In this howto I will describe how to edit initrd.img from iso file to add new drivers in RHEL 6.x. We face an issue to add 40G t4_tom chelsio card driver inside initrd.img to start kickstart installation from Network. The initrd.img comes with RHEL 6.x ISO doesn’t contain this driver and hence we were unable to start kickstart installation from network. Chelsio provided DriverDisk but it doesn’t work because it require to provide it using any dvd or usb drive, which is impossible if you installing large number of nodes and away from your DataCenter. This method can work for any add/edit initrd.img file. For my work I used RHEL 6.5. Before doing it you should have one server running with RHEL 6.5 and updated driver.

1. Get Initrd.img from ISO

mkdir /mnt/{image,work}
mount -o loop RHEL6.5-server.x86_64.iso /mnt/image/
cp /mnt/image/isolinux/initrd.img /mnt/work

 2. Extract Initrd.img

Before extract rename initrd.img to initrd.img.xz because its compressed with xz and will remove its extension and rename again with initrd.img

cd /mnt/work
mkdir initrd-new
mv initrd.img initrd.img.xz
xz --format=lzma initrd.img.xz –decompress
cd initrd-new
cpio -ivdum < ../initrd.img

 3. Copy Required Driver

I will used already installed chelsio driver from chelsio script. We were using same directory tree,

cp  /lib/modules/2.6.32.431.el6.x86_64/updates/drivers/ /mnt/work/initrd-new/modules/2.6.32.431.el6.x86_64/updates/

 4. Update driver information from modules.* to initrd.img modules.* files.

I will used chelsio driver information here and it can be different for you. You need to confirm which hardware driver you will used to insert in initrd.img and its information from modules.* files.

cd /lib/modules/2.6.32.431.el6.x86_64/
egrep 'cxgb4|toecore|t4_tom' modules.symbols &nbsp;>> /mnt/work/initrd-new/modules/2.6.32-431.el6.x86_64/modules.symbols
egrep 'cxgb4|toecore|t4_tom' modules.alias >> /mnt/work/initrd-new/modules/2.6.32-431.el6.x86_64/modules.alias
egrep 'cxgb4|toecore|t4_tom' modules.dep >> /mnt/work/initrd-new/modules/2.6.32-431.el6.x86_64/modules.dep

5. Generate modules.*.bin files inside initrd.img

This will recreate all modules.*.bin files using required driver information using modules.* files. This required because without this initrd.img will unable to load newly inserted driver.

chroot /mnt/work/initrd-new
depmod -a -v
exit

 6. Generate updated Initrd.img

cd /mnt/work/initrd-new
find . -print |cpio -o -H newc | xz --format=lzma > ../initrd.img

Your initrd.img is ready and you can used this new initrd.img to replaced stock initrd.img to start kickstart installation or network boot.

If you have any question please use comments.

By Sohail Riaz

I am a First Red Hat Certified Architect - RHCA (ID # 110-082-666) from Pakistan with over 14 years industry experience in several disciplines including LINUX/UNIX System Administration, Virtualization, Network, Storage, Load Balances, HA Clusters and High Performance Computing.

2 thoughts on “HowTo Edit Initrd.img in RHEL/CentOS 6.x”
  1. I am getting the below reply while I pass the parameter –decompress. Can anyone help me on this?

    [root@localhost work]# xz –format=lzma initrd.img.xz –-decompress
    xz: –-decompress: No such file or directory
    [root@localhost work]#

Leave a Reply

Your email address will not be published. Required fields are marked *