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

**URL:** <https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656>\
**Category:** Infrastructure\
**Created:** [October 26, 2022, 2:46pm UTC](https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656 "2022-10-26T14:46:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Lars](https://forums.rockylinux.org/u/Lars)\
**Post date:** [October 26, 2022, 2:46pm UTC](https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656/1 "2022-10-26T14:46:09Z")

</div>

Hi,

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,  
Lars

---

<div class="post-metadata">

**Author:** ![label](https://avatars.discourse-cdn.com/v4/letter/l/c5a1d2/32.png) [@label](https://forums.rockylinux.org/u/label)\
**Post date:** [October 26, 2022, 5:10pm UTC](https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656/2 "2022-10-26T17:10:37Z")

</div>

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](https://weldr.io/lorax/mkksiso.html) for more info.

---

<div class="post-metadata">

**Author:** ![Lars](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Lars](https://forums.rockylinux.org/u/Lars)\
**Post date:** [October 27, 2022, 10:59am UTC](https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656/3 "2022-10-27T10:59:23Z")

</div>

Thanks for your answer!

I get your point and will give it a try…

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 3:36am UTC](https://forums.rockylinux.org/t/how-to-correctly-repack-initrd-img-from-rocky-9-iso-image/7656/4 "2023-08-25T03:36:23Z")

</div>

Closed on August 25, 2023, 3:36am UTC


