Installation guide

Chapter 14. Swap Space
92
14.2.1. Extending Swap on an LVM2 Logical Volume
By default, Red Hat Enterprise Linux 6 uses all available space during installation. If this is the case
with your system, then you must first add a new physical volume to the volume group used by the
swap space. For instructions on how to do so, refer to Section 3.2.2, “Adding Unallocated Volumes to
a Volume Group”.
After adding additional storage to the swap space's volume group, it is now possible to extend it. To
do so, perform the following procedure (assuming /dev/VolGroup00/LogVol01 is the volume you
want to extend by 256MB):
1. Disable swapping for the associated logical volume:
swapoff -v /dev/VolGroup00/LogVol01
2. Resize the LVM2 logical volume by 256 MB:
lvresize /dev/VolGroup00/LogVol01 -L +256M
3. Format the new swap space:
mkswap /dev/VolGroup00/LogVol01
4. Enable the extended logical volume:
swapon -v /dev/VolGroup00/LogVol01
To test if the logical volume was successfully extended, use cat /proc/swaps or free to inspect
the swap space.
14.2.2. Creating an LVM2 Logical Volume for Swap
To add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you
want to add):
1. Create the LVM2 logical volume of size 256 MB:
lvcreate VolGroup00 -n LogVol02 -L 256M
2. Format the new swap space:
mkswap /dev/VolGroup00/LogVol02
3. Add the following entry to the /etc/fstab file:
/dev/VolGroup00/LogVol02 swap swap defaults 0 0
4. Enable the extended logical volume:
swapon -v /dev/VolGroup00/LogVol02
To test if the logical volume was successfully created, use cat /proc/swaps or free to inspect the
swap space.
14.2.3. Creating a Swap File
To add a swap file: