Basically when you update your kernel whether or not compiled by yourself, related init-ramdisk copied to the boot directory as well.
This init-ramdisk built at the end of the stage in kernel building. This ramdisk includes several modules which is necessary during the boot processing.
Sometimes, a user wants to include several customized modules into the init-ramdisk, so do work at the initial stage. There are several ways to include modules into the init-ramdisk.
One of easiest way is, during the making stage, provides option parameter with the module name as shown following command.
mkinitrd –preload=ext4 /boot/initrd-`uname -r`.img `uname -r`
This is easy method but sometimes we also want to tune some parameters and steps before and after loading modules into the kernel. In that case, you should dig into the ramdisk itself.
Following is the steps you need to watch and edit init-ramdisk.
mkinitrd initrd-`uname -r`.img `uname -r`
gunzip -c ../initrd-`uname -r`.img | cpio -idv
You can see several directories and files. At the root directory of the ramdisk image, you will see the ‘init’ file. This file will be executed during the boot process and load some modules into the kernel.
If you want to add some modules or modify behavior of this ramdisk, you are only necessary to modify this ‘init’ file.
Following diff file shows example of modified ‘init’. In there, I specified to download the ram-based root filesystem and mount it into the ramdisk.
— init.old 2008-09-17 10:44:30.000000000 +0900
+++ init 2008-09-17 10:45:54.000000000 +0900
@@ -83,7 +83,8 @@
lvm vgchange -ay –ignorelockingfailure VolGroup00
echo Creating root device.
-mkrootdev -t ext3 -o defaults,ro /dev/VolGroup00/LogVol00
+mount -t tmpfs /dev/shm /sysroot
echo Mounting root filesystem.
echo Setting up other filesystems.
If you finished all your necessary steps into this ramdisk directory, it is time to pack this again as a init-ramdisk image file as shown following block.
find . | cpio –quiet -c -o > ../initrd-new-`uname -r`.img && gzip ../initrd-new-`uname -r`.img
The final step is, of course, move this ramdisk image into the /boot directory and modify ‘grub.conf’ or ‘lilo.conf’ to specify ‘initrd=’ parameter. That is all!!! Now it’s time reboot the machine.