Increasing storage on a RHEL 6 virtual machine with LVM

Recently I had to increase the available space on a virtual machine running RedHat Linux 6. The filesystem was configured with LVM, so the quick answer that came to mind was to add another virtual hard drive and expand. While this would work, it was “messy” as future expansion in this fashion would get out of hand. And by "out of hand" you might end up with a single VM with many small drives (HDDs) added to it over time - each would take up a bit of the virtual IO on the VM, and make recovery more challenging if one of those HDDs became corrupted.

The solution outlined below takes advantage of the fact that many virtualization environments will let you resize the size of the HDD presented to the guest VM.

Thankfully the solution was easier for my specific case:

  1. Confirm you're starting state to verify these steps work

    • Check the free LVM space assuming “/dev/sdb” is your disk in that volume group, and “MyVG” is the name of the volume group.

      vgdisplay MyVG | grep Free

  2. Power down your virtual machine.

    • This is because some virtualization systems and VMs don't handle changes to disk, RAM, or CPUs well while the VM is running.
    • Assuming your environment supports this, you can expand the VGs and LVs while running.
  3. Expand the HDD size within the virtual system host environment

    • In my case I am using VMware vSphere and increased from 60GB to 300GB.
  4. Boot the virtual machine

    • It should boot without any difference than before.
    • Login as root
  5. Run the “pvresize” command to tell the LVM subsystem to look at the new size of the HDD

    • Assuming the drive in question is “/dev/sdb”, run this command:

      pvresize /dev/sdc

  6. You can confirm your LVM has additional space by noting the “Free” section of the output of the “vgdisplay” for the volume group that /dev/sdb is associated with it.

    • vgdisplay MyVG | grep Free
  7. Now you can use the lvresize command to expand your LVs as necessary.

    • Remember to use the --resize flag when resizing so the filesystem will make the new space available.