Skip to main content

Reducing size of container LV

Reducing the size of a disk is a very risky procedure, ensure that all data is backed up first.
Note I have had this process fail a number of times, my preferred method for reducing the size of a VM disk is to spin up a new VM with a smaller drive, rsync the relevant data across, and then delete the old VM.

 

Step One - CONFIRM volume name and path

pct list
pct stop <container id number>
lvdisplay | grep "LV Path\|LV Size"

 

Step 2 - Resize file system and logical volume

resize2fs /dev/pve/vm-999-disk-0 10G
lvreduce -L 10G /dev/pve/vm-999-disk-0

 

Step 3 - Edit container conf

nano /etc/pve/lxc/<container id>.conf

rootfs: local-lvm:vm-999-disk-0,size=32G >> rootfs: local-lvm:vm-999-disk-0,size=10G

 

Step 4 - Confirm new disk size

pct start <container id>
pct enter <container id>
df -h