Friday, October 31, 2008

ADD TEMPORARY SWAP SPACE IN LINUX

TO ADD A TEMPORARY SWAP SPACE IN LINUX:

To check the Swap space Available:

[root@apps ~]# /sbin/swapon -s

Filename Type Size Used Priority
/dev/hdc2 partition 4096564 238796 -1


To install an extra 64 MB of swap space:


dd if=/dev/zero of=/swap bs=1024 count=65535 ---> adding 64 MB of swap for the variable dd.
mkswap /swap ----> create swap named /swap
swapon /swap ----> Swap on

Now check the space :

[root@apps /]# /sbin/swapon -s

Filename Type Size Used Priority
/dev/hdc2 partition 4096564 247632 -1
/swap file 65524 0 -3

The /swap is added as 64 MB.

1. The count= argument to dd determines how big the swap file will be.
2. In this example the swap file's name is /swap, but the name and location are, generally, arbitrary, depending only on the file system's available space.
3. you should have write permissions in the directory.

Temp Swap OFF:

When you don't need the swap space any more, remove it with the following statements:

swapoff /swap ---> To Off
rm /swap ---> To Remove

Note :

The recommendation for an Enterprise Edition is to use twice as much SWAP space as RAM up to 4 GB and then use an equal amount of RAM vs. SWAP after 4 GB.

No comments: