Last active
October 22, 2023 13:08
-
-
Save ilyaevseev/491982f0db84c8590715ef272466ae30 to your computer and use it in GitHub Desktop.
Shrink rootfs for container under Proxmox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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