- Let’s explore how to create virtual memory, also known as swap memory, in Linux using a loop device. It’s an exciting process that can significantly enhance your system’s performance.
- To begin, use the dd command to create a file:
# dd if=/dev/zero of=a.txt bs=1M count=400
- Once the file is created, let’s attach it to a loop device:
- #
losetup /dev/loop0 a.txt
format the loop device /dev/loop0 with mkswap
#mkswap /dev/loop0
- Then activate swap using swapon command.
- #
swapon /dev/loop0
Now you can check you Swap memory using free -m command
- #free -m
Also you can verify swap is created over loop device or not using below command.
- cat /proc/swaps
How to Remove swap memory:Learn removal process.
- First run swapoff command to Disable swap memory
- #
swapoff /dev/loop0
- Now deattach loop device from file using below command.
# losetup -d /dev/loop0
- Time to cross check the removal.
losetup -a
- At latst time to delete file a.txt we created.
# rm -rf a.txt
Discover more from Learn Linux CCNA CCNP CEH CISSP CISA Penetration-Testing Bug Bounty IPv6 Cyber-Security Network-Security Online
Subscribe to get the latest posts to your email.