- Apr 22, 2019
shrinking a disk must be done manually.
You can loose your data so I recommand you to make a backup before.
first, shrink the fs in your container.
resize2fs will help you.
The next step would be to shrink the lv.
First of all thank you for your good advice, It would be worth making scripts to do the actions in an automated way.
Nevermind, found out how.
Documenting it here for posterity.
On your proxmox node, do this.
List the containers:
Stop the particular container you want to resize:
pct stop 999
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:
rootfs: local-lvm:vm-999-disk-0,size=32G >> rootfs: local-lvm:vm-999-disk-0,size=10G
pct start 999
Enter it and check the new size:
pct enter 999
WARNING: LV pve/vm-100-disk-0 maps 7.93 GiB while the size is only 6.00 GiB
mkdir /tmp/100 mount /dev/pve/vm-100-disk-0 /tmp/100 fstrim -v /tmp/100