Adding a Swap File to Linux

Adding a Swap File to Linux: "

You can add swap space to your Linux system by following this HowTo. You may want to do this because your existing swap space is insufficient or because you want to move your swap space to another location. This HowTo will create a swap “file” and mount it as swap space. However, typically Linux uses a partition as swap space.


Create the swap file in the location that you choose. In this example the swap file is 100MB in size:



dd if=/dev/zero of=/swapfile bs=1024 count=100000

Tell Linux that your new file is a “swap file”:



mkswap -f /swapfile

Turn the new swap file on:



swapon /swapfile

Also consider adding your new swap file to the “/etc/fstab” file:



/swapfile swap swap defaults 0 0
"