6. January 2012 06:00
This is a quick guide to adding emergancy swap space to linux. Which is useful when you know a machine is going to run out memory. Or you need a lot of memory for a single task that cannot be completed without the extra memory.
Login as root
Create a new file of the size that you want to add using the following command. In this case 512 mbytes of space.
dd if=/dev/zero of=/extraswap1 bs=1024 count=512k
Fix the permissions on the file so that only the creator can read / write to it.
chmod 0600 /extraswap1
Turn it into a swap file and tell linux to turn on the extra space
If you want the swap to be enabled after the next reboot of the machine you will need to add the following line to /etc/fstab
/extraswap1 swap swap defaults 0 0
You can verify that it is working by either using free or by looking directly at the proc filesystem using cat /proc/swaps