Proxmox shrinking an LVM VM disk

When I built my server I made a VM that should only have had a 30G disk, but I accidentally gave it 300G. Since I had plenty of space at the time… I left it. But, I kinda need the space now and I’d like to shrink the disk.

Inside it is an Ubuntu server install (with LVM too). Boot from an Ubuntu iso, use resize2fs to shrink the size of the filesystem, lvreduce to shrink the LVM, resize2fs again since I made the filesystem deliberately a little smaller. Works fine, got it to 30G…

However, if I now use lvreduce on the Proxmox commandline to reduce the size of the disk… it’s broken. So I’m missing a step here. Can anyone help me?

i don’t think you can do a resize2fs after making the LVM adjustment.
in practice i do this:

When shrinking , you should perform actions in this order

  1. Resize the file system
  2. Resize the logical volume

When growing , you should perform actions in this order

  1. Resize the logical volume
  2. Resize the file system

if that still does not work out for you, just use proxmox to backup the VMs onto a USB drive, reinstall proxmox how you want, then import the VMs and there you go. (this may be faster anyway, LVM can be a battle)

1 Like

If you have 30G free, you could attach a new/second volume. Run vgextend, pvmove, vgreduce. Then remove the second volume. It’s inefficient because it requires data copying, but if it’s only 30G it shouldn’t take long. And doesn’t require downtime (except reboot)

1 Like

Did you care about shrinking the partition? If so, create a lvm thin partition and just move the lvs to it. Then you don’t have to care about oversizing anymore and you can easily do lvm snapshots

This

should be what you need …

2 Likes

Personally, if I can’t do it through simpler options like lvresize, which I haven’t looked into yet, I just brute-force my way in, by live-booting an iso, adding a second disk, formatting it, copying files over, chrooting into the environment, modify the fstab, then finally run a grub-update (or your preferred bootloader’s update option). Then power off the VM and remove the first disk, then use the second one and be done with it. Takes a bit of time, but it’s not too overly complicated.

Hmm, might do this, if I have enough space. Not sure, this is the reason I’m looking into this in the first place.