From 9c34bb89218c4cae225e46fee9d1f27788706d7f Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sat, 18 Oct 2014 17:24:45 +0100 Subject: [PATCH] Add sparse option to not fill image with zeros Patch from Jan Gerber --- vmdebootstrap | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vmdebootstrap b/vmdebootstrap index 8301bd5..126475f 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -112,6 +112,9 @@ class VmDebootstrap(cliapp.Application): self.settings.boolean(['grub'], 'Install and configure grub2 - disables ' 'extlinux.') + self.settings.boolean(['sparse'], + 'Dont fill the image with zeros to keep a sparse disk image', + default=False) def process_args(self, args): if not self.settings['image'] and not self.settings['tarball']: @@ -545,9 +548,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 not self.settings['sparse']: + 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.39.5