qubes-linux-template-builder/cleanup_image
Marek Marczykowski 75a63613bc 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.
2013-04-28 22:49:41 +02:00

30 lines
361 B
Bash
Executable File

#!/bin/sh
export IMG=$1
. ./builder_setup
set -e
if ! [ $# -eq 1 ]; then
echo "usage $0 <img_file_name>"
exit 1
fi
if ! [ -f $IMG ]; then
echo $IMG does not exist
exit 1
fi
ls -als $IMG
mount -o loop $IMG mnt || exit 1
export INSTALLDIR=`pwd`/mnt/
$SCRIPTSDIR/09_cleanup.sh
echo "--> Compacting image file..."
fstrim mnt/
umount mnt
ls -als $IMG