How to extend swap space on Linux

This post describes how to extend swap space on Linux by adding a new LVM device also extend an existing LVM device.

How to add a new LVM device to swap space?

Step 1:Create the LVM  logical volume of size  500MB.

#lvm lvcreate VolGroup00 -n LogVol03 -L  500M

Step 2:Format  new swap space

#mkswap /dev/VolGroup00/LogVol03

Step 3:Add  following  line to the /etc/fstab.

#vi /etc/fstab
/dev/VolGroup00/LogVol03 swap swap defaults 0 0

Step 4:Enable the extended  logical volume

#swapon -va

How to extend  existing  swap  space ?

Red Hat 6  'll allocate all swap space while installing the Operating system. For this case, you need to add a new storage device to VG  to extend swap space.

After adding additional storage to the swap space's volume group(VolGroup00) it's possible to extend swap space. Use this action plan to extend  Swap space.

Step 1:Disable swapping  for  LVM 

#swapoff -v /dev/VolGroup00/LogVol01

Step 2:Resize  LVM device

#lvresize  /dev/VolGroup00/LogVol01 -L +2G

Step 3:Format  extended swap space

#mkswap /dev/VolGroup00/LogVol01

Step 4:Enable  extended swap space

#swapon -v  /dev/VolGroup00/LogVol01


I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me

Related Post