]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Optimize final image compression rate
authorAntonio Terceiro <antonio.terceiro@linaro.org>
Tue, 11 Jun 2013 14:44:04 +0000 (11:44 -0300)
committerLars Wirzenius <liw@liw.fi>
Sun, 14 Jul 2013 16:03:28 +0000 (17:03 +0100)
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.

vmdebootstrap

index 5b4fa96187affa0fef7d292718eadd2d097554a5..73274144b246cb1675a3ac1f7bb387f2bd5dc0a5 100755 (executable)
@@ -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.