diff options
author | Antonio Terceiro <antonio.terceiro@linaro.org> | 2013-06-11 11:44:04 -0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-07-14 17:03:28 +0100 |
commit | 83d5fb709c6f75557a0fc3511042205d2a722357 (patch) | |
tree | 5d036a961f9e61482a33bacfbdf37354bc7df79d | |
parent | 3520e4d1f4ef05386e4a3b12e66cd7b0dc7e327d (diff) | |
download | vmdebootstrap-83d5fb709c6f75557a0fc3511042205d2a722357.tar.gz |
Optimize final image compression rate
Filling up the image with zeros makes its compression rate a lot higher.
Together with running `apt-get clean`, I got an 1GB image compressed
down to 106M, against to 210M without these 2 changes.
-rwxr-xr-x | vmdebootstrap | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vmdebootstrap b/vmdebootstrap index 5b4fa96..7327414 100755 --- a/vmdebootstrap +++ b/vmdebootstrap @@ -115,6 +115,7 @@ class VmDebootstrap(cliapp.Application): self.customize(rootdir) if self.settings['image']: self.install_extlinux(rootdev, rootdir) + self.optimize_image(rootdir) if self.settings['tarball']: self.create_tarball(rootdir) except BaseException, e: @@ -364,7 +365,16 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s self.runcmd(['extlinux', '--install', rootdir]) self.runcmd(['sync']) import time; time.sleep(2) - + + def optimize_image(self, rootdir): + """ + 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]) + + def cleanup_system(self): # Clean up after any errors. |