LVM is not as useful in a virtual server environment

Posted June 17th, 2011 by bryanr

It wasn’t that long ago that I decided to partition a couple of our new servers using the LVM file system.  I have read that using the LVM (logical volume manager) is much for flexible than using standard ext3 or ext4 partitions.  This is true when you are using a physical server with physical hard drives, because when you run out of disk space, your only option is to add additional hard drives.  Using logical volumes makes it very easy to add new disks to existing volume groups and expand the volumes.

But, when your servers are in a virtual environment, you can easily make the hard drive larger with a setting change.  Expanding volumes and expanding ext partition both require server downtime too, so there aren’t many advantages.  Let’s just compare the steps taken to expand both file systems on a virtual server.

For logical volumes:

1. Increase the size of the vdisk, and reboot.

2. On guest OS, create a new partition to use free space (‘fdisk -l’ and ‘fdisk /dev/sda’), and reboot.

note: the new lvm partition must have an ID type “8e” in fdisk

note: if you are using and extended partition, you will have to boot to a partition utility to resize it first (gparted works great)

3. Create a physical volume on the new partition with pvcreate.

4. Extend the existing volume group to the new partition with vgextend.

5. Expand the logical volume to fill the volume group (use ‘lvextend -l +100%FREE /dev/vg/lv’ to use the remaining space so you don’t have to calculate the exact size.  ‘lvresize’ can also be used.)

6. Expand the filesystem to fill the logical volume (‘resize2fs -p /dev/vg/lv’)

note: use ‘lvdisplay’ to find the correct path to your volume groups

Here is the same process for standard partitions:

1. Increase the size of the vdisk, and reboot.

2. Boot to a partition utility and resize your current partition to fill the new disk size (I use a gparted boot cd iso).

note: if you have multiple partitions, you will have to move the partition around on the disk to resize in certain situations.

I can conclude the standard partitioning is much easier to resize.

Here is a good reference blog for LVM resizing:

One Response to “LVM is not as useful in a virtual server environment”

  1. barosl

    I’ve just reached the very same point with you. In addition to the complexity you described, LVM is also not good for shrinking logical volumes.

    I had thought LVM could automagically resize partitions online a few hours ago, but now I find it wrong. No royal road, huh?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>