How to Increase a Volume Group Size Linux LVM

Everytime I step away from linux when i get back this LVM stuff always look like chinese to me. So i decided to write this post to remind me of the steps. Hopefully it will help somebody else out there.

First of all, the Volume Group LVM is handled by software, it is an abstraction layer between the operating system and the file system. To increase the Volume Group Size is like adding another partition to your system and have the LVM software pick it up. The OS sees all these added partitions as one and it does not care since it communicates with the drives via the LVM software. Now if one these partitions/drives goes bad, you are in deep sh?? since the operating system spread the files through them just like they were just one single drive.

For the sake of this tutorial let say you have the following scenario:

You have a system with a lvm partition of 10G. Within this partition you have two LOGICAL VOLUMES : the root partition and the swap partition. You realize that the 10G is not sufficient for your operating system and you want to increase it. What should you do?

1. The first thing is to add storage to the system

Let’s say you add a new 50G hard drive or you extend your VM drive by 50G or you use another free partition scattered on your system.

2. Step #2 is to add that drive to the volume group by creating a PHYSICAL VOLUME

Again it is all software. Here is the command:

pvcreate /dev/xdax

replace the x’s by hda2 or sda2 for example.

3. Now you have to extend the volume group to the added size

Here is the command:

vgextend /dev/VolG1 /dev/xdax

Once your volume group is extended, the next thing is to augment your root partition to part of 50G or to the full 50G.

lvresize -L +20G /dev/VolG1/root

I have just added 20G to my root partition.

We are not done yet.
Now we need to expand the logical root partition to the added 20G.
Here is the command:

resize2fs -p /dev/VolG1/root

Now you are done.
The root partition has been increased by 20G. Since we added 50G we still have 30G left that we can use for other purposes. We did not have to reboot the system. We can keep adding disk until we reach the system limitation.

Reference
http://www.howtoforge.com/logical-volume-manager-how-can-i-extend-a-volume-group

LVM manual
http://tldp.org/HOWTO/LVM-HOWTO/index.html

Expand The virtual Machine Disk
http://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-expanding-the-virtual-machine-disk/