Initrd managing guide

Modifying initrd image

From OpenVZ Wiki

Jump to: navigation, search

The frequent reason why your kernel can’t boot is not properly created initrd image. Here is a small description of what you can do if you encounter a similar problem.

Contents

[hide]

What is initrd image

Your boot loader usually supports initrd instruction. For example, in GRUB:

GRUB loads initrd-2.6.8-022stab077.img file at a certain address in memory. When kernel boots, it checks for initrd image, and if it exists starts init script that resides on this image. init script is usually written in nash (a sort of bash-like shell, just smaller). When init script on initrd image is finished, kernel usually calls standard System V init process (/sbin/init, etc.)

Why initrd image is necessary

Suppose your root partion resides on some SCSI device and driver for this SCSI devices is compiled as a kernel module. Of course this module is required at boot time to have access to the root partion — but it is not in the kernel. Thus the need for an initrd image.

Additionally after udev subsystem become common, somebody has to start udev to create device nodes. This is initrd’s duty too.

Typical problem

Consider a real problem. After booting the kernel we get the following:

This can appear if there is no module loaded for device, where root partion resides. To solve the problem, extract the initrd image.

Extracting initrd image

Initrd image is just cpio-gzip archive. So to extract it:

Analyzing init script

We can see that init tries to load modules mptbase.ko and mptscsih.ko. Check for presense of these modules on initrd image:

So they are here… But on the node in question there is a device supported by driver in another module: mptspi.ko! After adding it to the image and into init script everything should work.

Creating initrd

We just have to cpio and gzip directory cpio:

Next, try to boot your kernel with newly created initrd image.

Who create initrd by default?

Usually there is an mkdinitrd package installed, that allows to create initrd image. You can use this program, it has a lot of options. OpenVZ kernel RPM-package (and “make install” target too) uses this program to create an initial (default) initrd image.

Author: stratus

Laisser un commentaire