Skip to content

Instantly share code, notes, and snippets.

@dkam
Created February 8, 2024 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkam/dca0842c15d11db26ceec736b3f1cfe8 to your computer and use it in GitHub Desktop.
Save dkam/dca0842c15d11db26ceec736b3f1cfe8 to your computer and use it in GitHub Desktop.
Shrink LXC container

Shink the volume of a Proxmox LXC container

From the Proxmox Forum

List the containers:

pct list

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:

vi /etc/pve/lxc/999.conf

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

Start it:

pct start 999

Enter it and check the new size:

pct enter 999
df -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment