定制安装光盘里面的initrd.img文件,以支持新驱动

To update the initrd.img to load additional drivers early in the boot process, normally you would simply run /sbin/mkinitrd and let the script do the work, and you can use the command line options --preload=module and --with=module to force it to load a certain module before or after the SCSI drivers respectively.

However, if you need to modify the initrd.img used during the installation of Red Hat Enterprise Linux (found in isolinux/initrd.img and images/pxeboot/initrd.img on the CD or DVD), it may be easier to modify the image by hand. Below are instructions to accomplish this.

As an example, let's use Red Hat Enterprise Linux 5.1 i386 and add the ide-cs.ko driver to the initrd.img to support PCMCIA devices during installation. (This was fixed in Red Hat Enterprise Linux 5.3.)

First, we need to get the ide-cs.ko module from the kernel package. Assuming the Red Hat Enterprise Linux 5.1 DVD is mounted on /mnt/cdrom, let's extract the files from the kernel RPM.

mkdir /tmp/2.6.18-53.el5
cd /tmp/2.6.18-53.el5
rpm2cpio /mnt/cdrom/Server/kernel-2.6.18-53.el5.i686.rpm | cpio -ivd
ls /tmp/2.6.18-53.el5/lib/modules/2.6.18-53.el5/kernel/drivers/ide/legacy/ide-cs.ko

Next we'll extract the initrd.img from the DVD. The initrd.img is a gzip'ed cpio archive.


mkdir /tmp/initrd
cd /tmp/initrd
gzip -dc /mnt/cdrom/isolinux/initrd.img | cpio -ivd

In the modules/ subdirectory, you'll see modules.cgz which is yet another gzip'ed cpio archive. Let's extract it next.


cd /tmp/initrd/modules
gzip -dc modules.cgz | cpio -ivd

Now we can copy the ide-cs.ko module from the kernel into our custom initrd.img. We also need to update the modules.alias file so Anaconda (the installation program for Red Hat Enterprise Linux) knows which hardware devices need the ide-cs.ko module. Some drivers may also need the module-info, modules.dep, and pci.ids files updated too. For more information on these files, see How do I manually update a Driver Update Disk?

cd /tmp/initrd/modules
cp /tmp/2.6.18-53.el5/lib/modules/2.6.18-53.el5/kernel/drivers/ide/legacy/ide-cs.ko 2.6.18-53.el5/i686/
modinfo -F alias 2.6.18-53.el5/i686/ide-cs.ko | sed -e 's/^/alias /' -e 's/$/ ide-cs/' >> modules.alias

Finally, we can package everything back up into our new custom initrd.img. Be careful when creating the cpio archives because the modules.cgz file uses the crc format whereas initrd.img uses the newc format! If you use the wrong format, the installation will not be able to read the initrd.img.


cd /tmp/initrd/modules
find 2.6.18-53.el5 | cpio -o -H crc | gzip -9 > modules.cgz
rm -fr 2.6.18-53.el5
cd ..
find . | cpio -o -H newc | gzip -9 > /tmp/initrd.img

Now copy your new /tmp/initrd.img onto your PXE boot server, or burn a new installation DVD with this replacement initrd.img.

你可能感兴趣的:(initrd,pxe的initrd修改)