I would like to shrink the main disk of a LXC container on a Proxmox VE 4.2, from 30GB to 20GB for instance. Shrinking seems not to be supported yet :
$ pct resize <VMID> rootfs 20G unable to shrink disk size
Any ideas on how to accomplish this ?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
You probably figured it out already, but that seems to be a limitation of LXC containers, at least for now. From the pct man page :
<size> \+?\d+(\.\d+)?[KMGT]? The new size. With the + sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.
If you truly want to shrink a container, I guess you'd have to perform a backup, then restore it with the
--rootfs local:<newsize> option, like so :
pct stop <id> vzdump <id> -storage local -compress lzo pct destroy <id> pct restore <id> /var/lib/lxc/vzdump-lxc-<id>-....tar.lzo --rootfs local:<newsize>
Of course, you can't perform this sort of resizing online, so I wouldn't call it a great solution, but it works if you have no other choice.