Update initrd with mkinitrd to install new (different) hardware on Linux

I’m not sure if this important topic is discussed thoroughly in manuals because I couldn’t find any easily on Google without the exact keywords. I could be wrong though, but I’m documenting it here for my own note.

Many people do not dare to adopt Linux due to its complexity. I have to agree that Linux is far from being user friendly despite a lot of people’s effort to make it one. Simple task such as changing/replacing hardware is very common, especially now with the rapid development of technological advances. Few weeks ago I had to change one of my servers’ motherboard with a new one to accommodate a new multi-core CPU and I had to keep everything (OS and data) on the hard drive intact. Once the new motherboard was in place, it wouldn’t boot because it couldn’t read from my hard drive. Typical error where it says root partition cannot be found. Initially, I didn’t know an incorrect initrd could cause this problem because the error messages (which leads to kernel panic) didn’t mention anything specific other than not being able to read the partition table and find /. I almost put my blame instantly on LVM. Fortunately with some dedications searching through Google, I was able to find the right solution.

Linux uses initrd to keep a handful of modules it requires for booting to take place properly. If you compile every driver you need into the kernel, then initrd is not required but including everything in the kernel is inefficient and defeats the purpose of modular design. Important modules such as ext3, PATA/SATA controller, LVM, need to be placed inside the initrd. How can a boot loader (in most cases GRUB or LILO) be able to load LVM partitions if the modules required to read LVM partitions are inside the LVM partition?

To “repair” my new system, I had to boot using a rescue CD, modify /etc/modprobe.conf to include the new motherboard’s SATA controller. This new motherboard’s PATA controller is different from the old motherboard and therefore requires a different driver. I replaced “alias scsi_hostadapter2 pata_amd” to “alias scsi_hostadapter2 libata” in modprobe.conf. Basically these are the steps:

chroot /mnt/sysimage
vi /etc/modprobe.conf
(make needed changes as required)
depmod -ae -F /boot/System.map-2.6.9-1.667 2.6.9-1.667
mkinitrd -v -f /boot/initrd-2.6.9-1.667.img 2.6.9-1.667

Once everything ran as expected, remove the rescue CD, and reboot. The system should boot properly now. If it doesn’t, most likely the module name specified in modprobe.conf is incorrect.

Here is a tip to find out which PATA/SATA module you should include in modprobe.conf:
When booting the rescue CD, right after the blue screen appears it will pop up a dialog. Find the module name that is required in that dialog. Be sure to keep an eye on it because it will disappear quickly.

BTW, this article is also useful when moving an installed Linux hard drive to a different computer with different hardware.

Good luck! Let me know if this article helps you by posting a comment. Thanks!

References:
http://www.keffective.com/mvsata/
http://en.wikipedia.org/wiki/Initrd

2 thoughts on “Update initrd with mkinitrd to install new (different) hardware on Linux

  1. Hi, I run into what I think is the same problem, however my googling came up with only using absolute device reference in grub.cfg, so this article give me a different point of view, thx.. if only you I could share this on facebook will make things even better..

Leave a Reply

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

Anti-Spam by WP-SpamShield

areosystyle-knowledgeless