Repairing the initial ramdisk (initrd)

Posted on 11:15 PM by Bharathvn

The initrd is a file located in /boot with a name like initrd.img-2.6.20-16-generic.
If your initrd becomes corrupted, or if you need to add new block device drivers to it, run the mkinitrd command. First, make sure you make a copy of your existing initrd file. Then run the following commands:

$ sudo apt-get install initrd-tools
$ sudo mkinitrd -o /boot/ initrd.img-2.6.20-16-generic

Replace the kernel version in the example above (2.6.20-1.2320.fc5) with your own kernel
version. Alternatively, to use the currently running kernel version, you can use:

$ sudo mkinitrd -o /boot/initrd.img-`uname –r` `uname –r`

Unfortunately, you will often realize that you need to rebuild your initrd after it is too late, as you witness a kernel panic during the root file system mount stage of boot. When that occurs, boot into rescue mode as described in the previous section and run mkinitrd after chrooting to the proper hard disk partition.