I wanted to grow the root filesystem of an Ubuntu 18.04 VM hosted in Proxmox PVE from 500GB to 2TB.
The VM is well backed up using Proxmox Backup Server and I have been through similar efforts with other VMs in other environments so I felt confident enough to proceed.
I started by shutting down the VM and using the PVE GUI (Hardware > Hard Disk > Disk Action > Resize) and specifying 2000 in the GB box. Then I started the VM, confirmed the change and shutdown again to take a snapshot before proceeding.
After booting the VM again I started to work through what I thought would be a relatively straightforward process of growing the partition, growing the physical volume, growing the logical volume, and then growing the filesystem.
It wasn't working as well as I expected. Searching online showed how to add a new partition of type `8e` (Linux LVM) to consume the free space, then creating a physical volume on it, then adding it to the volume group, then extending the root volume.
I thought this was a bit messy and thought there must be a way to just grow the existing partition without having to create a new one. Running `growpart /dev/sda 5` seemed to suggest that it was able to add a bunch of space to the partition but none of the pv, vg, and lv display, extending, or resizing commands seemed to suggest that the free space was available or that growth was possible.
In the end I perhaps jumped the gun by removing the swap LV thinking that it was blocking the growth of the root LV. Then I realized that the /dev/sda5 partition hosting the VG was an extended partition and that /dev/sda2 (the primary partition assigned to hold extended partitions) might need to be grown before /dev/sda5.
So what I ended up with was more or less:
swapoff -a
lvremove hostname-vg/swap_1
growpart /dev/sda 2
growpart /dev/sda 5
pvresize /dev/sda5
lvextend hostname-vg/root /dev/sda5
resize2fs /dev/hostname-vg/root
But I'm not sure that I actually needed to remove the swap and was maybe just missing the `growpart /dev/sda 2` before the `growpart /dev/sda 5` and the rest to make it work. The next time I need to do this... try without removing swap first.
Addendum - 2026-03-27
I recently had to do something similar when trying to upgrade Ubuntu 18.04 VMs to newer LTS versions. When these were installed (maybe before 18.04) the boot partition was created as only 250MB in size. This was too small for larger kernels and could even result in problems for upgrading kernels within those releases. And as I have seen multiple times now, a `do-release-upgrade` with a boot partition that small results in an aborted upgrade. I was able to resolve this in PVE by:
- selecting the hard disk in the VM's hardware tab and choosing "Disk Action -> Resize" in the menu above.
- going into the VM Options and adjusting the Boot Order to have the ide CD/DVD device first in line for booting.
- booting into GParted and choosing the defaults to get to the GUI
- deactivating the LVM vg (in my case sda5) by right clicking on it and choosing Deactivate. This also deactivated the related LVM primary partition (in my case sda2)
These nest steps I did one at a time and had to fiddle a bit with getting the GUI to get the correct numbers in the before/size/after fields. The GUI arrows to grow/shrink and dragging with mouse to move was handy.
- Right click on the primary (outer LVM) partition and choose "move and resize" and drag it to consume the whole disk. Growing at the end of the partition will be fast.
- Grow and move the extended (inner LVM) partition leaving 1000MB of space before it if you can and 10MB after. If it gives you a hard time, just grow it and then shrink it from the beginning afterwards.
- Shrink the primary (outer LVM) partition afterwards. Might need to leave a small amount of unallocated space at either end to avoid any errors about things not able to start after they end or something like that.
- Once the LVM shuffle to the right is done, you should be able to grow the primary boot partition (in my case sda1) to fill the space left for it.