Altering Linux initrd images

Linux initrd allows the Linux kernel to stage boots: first a minimal kernel, then the initrd image, and finally the real file system. The initrd image is an ext2 file system that contains kernel modules and supporting files. To add new kernel modules or remove problematic drivers, the initrd image must be modified. The initrd-util utility helps modify initrd images. The utility has only been tested on RedHat and Fedora initrd images, though should work with any initrd image.

Newer initrd images may use cpio(1) archives instead of filesystem images. initrd-util has not yet been updated to support these newer image types.

The following notes illustrate removal of the e100 module from a RedHat 9 initrd image. Removal of a module may be needed if there is a conflict with a new module, or the module causes a problem with an automated install system being used to produce consistent host installations.

  1. Locate the pxeboot/initrd.img file.
  2. A Preboot Execution Environment (PXE) initrd image may be included with the installation files, or already installed under a Trivial File Transfer Protocol (TFTP) directory such as /tftpboot.

  3. Unpack the initrd.img file.
  4. The following assumes that the initrd image has been saved under the /tftpboot/redhat/9/x86 directory. The initrd-util script will run as root as needed via sudo.

    $ initrd-util unpack /tftpboot/redhat/9/x86/initrd.img

  5. Remove the eth0 module.
  6. Change to the temporary directory printed by initrd-util, and evict the e100 driver and any mention of it from the supporting metadata files, such as modules/module-info and modules/pcitable.

    Different versions of Linux may handle the modules.cgz bundle differently. RedHat 9 uses a 2.4.20-8BOOT kernel version in the initrd images. The initrd-util utility should have extracted the modules/modules.cgz file automatically if found.

    # cd /var/tmp/initrd-util.work.*
    # rm ./2.4.20-8BOOT/e100.o
    # find 2.4.20-8BOOT | cpio -ov -H crc | gzip -c9 > modules/modules.cgz
    # perl -i -ne 'print unless /"e100"/' modules/pcitable

    Also, remove the e100 data from modules/module-info. There should be a three line section to eliminate.

    # vi modules/module-info +/e100

  7. Package the new image.
  8. The following command should create a gzipped initrd file somewhere under /var/tmp.

    $ initrd-util pack /var/tmp/initrd-util.work.*

  9. Install the new initrd image.
  10. The new image file will need to be copied under /tftpboot, and the appropriate PXE configuration updated to reference it as the initrd kernel argument.

  11. Cleanup any scratch files.
  12. $ sudo rm -rf /var/tmp/initrd-util.*