[Vmdebootstrap-devel] [PATCH 1/3] Don't fill image with zeros by default

Jan Gerber j at mailb.org
Mon Oct 13 10:17:20 UTC 2014


add --optimize-image flag to fill image with zeros. while filling with
zeros improves the compression, it also requires the actual size of the
disk image on the host that builds the vm. By default the disk image is
sparse and only the space required for the installation is used.
---
 vmdebootstrap | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/vmdebootstrap b/vmdebootstrap
index fafd78a..f3fa192 100755
--- a/vmdebootstrap
+++ b/vmdebootstrap
@@ -114,6 +114,8 @@ class VmDebootstrap(cliapp.Application):
         self.settings.boolean(['grub'],
                               'Install and configure grub2 - disables '
                               'extlinux.')
+        self.settings.boolean(['optimize-image'],
+                'Filing up the image with zeros to increase its compression rate')
 
     def process_args(self, args):
         if not self.settings['image'] and not self.settings['tarball']:
@@ -539,9 +541,10 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s
         """
         Filing up the image with zeros will increase its compression rate
         """
-        zeros = os.path.join(rootdir, 'ZEROS')
-        self.runcmd_unchecked(['dd', 'if=/dev/zero', 'of=' + zeros, 'bs=1M'])
-        self.runcmd(['rm', '-f', zeros])
+        if self.settings['optimize-image']:
+            zeros = os.path.join(rootdir, 'ZEROS')
+            self.runcmd_unchecked(['dd', 'if=/dev/zero', 'of=' + zeros, 'bs=1M'])
+            self.runcmd(['rm', '-f', zeros])
 
     def squash(self):
         """
-- 
2.1.1




More information about the Vmdebootstrap-devel mailing list