Friday, December 19, 2008

Increasing the swap space in Linux

Swap space can be increased in linux by using a swap file

1) Determine the size of the new swap file.


2) Multiply it with 1024 to determine the block size.

3) Login as a root. Execute the following commands

Create a swap file using the following command.

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

where

swapfile = Name of the swap file

bs=Block size.

Count= Block count (Block count of 2GB swap file is (2048*1024))

4) Setup the swap file.

mkswap /swapfile

5) Enable the swap file.

swapon /swapfile

6) To enable it at the boot time, Add the below entry in the /etc/fstab

/swapfile swap swap 00

The next time the system boots, it will enable the swap file.

After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command

cat /proc/swaps (or) free -m

No comments: