Proxmox: Shrinking disk of an LVM backed container

Posted by

First, shut down the container and ensure it’s not running.

List out the LVM logical volumes:

lvdisplay | grep "LV Path\|LV Size"

Choose the disk you want to resize – you’ll see they’re named by container ID and disk number. For example, /dev/vg0/vm-205-disk-1.

Check and fix the filesystem, just incase:

e2fsck -fy /dev/vg0/vm-205-disk-1

Resize the file system. It is advisable, at this point, to set this to 1GB smaller than you actually want it (e.g. 7G when you want 8G):

resize2fs /dev/vg0/vm-205-disk-1 7G

Resize the LVM LV to the actual size you want it to be:

lvreduce -L 8G /dev/vg0/vm-205-disk-1

Resize the file system to fill the LVM LV:

resize2fs /dev/vg0/vm-205-disk-1

Finally, edit the configuration for the container such that Proxmox reports the correct size for the disk. You will find this at /etc/pve/lxc/205.conf where 205 is your container ID.

You can now start your container and check the disks’ sizes:

df -h

9 comments

  1. Thanks for the article. You should encourage the user to perform a proxmox backup of the container too, since it’s very easy and will be a lifesaver if you mess up.

  2. Hi Phil, it’s a shame they haven’t made this a function of the GUI! Great little guide, really helped me out. Thanks so much!

Leave a Reply to anonymous Cancel reply

Your email address will not be published. Required fields are marked *