Skip to content

Instantly share code, notes, and snippets.

@gfrn
Last active February 16, 2022 15:43
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 gfrn/3c1706394a6a0d260991d4d48afc9448 to your computer and use it in GitHub Desktop.
Save gfrn/3c1706394a6a0d260991d4d48afc9448 to your computer and use it in GitHub Desktop.
Shrink disk image by removing unused space
modprobe loop
losetup -f
losetup /dev/loop0 image.img
partprobe /dev/loop0
gparted /dev/loop0
fdisk -l /dev/loop0
truncate --size=$[(XXX+1)*512] image.img
losetup -d /dev/loop0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment