How do I edit the initrd.img in the RHEL 5.1 boot disk?
I am trying to make a RHEL 5.1 installer that runs from a USB flash drive. I would like to place a kickstart file in the install system's root directory, so that I may use it with ks=file:/ks.cfg. I understand that I must modify the contents of the initrd.img located in the <RHEL 5.1 CD>/images/diskboot.img.
I found a few websites that say initrd.img is a gzipped ext2 filesystem. They give the following procedure for opening initrd.img:
# gzip -dc /mnt/boot/initrd.img >/tmp/initrd.ext2
# mkdir /mnt/initrd
# mount -o loop /tmp/initrd.ext2 /mnt/initrd
However, I have had no success with this. gzip does successfully decompress the file, but when I attempt to mount it, mount does not recognize the filesystem type. When I specify the filesystem type as ext2 with
# mount -t ext2 -o loop /tmp/initrd.ext2 /mnt/initrd
the output suggests that I may have a bad superblock. (Sorry, but I'm not able to reproduce the exact output at the moment.)
Can anyone please shed some light on my problem? Thank you very much.
You're partly correct. The initial ram disk image is a compressed file, but it is a compressed cpio archive. Try this command to see what is inside your initrd file.
Thanks for the help! That works like a charm.
Hi there, I am having the same problem.
Could you advise which command will extract the kickstart initrd.img
and then how we can mount it in rhel5.
I can view the files with cpio but I want to extract them so I can add new net driver modules.
If you extract the files from the initial ram disk file, you just have a bunch of files - not a mountable file-system. If you want to modify your current initial ram disk file by adding modules, use the mkinitrd command to build a new initrdxxx.img file.
Perhaps some more info about what you're doing might help us provide a better response for you :)
I was working on hacking rhel5 kickstart initrd to add new network drivers. I have completed this but for other users here's how:
gzip –dc initrd.img >initrd.x
cpio –id < initrd.x
This will extract all folders.
I extracted the modules.cgz & added new kernel module drivers.
Repackage using cpio & gzip.
Put it back into initrd/modules folder.
Modify modules/pci.ids with details of your new modules.
Then use mkisofs & create a kickstart CD
Here's the process I used. The important trick is specifying the "newc" cpio format.
gunzip < initrd.img > initrd.cpio
2. Append files.
ls myfile | cpio -oAO initrd.cpio -H newc
gzip -cz initrd.cpio > initrd.img
|All times are GMT -5. The time now is 09:14 PM.|