Adding extra swap space to Linux
This is a quick guide to adding emergency 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.
STEP 1
Login as root
STEP 2
Create a new file of the size that you want to add using the following command. In this case the parameter 512k will make 512 mbytes of space.
dd if=/dev/zero of=/extraswap1 bs=1024 count=512k
STEP 3
Fix the permissions on the file so that only the creator can read / write to it.
chmod 0600 /extraswap1
STEP 4
Turn it into a swap file and tell linux to turn on the extra space
mkswap /extraswap1
swapon /extraswap1
STEP 5
If you want the swap to be enabled after the next reboot of the machine you will also need to add the following line to /etc/fstab
/extraswap1 swap swap defaults 0 0
FINALLY
You can verify that it is working by either using free or by looking directly at the proc filesystem using cat /proc/swaps
Did You find this page useful?
Yes
No