Adding Swap Space
Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system from 128 MB to 256 MB, but there is only 256 MB of swap space. It might be advantageous to increase the amount of swap space to 512 MB if you perform memory-intense operations or run applications that require a large amount of memory.
You have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM2 logical volume. It is recommended that you extend an existing logical volume.
To extend an LVM2 swap logical volume (assuming To add a swap volume group (assuming To add a swap file:
The next time the system boots, it enables the new swap file.
Extending Swap on an LVM2 Logical Volume
/dev/VolGroup00/LogVol01
is the volume you want to extend):
swapoff -v /dev/VolGroup00/LogVol01
lvm lvresize /dev/VolGroup00/LogVol01 -L +256M
mkswap /dev/VolGroup00/LogVol01
swapon -va
cat /proc/swaps
free
Creating an LVM2 Logical Volume for Swap
/dev/VolGroup00/LogVol02
is the swap volume you want to add):
lvm lvcreate VolGroup00 -n LogVol02 -L 256M
mkswap /dev/VolGroup00/LogVol02
/etc/fstab
file:
/dev/VolGroup00/LogVol02 swap swap defaults 0 0
swapon -va
cat /proc/swaps
free
Creating a Swap File
count
being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
mkswap /swapfile
swapon /swapfile
/etc/fstab
to include the following entry:
/swapfile swap swap defaults 0 0
cat /proc/swaps
or free
.