Saturday 1 March 2014

Resize swap memory in linux

We needed to to increase swap memory for one of our client who was using SUSE linux. There are two methods to overcome this and we used the following method.

Switch off swap

swapoff -a
First create a file named myswapfile and in this command count=1024 means 1GB so forexample our client needed swap memory of 44GB so we change count=45056

dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
after file is created change the permission to root only

chmod 600 /root/myswapfile
enable the newly created swap

swapon /root/myswapfile
Add the following enteries in the fstab to keep the swap space after reboot

cat /etc/fstab /root/myswapfile swap           swap    defaults        0 0
after entry to make sure new swap is used:

swapoff -a

swapon -a
then verify using the top command. Hope it helps !


Ref: http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/

No comments:

Post a Comment