Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Last active October 22, 2023 13:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ilyaevseev/491982f0db84c8590715ef272466ae30 to your computer and use it in GitHub Desktop.
Save ilyaevseev/491982f0db84c8590715ef272466ae30 to your computer and use it in GitHub Desktop.
Shrink rootfs for container under Proxmox
#!/bin/sh -e
# Based on https://serverfault.com/a/787380/228027
CT="123"
DIR="/$VE-$(date +%Y-%m-%d-%H%M)"
NEWSIZE="100G"
UNPRIV="1" # ..missed by dump/restore => should be selected explicitly
mkdir -p "$DIR"
pct stop "$CT"
vzdump "$CT" --dumpdir "$DIR" -compress lzo
pct destroy "$CT"
pct restore "$CT" "$DIR/vzdump-lxc-$CT"-*.tar.lzo --rootfs local:"$CT",size="$NEWSIZE" --unprivileged "$UNPRIV"
pct start "$CT"
: rm -rf "$DIR"
## END ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment