Shrinking the root disk of one of my LXC containers using the following commands:
List the containers:
pct list
Stop the particular container you want to resize:
pct stop XXX (XXX is the container ID)
Find out it’s path on the node:
lvdisplay | grep “LV Path\|LV Size”
For good measure one can run a file system check:
e2fsck -fy /dev/pve/vm-999-disk-0
Resize the file system:
resize2fs /dev/pve/vm-999-disk-0 10G
Resize the local volume
lvreduce -L 10G /dev/pve/vm-999-disk-0
Edit the container’s conf, look for the rootfs line and change accordingly:
nano /etc/pve/lxc/999.conf
rootfs: local-lvm:vm-999-disk-0,size=32G >> rootfs: local-lvm:vm-999-disk-0,size=10G
Start it:
pct start 999
Enter it and check the new size:
pct enter 999
df -h