Create Swap file at Linux

How to add more Linux Swap with Swap File

Assuming you want to put it in "/", Create an empty 500MB file
$ sudo dd if=/dev/zero of=/swap.img bs=1024k count=512

Format it as a swap file
$ sudo mkswap /swap.img

Add it to your running Linux system
$ sudo swapon /swap.img

Optionally you can add /swap.img to fstab for automatic swap activation.

$ sudo gedit /etc/fstab

Add this line at the end of the file
/swap.img none swap sw 0 0

Run "free -m" command to verify that you've added the newly created swap to your Linux based operating system.

Hope that helps!

Comments

Popular Posts