Rebuilding Initrd After Hardware Change
If you make a significant enough change to your Linux machine's hardware, you may find yourself unable to boot up.
Symptoms
What works:
- BIOS boots
- Boot loader (GRUB) boots to target
- Live CDs, Rescue Disks all function normally
What doesn't work:
Target kernel does not, complaining about being unable to several mount points such as VolGroup00
Simple explanation of problem
When a kernel is installed, a collections of modules is package into a single image file referred to as initrd (this isn't technically accurate). When it does that, it only includes the modules necessary for your system, specifically to boot your system -- I assume this is as a matter of efficiency. So post change, something requires a different module, not included in the image when it was installed. As a result, you cannot boot.
How can this happen?
The most likely cause of this problem seems to be changes to secondary storage (eg. hard drive) controllers. In my case it happened when I changed a BIOS parameter to enable SATA controllers on a laptop.
What you will need to fix it
All you really need is some rescue media for your Linux distribution of choice, in my case, Fedora. I decided to use a LiveCD (specifically the F9 KDE Live CD, but that isn't relevant).
How to fix
Boot the rescue media, in my case, a Fedora 9 LiveCD. If the problem is the one described here, you should boot to the LiveCD just fine.
Open a terminal (once booted) and become root:
su -
Execute the following commands, except for the '#' symbol and everything after it on a line:
mkdir /mnt/sysimage # create directory for your system mount /dev/VolGroup00/LogGroup00 /mnt/sysimage # mount your root partition mount /dev/sda0 /mnt/sysimage/boot # mount your boot partition mount --bind /proc /mnt/sysimage/proc # mount the virtual directory 'proc' mount --bind /sys /mnt/sysimage/sys # mount the virtual directory 'sys' chroot /mnt/sysimage
The above serves to get things ready. You need to make appropriate modifications (if at all) to the 2nd and 3rd commands to point them to the appropriate partitions. In my case, the root partition (/) was in LVM at /dev/VolGroup00/LogGroup00 and my boot partition (/boot) was on the first partition of the first drive at /dev/sda0.
Now its time to actually fix things. But before we do you may want to make copies of all the files listed by the following command (the initrd image files) as we will be overwriting them:
ls /boot/*.img
Now for the command that actually regenerates the module collection image, initrd:
mkinitrd -v -f /boot/initrd-2.6.25.14-108.fc9.img
Examine the output of the command -- just by looking at the text, and quantity of the text, you should be able to determine if it did anything meaningful.
You need to do this for at least the kernel that you normally boot to, but optionally the kernels you have installed. To do this, you need to provide the appropriate kernel version as part of the file name -- I did this for the 2.6.25.14-108.fc9.i686 kernel.
If all is well, you should be able to reboot, and boot successfully into your system.
If you have any comments or suggestions, you can reach via email: arthurpemberton at umkc dot edu
