[CentOS] How is initrd.img packed and compressed?

Nux! nux at li.nux.ro
Wed Jan 31 17:10:54 UTC 2018


Don't archive as lzma if you don't want lzma, remove the "--format=lzma" parameter.

hth
Lucian

--
Sent from the Delta quadrant using Borg technology!

Nux!
www.nux.ro

----- Original Message -----
> From: "Mircea Husz" <mirceahusz at yahoo.com>
> To: "CentOS mailing list" <centos at centos.org>
> Sent: Wednesday, 31 January, 2018 16:51:20
> Subject: [CentOS] How is initrd.img packed and compressed?

> Hi,
> 
> In order to work around a known upstream bug I needed to add a udev
> rule to pxeboot initrd.img on CentOS 7.
> 
> The process is straightforward:
> 1 - extract the pxeboot initrd.img  to a new directory
> 2 - add the udev rule needed to fix the bug
> 3 - pack and compress it back in initrd.img format
> 
> The resulting updated image works, it fixes the upstream bug and life
> is good. But although it works, it's not
> the same format as the original initrd.img that ships with the distro.
> I would like to know the proper incantation
> used to package initrd.img
> 
> Now for the specifics. The original image: http://mirror.steadfast.net/
> centos/7.4.1708/os/x86_64/isolinux/initrd.img
> is extracted: /usr/lib/dracut/skipcpio  initrd.img | xzcat | cpio -i -d
> and after adding the needed udev rule, it gets packed and compressed as
> follows:
> 
> find . 2>/dev/null | cpio --quiet -c -o | xz -9
> --format=lzma >"~/patched-initrd.img"
> 
> Now for the difference. FIrst the original distro image:
> # file initrd.img
> initrd.img: xz compressed data
> 
> # file patched-initrd.img
> patched-initrd.img: LZMA compressed data, streamed
> Without the --format=lzma  flag it fails to boot.
> 
> Does anyone know how this is done properly ?
> 
> Thanks,
> -Mike
> 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos



More information about the CentOS mailing list