How do I reduse lxc's rootfs partition size ?

tukiyo3

Well-Known Member
Sep 13, 2015
30
1
48
lxc's rootfs couldn't reduse image size, but openvz's rootfs could.
How do I reduse lxc's rootfs partition size ? (Host filesystem is ext4.)
 
`pct resize` currently only allows increasing the size, but depending on the storage you should be able to do this manually the way you'd expect on a linux system.
Eg. if it's a directory based storage you have a .raw file with an ext4 filesystem on it, there you can use resize2fs to shrink it, then run use the truncate command to shrink the file itself.
However, be careful when you do it, if you truncate the file to a size smaller than you resized it to with resize2fs you'll be in trouble.
 
hello tukiyo3


here is my unofficial workaround:

1) open the CT config on the host node (/etc/pve/nodes/HOSTNAME/lxc/CTID.conf)
2) search for "rootfs: local:CTID/vm-CTID-disk-1.raw,size=XXXG" and edit size=XXX to the new rootfs size you want
3) make a backup of the CT (via gui or cli)
4) restore the backup


it's with a little downtime and maybe not perfect - but for me it is working fine
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!