<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vzuser</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vzuser"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Vzuser"/>
	<updated>2026-04-11T09:26:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Modifying_initrd_image&amp;diff=1911</id>
		<title>Modifying initrd image</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Modifying_initrd_image&amp;diff=1911"/>
		<updated>2006-07-27T20:10:43Z</updated>

		<summary type="html">&lt;p&gt;Vzuser: added cpio option &amp;quot;-H newc&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The frequent reason why your kernel can't boot is not properly created initrd image.&lt;br /&gt;
Here is a small description of what you can do if you encounter a similar problem.&lt;br /&gt;
&lt;br /&gt;
==What is initrd image==&lt;br /&gt;
Your boot loader usually supports &amp;lt;code&amp;gt;initrd&amp;lt;/code&amp;gt; instruction.&lt;br /&gt;
For example, in GRUB:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OpenVZ (2.6.8-022stab077)&lt;br /&gt;
        root (hd0,0)&lt;br /&gt;
        kernel /vmlinuz-2.6.8-022stab077 ro root=LABEL=/ console=tty0&lt;br /&gt;
        initrd /initrd-2.6.8-022stab077.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
GRUB loads initrd-2.6.8-022stab077.img file at a certain address in memory.&lt;br /&gt;
When kernel boots, it checks for initrd image, and if it exists starts &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt;&lt;br /&gt;
script that resides on this image.&lt;br /&gt;
&amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script is usually written in nash (a sort of bash-like shell, just smaller).&lt;br /&gt;
When &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script on initrd image is finished, kernel usually calls standard System V &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt;&lt;br /&gt;
process (/sbin/init, etc.)&lt;br /&gt;
&lt;br /&gt;
==Why initrd image is necessary==&lt;br /&gt;
Suppose your root partion resides on some SCSI device and driver for this SCSI devices is compiled as a&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Additionally after udev subsystem become common, somebody has to start udev to create device nodes. This is initrd's duty too.&lt;br /&gt;
&lt;br /&gt;
==Typical problem==&lt;br /&gt;
Consider a real problem. After booting the kernel we get the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
Creating root device&lt;br /&gt;
mkrootdev: label / not found&lt;br /&gt;
Mounting root filesystem&lt;br /&gt;
mount: error 2 mounting ext3&lt;br /&gt;
mount: error 2 mounting none&lt;br /&gt;
Switching to new root&lt;br /&gt;
switchroot: mount failed: 22&lt;br /&gt;
umount /initrd/dev failed: 2&lt;br /&gt;
Kernel panic - not sysncing: Attempted to kill init!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can appear if there is no module loaded for device, where root partion resides.&lt;br /&gt;
To solve the problem, extract the initrd image.&lt;br /&gt;
&lt;br /&gt;
==Extracting initrd image==&lt;br /&gt;
Initrd image is just cpio-gzip archive. So to extract it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir initrd&lt;br /&gt;
$ cd initrd&lt;br /&gt;
$ gzip -dc /boot/initrd-2.6.16-026test014.4-smp.cpio | cpio -id&lt;br /&gt;
$ ls -1&lt;br /&gt;
bin&lt;br /&gt;
dev&lt;br /&gt;
etc&lt;br /&gt;
init&lt;br /&gt;
initrd-2.6.16-026test014.4-smp.cpio&lt;br /&gt;
lib&lt;br /&gt;
loopfs&lt;br /&gt;
proc&lt;br /&gt;
sbin&lt;br /&gt;
sys&lt;br /&gt;
sysroot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Analyzing init script==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat init&lt;br /&gt;
#!/bin/nash&lt;br /&gt;
&lt;br /&gt;
mount -t proc /proc /proc&lt;br /&gt;
setquiet&lt;br /&gt;
echo Mounted /proc filesystem&lt;br /&gt;
echo Mounting sysfs&lt;br /&gt;
mount -t sysfs none /sys&lt;br /&gt;
echo Creating /dev&lt;br /&gt;
mount -o mode=0755 -t tmpfs none /dev&lt;br /&gt;
mknod /dev/console c 5 1&lt;br /&gt;
mknod /dev/null c 1 3&lt;br /&gt;
mknod /dev/zero c 1 5&lt;br /&gt;
mkdir /dev/pts&lt;br /&gt;
mkdir /dev/shm&lt;br /&gt;
echo Starting udev&lt;br /&gt;
/sbin/udevstart&lt;br /&gt;
echo -n &amp;quot;/sbin/hotplug&amp;quot; &amp;gt; /proc/sys/kernel/hotplug&lt;br /&gt;
echo &amp;quot;Loading mptbase.ko module&amp;quot;&lt;br /&gt;
insmod /lib/mptbase.ko&lt;br /&gt;
echo &amp;quot;Loading mptscsih.ko module&amp;quot;&lt;br /&gt;
insmod /lib/mptscsih.ko&lt;br /&gt;
/sbin/udevstart&lt;br /&gt;
echo Creating root device&lt;br /&gt;
mkrootdev /dev/root&lt;br /&gt;
umount /sys&lt;br /&gt;
echo Mounting root filesystem&lt;br /&gt;
mount -o defaults --ro -t ext3 /dev/root /sysroot&lt;br /&gt;
mount -t tmpfs --bind /dev /sysroot/dev&lt;br /&gt;
echo Switching to new root&lt;br /&gt;
switchroot /sysroot&lt;br /&gt;
umount /initrd/dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that init tries to load modules &amp;lt;code&amp;gt;mptbase.ko&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mptscsih.ko&amp;lt;/code&amp;gt;.&lt;br /&gt;
Check for presense of these modules on initrd image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ls -1 ./lib/&lt;br /&gt;
mptbase.ko&lt;br /&gt;
mptscsih.ko&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So they are here... But on the [[Hardware Node|node]] in question there is a device supported by driver in another module:&lt;br /&gt;
&amp;lt;code&amp;gt;mptspi.ko&amp;lt;/code&amp;gt;! After adding it to the image and into init script everything should work.&lt;br /&gt;
&lt;br /&gt;
==Creating initrd==&lt;br /&gt;
We just have to cpio and gzip directory cpio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ find ./ | cpio -H newc -o &amp;gt; /boot/new-initrd.cpio&lt;br /&gt;
1354 blocks&lt;br /&gt;
$ cd /boot&lt;br /&gt;
$ gzip new-initrd.cpio&lt;br /&gt;
$ mv new-initrd.cpio.gz new-initrd.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, try to boot your kernel with newly created initrd image.&lt;br /&gt;
&lt;br /&gt;
==Who create initrd by default?==&lt;br /&gt;
Usually there is an &amp;lt;code&amp;gt;mkdinitrd&amp;lt;/code&amp;gt; package installed, that allows to create&lt;br /&gt;
initrd image. You can use this program, it has a lot of options. OpenVZ kernel RPM-package (and “make install” target too) uses this&lt;br /&gt;
program to create an initial (default) initrd image.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vzuser</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Modifying_initrd_image&amp;diff=1910</id>
		<title>Modifying initrd image</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Modifying_initrd_image&amp;diff=1910"/>
		<updated>2006-07-27T20:05:27Z</updated>

		<summary type="html">&lt;p&gt;Vzuser: changed mtpspi.ko to mptspi.ko&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The frequent reason why your kernel can't boot is not properly created initrd image.&lt;br /&gt;
