echo "Copying base image $baseimage to $image..."
if which rsync &> /dev/null; then
- rsync -ah --progress $baseimage $image
+ rsync -ah --sparse --progress $baseimage $image
else
- cp $baseimage $image
+ # See https://rwmj.wordpress.com/2010/10/19/tip-making-a-disk-image-sparse/
+ cp --sparse=always $baseimage $image
fi
if [ -e "$basekey" ]; then
# Copy image and configuration
echo "Copying basebox..."
if which rsync &> /dev/null; then
- rsync -ah --progress `dirname $image`/ $FOLDER/
+ rsync -ah --sparse --progress `dirname $image`/ $FOLDER/
else
- cp -r `dirname $image` $FOLDER/
+ cp -r --sparse=always `dirname $image` $FOLDER/
fi
# Remove old state folder