]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Copy guest images as sparse files
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 3 Jun 2017 17:02:54 +0000 (14:02 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 3 Jun 2017 17:02:54 +0000 (14:02 -0300)
kvmx

diff --git a/kvmx b/kvmx
index 29e56618060d26fe1527a3f9025097d45e7562a1..16da59d11481417a0e620d9cb5b933e967758d90 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -274,9 +274,10 @@ function kvmx_up {
 
         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
@@ -735,9 +736,9 @@ function kvmx_clone {
   # 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