Thursday, October 18, 2007

More SWAP space with a SWAP file

Hi Friends,

There is a possibility for adding extra swap space even after installation. The swap space is nothing but a virtual memory (Hard disk space acting as a RAM space). Any linux distribution requires the swap space for deploying the kernel. The recommended swap space is to be twice that of the RAM size. In case, you are starting from a scratch or forget to allocate the required space for the /swap partition at the time of installation, no harm it can be extended easily.

The trick is to make a file and then tell the swapon program to use it. Here's how to create, for example, a 64
megs swap file on your root partition (of course make sure you have at least 64 megs free):

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

This will make a 64 megs (about 67 millions bytes) file on your hard drive. You now need to initialize it:

mkswap /swapfile 65536
sync

And you can then add it to your swap pool:

swapon /swapfile

With that you have 64 megs of swap added. Don't forget to add the swapon command to your startup files (chkconfig --list) so that the command will be repeated at each reboot.

Thanks

Logu
logu_microsoft@hotmail.com
91-98414-99143

No comments: