How to correctly repack initrd.img from Rocky 9 iso image?


I try to create a custom Rocky 9 based iso image with different kickstart files.
I extract the initrd.img which comes with Rocky 9, add the kickstart files and repack the initrd.img again.
After this I create a new iso image and try to install the system.

Unfortunately this fails during startup of the custom iso. Directly after successful “Reached target Basic System.” I see multiple dracut-initqueue errors:
“cannot find an unused loop device”…
“failed to setup loop device”…
“failed to find a root file system”…

If I directly use the unpatched original Rocky 9 initrd.img file (in the custom iso) it is working and I can install the system (but of course need to setup things manually in anaconda).
So I guess the way I create the iso itself is ok and the issue is that I repack the initrd.img in wrong way.

Here is the code snippet I use to patch the initrd.img:
mkdir -p $(INITRD_DIR)
cd $(INITRD_DIR) ; xz --decompress --verbose < $(ROCKY9_SRC)/initrd.img | sudo cpio --extract --quiet --make-directories --no-absolute-filenames --unconditional --preserve-modification-time
cp $(KS_DIR)/*.ks $(INITRD_DIR)
cd $(INITRD_DIR) ; sudo find . | sudo cpio --create --quiet -H newc | xz --compress --format=lzma --verbose > $(ISOLINUX_DST)/initrd.img

What is the correct command to repack the initrd.img?

Kind regards,

I really don’t recommend modifying initrd as there are specific image and volume names as well as specific expectations during boot. Is there a reason you want to repack the initrd instead of adding the kickstart to the ISO itself?

You’re much better off including the kickstart on the ISO itself without changing the initrd yourself using mkksiso (part of the lorax package). See this for more info.

1 Like

Thanks for your answer!

I get your point and will give it a try…