Here is a small description of what you can do if you encounter a similar problem.&lt;br /&gt;
&lt;br /&gt;
==What is initrd image==&lt;br /&gt;
Your boot loader usually supports &amp;lt;code&amp;gt;initrd&amp;lt;/code&amp;gt; instruction.&lt;br /&gt;
For example, in GRUB:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OpenVZ (2.6.8-022stab077)&lt;br /&gt;
        root (hd0,0)&lt;br /&gt;
        kernel /vmlinuz-2.6.8-022stab077 ro root=LABEL=/ console=tty0&lt;br /&gt;
        initrd /initrd-2.6.8-022stab077.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
GRUB loads initrd-2.6.8-022stab077.img file at a certain address in memory.&lt;br /&gt;
When kernel boots, it checks for initrd image, and if it exists starts &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt;&lt;br /&gt;
script that resides on this image.&lt;br /&gt;
&amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script is usually written in nash (a sort of bash-like shell, just smaller).&lt;br /&gt;
When &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt; script on initrd image is finished, kernel usually calls standard System V &amp;lt;tt&amp;gt;init&amp;lt;/tt&amp;gt;&lt;br /&gt;
process (/sbin/init, etc.)&lt;br /&gt;
&lt;br /&gt;
==Why initrd image is necessary==&lt;br /&gt;
Suppose your root partion resides on some SCSI device and driver for this SCSI devices is compiled as a&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Additionally after udev subsystem become common, somebody has to start udev to create device nodes. This is initrd's duty too.&lt;br /&gt;
&lt;br /&gt;
==Typical problem==&lt;br /&gt;
Consider a real problem. After booting the kernel we get the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
Creating root device&lt;br /&gt;
mkrootdev: label / not found&lt;br /&gt;
Mounting root filesystem&lt;br /&gt;
mount: error 2 mounting ext3&lt;br /&gt;
mount: error 2 mounting none&lt;br /&gt;
Switching to new root&lt;br /&gt;
switchroot: mount failed: 22&lt;br /&gt;
umount /initrd/dev failed: 2&lt;br /&gt;
Kernel panic - not sysncing: Attempted to kill init!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can appear if there is no module loaded for device, where root partion resides.&lt;br /&gt;
To solve the problem, extract the initrd image.&lt;br /&gt;
&lt;br /&gt;
==Extracting initrd image==&lt;br /&gt;
Initrd image is just cpio-gzip archive. So to extract it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mkdir initrd&lt;br /&gt;
$ cd initrd&lt;br /&gt;
$ gzip -dc /boot/initrd-2.6.16-026test014.4-smp.cpio | cpio -id&lt;br /&gt;
$ ls -1&lt;br /&gt;
bin&lt;br /&gt;
dev&lt;br /&gt;
etc&lt;br /&gt;
init&lt;br /&gt;
initrd-2.6.16-026test014.4-smp.cpio&lt;br /&gt;
lib&lt;br /&gt;
loopfs&lt;br /&gt;
proc&lt;br /&gt;
sbin&lt;br /&gt;
sys&lt;br /&gt;
sysroot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Analyzing init script==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat init&lt;br /&gt;
#!/bin/nash&lt;br /&gt;
&lt;br /&gt;
mount -t proc /proc /proc&lt;br /&gt;
setquiet&lt;br /&gt;
echo Mounted /proc filesystem&lt;br /&gt;
echo Mounting sysfs&lt;br /&gt;
mount -t sysfs none /sys&lt;br /&gt;
echo Creating /dev&lt;br /&gt;
mount -o mode=0755 -t tmpfs none /dev&lt;br /&gt;
mknod /dev/console c 5 1&lt;br /&gt;
mknod /dev/null c 1 3&lt;br /&gt;
mknod /dev/zero c 1 5&lt;br /&gt;
mkdir /dev/pts&lt;br /&gt;
mkdir /dev/shm&lt;br /&gt;
echo Starting udev&lt;br /&gt;
/sbin/udevstart&lt;br /&gt;
echo -n &amp;quot;/sbin/hotplug&amp;quot; &amp;gt; /proc/sys/kernel/hotplug&lt;br /&gt;
echo &amp;quot;Loading mptbase.ko module&amp;quot;&lt;br /&gt;
insmod /lib/mptbase.ko&lt;br /&gt;
echo &amp;quot;Loading mptscsih.ko module&amp;quot;&lt;br /&gt;
insmod /lib/mptscsih.ko&lt;br /&gt;
/sbin/udevstart&lt;br /&gt;
echo Creating root device&lt;br /&gt;
mkrootdev /dev/root&lt;br /&gt;
umount /sys&lt;br /&gt;
echo Mounting root filesystem&lt;br /&gt;
mount -o defaults --ro -t ext3 /dev/root /sysroot&lt;br /&gt;
mount -t tmpfs --bind /dev /sysroot/dev&lt;br /&gt;
echo Switching to new root&lt;br /&gt;
switchroot /sysroot&lt;br /&gt;
umount /initrd/dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that init tries to load modules &amp;lt;code&amp;gt;mptbase.ko&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mptscsih.ko&amp;lt;/code&amp;gt;.&lt;br /&gt;
Check for presense of these modules on initrd image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ls -1 ./lib/&lt;br /&gt;
mptbase.ko&lt;br /&gt;
mptscsih.ko&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So they are here... But on the [[Hardware Node|node]] in question there is a device supported by driver in another module:&lt;br /&gt;
&amp;lt;code&amp;gt;mptspi.ko&amp;lt;/code&amp;gt;! After adding it to the image and into init script everything should work.&lt;br /&gt;
&lt;br /&gt;
==Creating initrd==&lt;br /&gt;
We just have to cpio and gzip directory cpio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ find ./ | cpio -o &amp;gt; /boot/new-initrd.cpio&lt;br /&gt;
1354 blocks&lt;br /&gt;
$ cd /boot&lt;br /&gt;
$ gzip new-initrd.cpio&lt;br /&gt;
$ mv new-initrd.cpio.gz new-initrd.img&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, try to boot your kernel with newly created initrd image.&lt;br /&gt;
&lt;br /&gt;
==Who create initrd by default?==&lt;br /&gt;
Usually there is an &amp;lt;code&amp;gt;mkdinitrd&amp;lt;/code&amp;gt; package installed, that allows to create&lt;br /&gt;
initrd image. You can use this program, it has a lot of options. OpenVZ kernel RPM-package (and “make install” target too) uses this&lt;br /&gt;
program to create an initial (default) initrd image.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vzuser</name></author>
		
	</entry>
</feed>