diff options
author | Neil Williams <codehelp@debian.org> | 2014-10-18 17:24:45 +0100 |
---|---|---|
committer | Neil Williams <codehelp@debian.org> | 2014-10-18 17:24:45 +0100 |
commit | 9c34bb89218c4cae225e46fee9d1f27788706d7f (patch) | |
tree | bd88a2e86afb504a93d71d7a34333984da24b094 /vmdebootstrap | |
parent | 41f88537a1fd6363a0b2da9796a176f5a727e279 (diff) | |
download | vmdebootstrap-9c34bb89218c4cae225e46fee9d1f27788706d7f.tar.gz |
Add sparse option to not fill image with zeros
Patch from Jan Gerber <j@mailb.org>
Diffstat (limited to 'vmdebootstrap')
-rwxr-xr-x | vmdebootstrap | 10 |
1 files 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): """ |