I am trying to update a process used to remaster the Ubuntu 18.04 install image for 20.04 and running into a problem with extracting the initrd archive. The command used is cpio -id --no-absolute-filenames. When I use this same command to extract the initrd image from the 20.04 image, it extracts kernel/x86/microcode/AuthenticAMD.bin and stops.

Inspecting initrd file contents I can see a "TRAILER" section showing that there are multiple archives in the file. As suggested in other threads about cpio archives, I tried to extract the compound archive as such: cat initrd | while cpio -id --no-absolute-filenames; do :; done. In this case, the first entry extracts but then it has a bunch of "0 blocks" and doesn't extract anything else.

Does anyone know how this archive was created or how to extract it?

3 Answers 3


/usr/sbin/update-initramfs calls /usr/sbin/mkinitramfs, which calls

cpio --quiet -R 0:0 --reproducible -o -H newc | lz4 -9 -l

where the lz4 is coming from /etc/initramfs-tools/initramfs.conf

reversing that into

cat /boot/initrd.img-5.4.0-26-generic | unlz4 -9 -l | cpio -i -H newc

fails though.

cat /boot/initrd.img-5.4.0-26-generic | file -
    /dev/stdin: ASCII cpio archive (SVR4 with no CRC)

keeps persisting it's a cpio archive, but

cat /boot/initrd.img-5.4.0-26-generic | cpio -i -H newc

still ends up in the same AuthenticAMD.bin. Maybe somebody else can build on this?

Edit: nope. According to https://unix.stackexchange.com/a/511224/44864 The answer is

 unmkinitramfs -v initrd.img-5.4.0-26-generic .
  • unmkinitramfs also extracted GenuineIntel.bin and a junk directory named .enuineIntel.align.0123456789abc, seemingly misunderstanding some metadata. It then errors with premature end of archive.
    – virullius
    Apr 27, 2020 at 14:48
  • I suggest you look into the checksum of your downloaded copy of ubuntu-20.04-live-server-amd64.iso as I just downloaded it, and successfully unpacked the initrd.img from it with unmkinitramfs.
    – JdeHaan
    Apr 27, 2020 at 14:59
  • is the file you're looking at called "initrd.img"? I am looking at /casper/initrd.
    – virullius
    Apr 28, 2020 at 17:36
  • Yes: pastebin.com/MqDVq6P8
    – JdeHaan
    Apr 29, 2020 at 6:38
  • I suggest you download nl.archive.ubuntu.com/ubuntu/pool/main/i/initramfs-tools/… and extract it with mkdir initramfs-tools-core cd initramfs-tools-core dpkg -x ../initramfs-tools/initramfs-tools-core_0.136ubuntu6_all.deb . dpkg -e ../initramfs-tools/initramfs-tools-core_0.136ubuntu6_all.deb ls -al ./usr/bin/unmkinitramfs -rwxr-xr-x 1 me me 3595 Feb 18 02:19 ./usr/bin/unmkinitramfs
    – JdeHaan
    Apr 29, 2020 at 6:45

Same problem here -- the solution was to not unpack with Ubuntu version 20.04 using unmkinitramfs.

I created a bootable USB and booted my machine into Ubuntu 20 -- unmkinitramfs was then able to unpack the initrd. I'm still finding my way around building a new bootable USB that doesn't autologin (and works correctly with casper-rw).

If you want to see more about what unmkinitramfs does, it's a bash script. In a comparison between Bionic and Focal, Bionic does not supprt lz4 compression.

  • So is the point here that the version of unmkinitramfs shipped with versions previous to 20.04 not compatible with the format used?
    – virullius
    May 15, 2020 at 16:08
  • That is indeed the issue. I needed the version shipped with 20.04.
    – virullius
    May 15, 2020 at 19:34
  • when tried I got unmkinitramfs command not found message even though I have initram tools May 3, 2021 at 19:13

I'm currently creating a custom live CD, based on Ubuntu 20.04 live CD. Everything is fine untill i tried to modify initrd. I mean the initrd located in the casper directory of the iso.

The standard way to build the live cd ,as far as i understood, is first.

Extract the iso in a separate directory

Extract the squashfs file system in a separate directory

Mount proc sys dev .. prior to make the chroot on the squashfs directory

# Make a chroot on squahfs dir

And you can start modifying the squashfs filesystem for your needs.

# Make your modifications

Prior to leave your chroot

# Do an update-initramfs (update-initramfs -k all -u)

Rebuild the squashfs image

Copy it into the iso dir

Rebuild the iso image.

One thing i noticed, update-initramfs does not modify initrd.

In my case i was changing the plymouth theme.

  • So, instead i tried to create a new initrd, based upon the original initrd located under /casper.

mkdir temp;cd temp unmkinitramfs ../initrd . # (casper) mkinitramfs . -o ../initrd.new

To me, this should create an initrd.new with the same size as the original.

But its not the case ! the new one is bigger

Otherwise, i tried an other method -----------------------


binwalk initrd .. 3492528 0x354AB0 ASCII cpio archive (SVR4 with no CRC), file name: "TRAILER!!!", file name length: "0x0000000B", file size: "0x00000000" 3492864 0x354C00 LZ4 compressed data, legacy

Just after the TRAILER line (get the lz4 size , here 3492864)

dd if=../initrd bs=3492864 skip=1 | unlz4 -c | cpio -id

Now rebuild initrd

find | cpio -H newc -o | lz4 -c > ../initrd.partial.lz4

And finally concatenate the microcode files and your new initrd (initrd.partial.lz) by

Count is block size divided by 512

dd if=../initrd of=../initrd.microcode bs=512 count=6822

Rebuild the newinitrd

cat ../initrd.microcode ../initrd.partial.lz4 > ../initrd.new


They do not have the same size eather!

It looks like that with focal, the initrd format has changed somehow. For sure lz4 compression has been added to focal, but there is something else, but its not documented ....

  • 1
    Please, edit your answer... take your time and format properly. Oct 15, 2021 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.