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 -----------------------
Do
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 ....