Centos – gparted live CD can’t resize a partition

centosgpartedlvmvagrantvirtualbox

I recently ran out of space on a VirtualBox VM (CentOS guest) managed by Vagrant. It was using a .vmdk image, so I couldn't dynamically resize it. Following these instructions, I cloned the old image to a new, much larger vdi image, then attempted to resize the old partition using the GParted LiveCD. Unfortunately, even though I can see that the backing device is much larger, the partition (which is managed by LVM, since it is a CentOS guest) is displayed with a lock icon, and I can't resize it. I don't understand why the partition is locked: I'm using a LiveCD, so the FS is shouldn't be mounted (at least as I understand these things). Any suggestions on what I've done wrong? Thanks.

Best Answer

The process appears to be:

  1. create a new partition in your newly available free space; your choice of filesystem doesn't much matter, as we will change it later
  2. reboot into the system
  3. use cfdisk to flag the new partition as Linux LVM instead of whatever you chose above
  4. use pvcreate to flag your new partition as a physical volume for LVM
  5. use vgextend to add your new physical volume to your existing VolumeGroup
  6. use lvresize to expand your desired logical volume with the new space in its volume group
  7. use resize2fs to grow your fs to use the new space on your logical volume (I hope your filesystem supports online resizing)
  8. enjoy your now-spacious VM.
Related Question