Adding storage, network and 3rd party kernel modules to a Linux initrd image

While playing around with initrd images a few weeks back, I came across the mkinitrd “–with” option. This option allows you to add additional modules to an initrd image, which is useful when you have a new storage or Ethernet driver that isn’t supported by the base operating system. To use this option, you can place the names of the modules to add to the initrd image in quotes, and pass them to the “–with” option:

$ mkinitrd -v –with=”aoe virtio” /tmp/initrd/initrd-2.6.29.6-213.fc11.x86_64.img 2.6.29.6-213.fc11.x86_64

To verify the image contains the modules you specified, you can extract the initrd image and poke around the lib/modules directory:

$ gunzip < initrd-2.6.29.6-213.fc11.x86_64.img | cpio -i

$ cd lib/modules/

$ find . -name \*aoe\*
./2.6.29.6-213.fc11.x86_64/aoe.ko

$ find . -name \*virtio\*
./2.6.29.6-213.fc11.x86_64/virtio.ko

If you want the modules included in all future mkinitrd runs, you can add the modules to the modules variable in the/etc/sysconfig/initrd file. Nice!

Leave a Reply

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