cleanup-image: smart image shrink using fstrim

Linux loop driver support TRIM operation for some time (from 3.1
kernel), which is mapped to hole punch operation in underlying
filesystem (which must support it - ext* and xfs have it).
This is much faster and less space consuming than previous cp --sparse
method.
pull/1/head
Marek Marczykowski 11 years ago
parent 30155ba17b
commit 75a63613bc

@ -23,11 +23,7 @@ export INSTALLDIR=`pwd`/mnt/
$SCRIPTSDIR/09_cleanup.sh
echo "--> Compacting image file..."
dd if=/dev/zero of=mnt/fillme bs=1M > /dev/null 2>&1 || true
sync
rm mnt/fillme
fstrim mnt/
umount mnt
cp --sparse=always $IMG $IMG.new
mv $IMG.new $IMG
ls -als $IMG

Loading…
Cancel
Save