Skip to main content
Tim's (still) not blogging

Growing LVM in a VM with extended partitions

I had a 20GB virtual disk. I partitioned it with the debian installer and LVM, which gave me one primary boot partition and one extended partition for the rest. The large extended partition was my one LVM physical volume.

As you do, I didn’t allocate all of the LVM space right away, so I had room to expand /usr/local and /home the first time I ran out. When I needed more than my initial 20GB space, I should have just asked for a second virtual disk, create one big primary partition, add it as a pv to the vg, done. Instead I asked for the virtual disk to be expanded, which took more work:

  1. Expand virtual disk in VMWare
  2. Boot VM from gparted
  3. Expand the extended partition wrapper (sda2 for me) to fill the new space.
  4. gparted wouldn’t let me expand the existing LVM partition, but that’s fine.
  5. Reboot to debian
  6. Add a new extended partition to fill the new space. (I don’t remember if I specified it as type LVM or if vgextend did that.)
  7. Add the new partition to the vg with vgextend
  8. Use lvextend to grow the logical volume that needs space (live)
  9. Use resize2fs to grow the fs on that logical volume (live)

Oh, and maybe you should have backups before attempting this. I live on the edge.