Linux rebuild the initial ramdisk image

by on April 19, 2006 · 4 comments· LAST UPDATED September 7, 2007

in , ,

Q: I think I am missing some driver or my initial ramdisk is corrupted for running kernel how do I Rebuild the initial ramdisk image under Linux?

A: You need ramdisk if you have added new hardware devices such as SCSI or FibreChannel controller to your server as the ramdisk contains the necessary modules (i.e. drivers) to initialize hardware driver. If you modified the /etc/modprob.conf (or modules.conf) file then you need to execute special script called mkinitrd.

The mkinitrd script constructs a directory structure that can serve as an initrd root file system. It then generates an image containing that directory structure using mkcramfs, which can be loaded using the initrd mechanism. The kernel modules for the specified kernel version will be placed in the directory structure. If version is omitted, it defaults to the version of the kernel that is currently running.

Find out your kernel version:
# uname -r
2.6.15.4
Make backup of existing ram disk:
# cp /boot/initrd.$(uname -r).img /root
To create initial ramdisk image type following command as the root user:
# mkinitrd -o /boot/initrd.$(uname -r).img $(uname -r)
# ls -l /boot/initrd.$(uname -r).img

You may need to modify grub.conf to point out to correct ramdisk image, make sure following line existing in grub.conf file:
initrd /boot/initrd.img-2.6.15.4.img
When the system boots using an initrd image created by mkinitrd command, the linuxrc will wait for an amount of time which is configured through mkinitrd.conf, during which it may be interrupted by pressing ENTER. After that, the modules specified in will be loaded.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Goldschmidt Arnon October 21, 2006 at 7:32 pm

Thanks for the explanation.
I didnt understand if I can copy initrd from vertion 2.6.9 to 2.4.27?
In general, is it vertion depended? is it a MUST?

Arnon

Reply

2 nixCraft October 23, 2006 at 9:46 pm

> In general, is it vertion depended? is it a MUST?

Yes, it is version dependent. You cannot use 2.4.xx with 2.6.xx or vice versa.

Reply

3 Gaurav August 16, 2010 at 9:47 am

I am also having the same problem but my PC not booting at all. How do I insert these commands? I am using “linux mint Gloria 7″. I tried reinstalling it but it didn’t work.

Reply

4 Praveen November 11, 2014 at 10:36 am

Kernel was updated and kernel panic, root file system was not mounting.
Made a copy of ram disk.
mkinitrd –force-lvm-probe /boot/initrd-2.6.18-92.el5.img 2.6.18-92.el5
solved.Thanks

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: