Ubuntu – Howto skip over cpio archive when multiple cpio archives are concatenated

18.04initramfs

When doing a update-initramfs -u that will eventually call /usr/sbin/mkinitramfs the __TMPEARLYCPIO variable will point to data that is prepended to the final initramfs. For an AMD system it seems to consist of an uncompressed cpio archive with only one file kernel/x86/microcode/AuthenticAMD.bin in. After the first cpio section the real initramfs starts, however because of the prepended section the simple zcat /boot/initramfsfile | cpio --extract now doesnt work any more.

  • how can I strip ofer the first prepended cpio? How can I calculate the size of one cpio archive?

Best Answer

  • As hinted here dracut's skipcpio does the trick: skipcpio. I can then use it like this:

    skipcpio /boot/initrd.img-4.12.0-rc6-custom > initrd.img-4.12.0-rc6-custom.real
    zcat initrd.img-4.12.0-rc6-custom.real | cpio --extract
    

    skipcpio skips over the first (noncompressed) ASCII cpio block and prints the rest. If two firmware blobs are prepended this has to be run two times.