RHEL6 – Managing Swap Space

54af9-6a00e551c39e1c8834017ee46a8c54970d-piSwap space on a Linux box is an area on disk that is used to hold inactive memory pages. This occurs when the system needs more memory then is currently available, so it swaps these inactive memory pages to disk.

To create additional swap space on the fly you are either going to need a spare disk or free partition on a disk that you can use.

First, using fdisk,  you will need to make sure that the partition type for the disk (or partition) is set to 82.

Then setup the swap area using mkswap. In this example I am using /dev/sdb2, but your setup is bound to be different.

>mkswap /dev/sdb2

Then determine the UUID of the new swap space.

>blkid /dev/sdb2

Then add an entry to the /etc/fstab, so that the swap space is mounted at boottime. The show in the example below is the output of the blkid command above.

>UUID=7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 swap                    swap    defaults        0 0

Then activate your new swap space

>swapon -a

Then check to make sure everything worked by checkign for your new swap partition in the output of the command below.

>swapon -s

/dev/sdb2                             partition       4193276 7480    0

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.