Skip to content

Instantly share code, notes, and snippets.

@libussa
Created March 14, 2018 13:18
Show Gist options
  • Save libussa/6df930d1a82d31338f7813de936e1681 to your computer and use it in GitHub Desktop.
Save libussa/6df930d1a82d31338f7813de936e1681 to your computer and use it in GitHub Desktop.
shrinking lxc disk
# Check file system
e2fsck -f vm-101-disk-2.raw
# Resize fs to new-size (will fail if not enough space empty)
resize2fs vm-101-disk-2.raw <new-size>
# Truncate image file, with some security (truncate will happen no matter what, +1GB is here to make sure we don't fck things up)
truncate -s <new-size + 1GB> vm-101-disk-2.raw
# Re-expand the fs to take up all the space (including the security from before)
resize2fs vm-101-disk-2.raw
# Edit container config to reflect new size
nano /etc/pve/lxc/101.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment