Skip to contentSkip to conversation

isoimage-isohybrid: don't include cpio in cpio image

PATCH Superseded Ioan-Adrian Ratiu 1 participant 1 message Sep 18, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 isoimage-isohybrid: don't include cpio in cpio image

Because the find | cpio processes execute in parallel connected via the pipe, and the cpio outputs in the same dir find searches for source files, the cpio will be included in itself partially, depending on how fast the build machine creates the cpio file before cpio gobbles it up.

This bloats the ISO image, though compression reduces the .iso file size, once the kernel decompresses the cpio image and boots it live, it uses up to double the RAM memory.

Fix this by creating the initrd.cpio file directly inside cr_workdir.

---
 scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +3 -5
index 25a695da17..3006223cda 100644
@@ -172,7 +172,6 @@ class IsoImagePlugin(SourcePlugin):
 
         if not initrd or not os.path.exists(initrd):
             # Create initrd from rootfs directory
-            initrd = "%s/initrd.cpio.gz" % cr_workdir
             initrd_dir = "%s/INITRD" % cr_workdir
             shutil.copytree("%s" % rootfs_dir, \
                             "%s" % initrd_dir, symlinks=True)
@@ -191,10 +190,9 @@ class IsoImagePlugin(SourcePlugin):
             else:
                 raise WicError("Couldn't find or build initrd, exiting.")
 
-            exec_cmd("cd %s && find . | cpio -o -H newc -R root:root >./initrd.cpio " \
-                    % initrd_dir, as_shell=True)
-            exec_cmd("gzip -f -9 -c %s/initrd.cpio > %s" \
-                    % (initrd_dir, initrd), as_shell=True)
+            exec_cmd("cd %s && find . | cpio -o -H newc -R root:root >%s/initrd.cpio " \
+                     % (initrd_dir, cr_workdir), as_shell=True)
+            exec_cmd("gzip -f -9 %s/initrd.cpio" % cr_workdir, as_shell=True)
             shutil.rmtree(initrd_dir)
 
         return initrd
Signature · 1 line
2.19.0