Shrink Proxmox LXC Storage
-
Shut down the LXC:
pct stop 102 -
Find the storage volume name:
lvdisplay | grep "LV Path\|LV Name" | grep 102 -
Check free space:
pct df 102 -
Resize it:
resize2fs /dev/pve/vm-102-disk-0 15G -
Check the filesystem:
e2fsck -fy /dev/pve/vm-102-disk-0 -
Resize the LV:
lvreduce -L 15G /dev/pve/vm-102-disk-0 -
Mount the drive and show the mount point:
pct mount 102 -
Trim the filesystem using the mount path shown:
fstrim -v /var/lib/lxc/102/rootfs -
Unmount it:
pct unmount 102 -
At this point a warning like this may appear:
WARNING: Thin volume pve/vm-102-disk-0 maps 262296436736 while the size is only 16106127360.The only thing that could make this work was to backup/restore it via the GUI. The ZFS mount was removed and re-added because a warning said it would erase mountpoints and it didn't seem worth the risk.