Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Modifying initrd image

104 bytes removed, 20:35, 28 June 2006
small fixes here and there
The very often 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.
==What is initrd image==
Your boot loader ussually usually supports <ttcode>initrd</ttcode> instruction.For example , in GRUB:
<pre>
OpenVZ (2.6.8-022stab077)
</pre>
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 <tt>init</tt>script, that resides on this image.<tt>init</tt> script is usually is written on in nash (something a sort of bash-like bashshell, but poorerjust smaller).When <tt>init</tt> scipt script on initrd image is finished , kernel as usually calls system standard System V <tt>init</tt>
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 in someas akernel module. Of course this module is required at boot time to have access to the root partion— but it is not in the kernel. Somebody has to load thismodule, and it does Thus the need for an initrd image!. Additionally after appearing udev subsystembecome common, somebody have has to start udev to create device nodes. This is initrd's duty too.
==Typical problem==
</pre>
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:
<pre>
$ mkdir cpio$ cp initrd-2.6.16-026test014.4-smp.img cpio/initrd-2.6.16-026test014.4-smp.cpio.gz$ cd cpioinitrd$ gunzip gzip -dc /boot/initrd-2.6.16-026test014.4-smp.cpio.gz$ | cpio -i < initrd-2.6.16-026test014.4-smp.cpioid
$ ls -1
bin
</pre>
We can see, that init tryies tries to load modules <code>mptbase.ko </code> and <code>mptscsih.ko</code>.
Check for presense of these modules on initrd image:
<pre>
</pre>
So they arehere... But on the [[Hardware Node|node ] in question there is a device, that is supported by driver in another module:<ttcode>mtpspi.ko</ttcode>! After adding it to the image an in and into init script everything must should work.
==Creating initrd==
We just have to cpio and gzip directory cpio:
<pre>
$ lsbin etc initrd-2.6.16-026test014.4-smp.cpio loopfs sbin sysrootdev init lib proc sys$ rm initrd-2.6.16-026test014.4-smp.cpio$ find ./ | cpio -o > ../boot/new-initrd.img
1354 blocks
</pre>
Next, try to boot your kernel with newly created initrd image, ==Who create mkinitrd initrd by default?==In each modern distribution Usually there is an <ttcode>mkdinitrd</ttcode> packetpackage installed, that allows to createinitrd image. You can use this program, it has a lot of options. OpenVZ kernel RPM-package (and "make install" “make install” target too) uses thisprogram to create an initial (default) initrd image.
[[Category: HOWTO]]
[[Category: Troubleshooting]]