Wednesday, May 8, 2013

LVM2 Method of adding Swap Space

Ok, so- like any good admin.. you probably have your disks setup in LVM2.  If not, that's OK.  This post won't help you out.

Your first step is to disable temporarily for the particular swap LV you're working with.   This is probably best done during a maintenance cycle for your server.  Let's assume that your Swap LV is called SwapVolume and the VG that contains it is "VolumeGroup".   

First you'll need to check if you even have enough free space.   Do a "vgdisplay VolumeGroup" and see if you have enough free space.   The output is fairly clear wrt that.  If you don't have enough free space, you'll have to arrange for a disk to be added to the system somehow- either SAN or a physical hard disk.

Adding a disk is out of this post's scope, so we're assuming we have enough space.   I always like to keep a couple of gigs in my back pocket on each system I manage.

Disable swap:  swapoff -v /dev/VolumeGroup/SwapVolume

Resize the LV: lvresize /dev/VolumeGroup/SwapVolume -L +1G

Format the space:  mkswap /dev/VolumeGroup/SwapVolume

Re-enable the swap:  swapon -va

Check that you see the increased space:

cat /proc/swaps

No comments:

Post a Comment