<?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=Vass</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=Vass"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Vass"/>
	<updated>2026-06-14T03:01:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3694</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3694"/>
		<updated>2007-12-02T22:08:01Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Workaround */  formatting fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Problem #1 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Problem #2 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
* for 2.6.18 rhel5 based kernels: Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
* for 2.6.18 mainstream based kernels: Update till &amp;lt;tt&amp;gt;028stab043&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem #3 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE till &amp;lt;tt&amp;gt;2.6.18-028stab049&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;2.6.9-023stab044.14&amp;lt;/tt&amp;gt; kernels. This device is usually used for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
* for 2.6.18 based kernels: update till &amp;lt;tt&amp;gt;028stab049&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
* for 2.6.9 based kernels: update till &amp;lt;tt&amp;gt;023stab044.14&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3693</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3693"/>
		<updated>2007-12-02T22:06:02Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Reason */ formatting fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Problem #1 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Problem #2 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
* for 2.6.18 rhel5 based kernels: Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
* for 2.6.18 mainstream based kernels: Update till &amp;lt;tt&amp;gt;028stab043&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem #3 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE till &amp;lt;tt&amp;gt;2.6.18-028stab049&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;2.6.9-023stab044.14&amp;lt;/tt&amp;gt; kernels. This device is usually used for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Just use 2.6.18-028stab049 or 2.6.9-023stab044.14 (and later) OpenVZ kernels.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3692</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3692"/>
		<updated>2007-12-02T22:04:09Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Workaround */ TUN is now supported.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Problem #1 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Problem #2 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
* for 2.6.18 rhel5 based kernels: Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
* for 2.6.18 mainstream based kernels: Update till &amp;lt;tt&amp;gt;028stab043&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem #3 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE till 028stab049 kernel. This device is usually used &lt;br /&gt;
for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Just use 2.6.18-028stab049 or 2.6.9-023stab044.14 (and later) OpenVZ kernels.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3691</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3691"/>
		<updated>2007-12-02T22:02:22Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Reason */ TUN is supported now!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Problem #1 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Problem #2 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
* for 2.6.18 rhel5 based kernels: Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
* for 2.6.18 mainstream based kernels: Update till &amp;lt;tt&amp;gt;028stab043&amp;lt;/tt&amp;gt; or newer kernel&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problem #3 ==&lt;br /&gt;
===  Symptoms ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE till 028stab049 kernel. This device is usually used &lt;br /&gt;
for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
You should not use &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device in VE to migrate  it. If you're using VPN in VE, just stop VPN, then produce the online migration and after that start the VPN. Of course, all current connections to VPN will be lost :(.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=UBC_primary_parameters&amp;diff=3427</id>
		<title>UBC primary parameters</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=UBC_primary_parameters&amp;diff=3427"/>
		<updated>2007-09-05T02:30:30Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* vmguarpages */ x86_64 page size added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{UBC toc}}&lt;br /&gt;
&lt;br /&gt;
The most important parameters determining the resources available to&lt;br /&gt;
Virtual Environment are explained below. The meaning of the parameters&lt;br /&gt;
is illustrated assuming that the Virtual Environment runs some network&lt;br /&gt;
server applications.&lt;br /&gt;
&lt;br /&gt;
== numproc ==&lt;br /&gt;
Maximum number of processes and kernel-level threads allowed for this Virtual Environment.&lt;br /&gt;
&lt;br /&gt;
Many server applications (like Apache Web server, FTP and mail servers)&lt;br /&gt;
spawn a process to handle each client, so the limit on number of processes&lt;br /&gt;
defines how many clients the application will be able to handle in parallel.&lt;br /&gt;
However, the number of processes doesn't limit how “heavy” the application is&lt;br /&gt;
and whether the server will be able to serve heavy requests from clients.&lt;br /&gt;
&lt;br /&gt;
Configuring resource control system, it is important to estimate both&lt;br /&gt;
the maximum number of processes and the average number of processes&lt;br /&gt;
(referred to as avnumproc later). Other (dependent) resource&lt;br /&gt;
control parameters may depend both on the limit and the average number (see [[UBC consistency check]]).&lt;br /&gt;
&lt;br /&gt;
Barrier of numproc doesn't provide additional control and should be set equal to the limit.&lt;br /&gt;
&lt;br /&gt;
There is a restriction on the total number of processes in the system.&lt;br /&gt;
More than about 16000 processes start to cause poor responsiveness of&lt;br /&gt;
the system, worsening when the number grows. Total number of processes&lt;br /&gt;
exceeding 32000 is very likely to cause hang of the system.&lt;br /&gt;
&lt;br /&gt;
Note that in practice the number of processes is usually less. Each&lt;br /&gt;
process consumes some memory, and the available memory and the&lt;br /&gt;
&amp;quot;low memory&amp;quot; (see [[UBC systemwide configuration#“Low memory”|“Low memory”]]) limit the number of processes to lower&lt;br /&gt;
values. With typical processes, it is normal to be able to run only up&lt;br /&gt;
to 8000 processes in a system.&lt;br /&gt;
&lt;br /&gt;
== numtcpsock ==&lt;br /&gt;
Maximum number of TCP sockets.&lt;br /&gt;
&lt;br /&gt;
This parameter limits the&lt;br /&gt;
number of TCP connections and, thus, the number of clients the server&lt;br /&gt;
application can handle in parallel.&lt;br /&gt;
Barrier of this parameter should be set equal to the limit.&lt;br /&gt;
If each Virtual Environment has it's own set of IP addresses (which is&lt;br /&gt;
the only way a OpenVZ system can be configured), there are no direct&lt;br /&gt;
limits on the total number of TCP sockets in the system. The number&lt;br /&gt;
of sockes needs to be controlled because each socket needs certain&lt;br /&gt;
amount of memory for receive and transmit buffers (see descriptions&lt;br /&gt;
of [[&amp;lt;code&amp;gt;tcpsndbuf&amp;lt;/code&amp;gt;]] and [[&amp;lt;code&amp;gt;tcprcvbuf&amp;lt;/code&amp;gt;]]), and&lt;br /&gt;
the memory is a limited resource.&lt;br /&gt;
&lt;br /&gt;
== numothersock ==&lt;br /&gt;
Maximum number of non-TCP sockets (local sockets, UDP and other types of sockets).&lt;br /&gt;
&lt;br /&gt;
Local (UNIX-domain) sockets are used for communications inside the&lt;br /&gt;
system. Multi-tier applications (for example, a Web application with a&lt;br /&gt;
database server as a back-end) may need one or multiple local sockets&lt;br /&gt;
to serve each client. Straightforward applications (for example, most&lt;br /&gt;
mail servers, with the exception of Postfix) do not use local sockets.&lt;br /&gt;
&lt;br /&gt;
UDP sockets are used for Domain Name Service (DNS) queries, but&lt;br /&gt;
the number of such sockets opened simultaneously is low. UDP and&lt;br /&gt;
other sockets may also be used in some very special applications&lt;br /&gt;
(SNMP agents and others).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Barrier&amp;lt;/code&amp;gt; of this parameter should be set equal to the &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt;.&lt;br /&gt;
The number of local sockets in a system is not limited. The number of&lt;br /&gt;
UDP sockets in a system, similarly to TCP sockets, is not limited in&lt;br /&gt;
OpenVZ systems.&lt;br /&gt;
&lt;br /&gt;
Similarly to &amp;lt;code&amp;gt;numtcpsock&amp;lt;/code&amp;gt; parameter discussed above, the number of&lt;br /&gt;
non-TCP sockets needs to be controlled because each socket needs certain&lt;br /&gt;
amount of memory for its buffers, and the memory is a limited&lt;br /&gt;
resource.&lt;br /&gt;
&lt;br /&gt;
== vmguarpages ==&lt;br /&gt;
Memory allocation guarantee.&lt;br /&gt;
&lt;br /&gt;
This parameter controls how much memory is available to the Virtual&lt;br /&gt;
Environment (i.e. how much memory its applications can allocate by&lt;br /&gt;
&amp;lt;code&amp;gt;malloc(3)&amp;lt;/code&amp;gt; or other standard Linux memory allocation mechanisms).&lt;br /&gt;
The more clients are served or the more “heavy” the application is, the&lt;br /&gt;
more memory it needs.&lt;br /&gt;
&lt;br /&gt;
The amount of memory that Virtual Environment's applications are&lt;br /&gt;
guaranteed to be able to allocate is specified as the barrier of&lt;br /&gt;
&amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt; parameter. The current amount of allocated memory space&lt;br /&gt;
is accounted into &amp;lt;code&amp;gt;privvmpages&amp;lt;/code&amp;gt; parameter, and &amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt;&lt;br /&gt;
parameter does not have its own accounting. The barrier and the limit of&lt;br /&gt;
&amp;lt;code&amp;gt;privvmpages&amp;lt;/code&amp;gt; parameter impose an upper limit on the memory allocations&lt;br /&gt;
(see [[privvmpages]]). The meaning of the &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; for the&lt;br /&gt;
&amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt; parameter is unspecified in the current version and should be set&lt;br /&gt;
to the maximal allowed value ([[MAX_ULONG]]).&lt;br /&gt;
&lt;br /&gt;
If the current amount of allocated memory space does not exceed the&lt;br /&gt;
guaranteed amount (the &amp;lt;code&amp;gt;barrier&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt;),&lt;br /&gt;
memory allocations of Virtual Environment's applications always succeed.&lt;br /&gt;
If the current amount of allocated memory space exceeds the guarantee but below&lt;br /&gt;
the &amp;lt;code&amp;gt;barrier&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;privvmpages&amp;lt;/code&amp;gt;, allocations may or may not succeed,&lt;br /&gt;
depending on the total amount of available memory in the system.&lt;br /&gt;
&lt;br /&gt;
Starting from the &amp;lt;code&amp;gt;barrier&amp;lt;/code&amp;gt; of &amp;lt;code&amp;gt;privvmpages&amp;lt;/code&amp;gt;,&lt;br /&gt;
normal priority allocations and, starting from the &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt;&lt;br /&gt;
of &amp;lt;code&amp;gt;privvmpages&amp;lt;/code&amp;gt;, all memory allocations&lt;br /&gt;
made by the applications fail.&lt;br /&gt;
The memory allocation guarantee (&amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt;) is a primary tool for&lt;br /&gt;
controlling the memory available to Virtual Environments, because&lt;br /&gt;
it allows administrators to provide Service Level Agreements — agreements&lt;br /&gt;
guaranteeing certain quality of service, certain amount of resources&lt;br /&gt;
and general availability of the service. The unit of measurement&lt;br /&gt;
of vmguarpages values is memory pages (4KB on x86 and x86_64 processors).&lt;br /&gt;
The total memory allocation guarantees given to Virtual Environments&lt;br /&gt;
are limited by the physical resources of the computer — the size of RAM&lt;br /&gt;
and the swap space — as discussed in [[UBC systemwide configuration]].&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Resource_management&amp;diff=3426</id>
		<title>Resource management</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Resource_management&amp;diff=3426"/>
		<updated>2007-09-05T01:24:38Z</updated>

		<summary type="html">&lt;p&gt;Vass: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''OpenVZ resource management''' is a set of controls to provide per-[[VE]] limits and guarantees in a way that multiple VEs will coexist on a single physical server. It consists three primary controllers:&lt;br /&gt;
&lt;br /&gt;
* [[User beancounters]]&lt;br /&gt;
* [[OpenVZ disk quota system]]&lt;br /&gt;
* [[CPU Fairscheduler]]&lt;br /&gt;
* [[Traffic shaping with tc]]&lt;br /&gt;
&lt;br /&gt;
 FIXME: add more text&lt;br /&gt;
 FIXME: create a right-hand navigation menu for all of the resource management stuff&lt;br /&gt;
&lt;br /&gt;
[[Category:Definitions]]&lt;br /&gt;
[[Category:Kernel]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Installing_udev_in_VE_based_on_Debian-4.0&amp;diff=3308</id>
		<title>Installing udev in VE based on Debian-4.0</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Installing_udev_in_VE_based_on_Debian-4.0&amp;diff=3308"/>
		<updated>2007-07-12T08:06:35Z</updated>

		<summary type="html">&lt;p&gt;Vass: Initial edition of the article&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When you install &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt; package in [[VE]] based on Debian-4.0 template, you can see the following message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Setting up udev (0.105-4) ...&lt;br /&gt;
/var/lib/dpkg/info/udev.postinst: line 125: echo: write error: Operation not permitted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The problem is that postinstall script tries to write to &amp;lt;tt&amp;gt;/proc/sys/kernel/hotplug&amp;lt;/tt&amp;gt; file, and this operation is prohibited in VE.&lt;br /&gt;
To work around this problem, just comment the 125th line in &amp;lt;tt&amp;gt;/var/lib/dpkg/info/udev.postinst&amp;lt;/tt&amp;gt; file, that writes to &amp;lt;tt&amp;gt;/proc/sys/kernel/hotplug&amp;lt;/tt&amp;gt; file. After that &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt; can be installed smoothly.&lt;br /&gt;
&lt;br /&gt;
P.S. Don't forget to enable &amp;lt;tt&amp;gt;sysfs&amp;lt;/tt&amp;gt; feature for VE in question (by vzctl), in order &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt; to be able to work.&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3307</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3307"/>
		<updated>2007-07-12T07:52:27Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Workaround */ add more detailed workaround: stop VPN&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Reason #1 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Reason #2 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reason #3 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE, which is usually used &lt;br /&gt;
for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
You should not use &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device in VE to migrate  it. If you're using VPN in VE, just stop VPN, then produce the online migration and after that start the VPN. Of course, all current connections to VPN will be lost :(.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3306</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3306"/>
		<updated>2007-07-11T12:48:54Z</updated>

		<summary type="html">&lt;p&gt;Vass: reason 3 added: tun device in VE&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Reason #1 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Reason #2 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reason #3 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Dumping VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        join context..&lt;br /&gt;
        dump...&lt;br /&gt;
Can not dump VE: Device or resource busy&lt;br /&gt;
unsupported netdevice tun0&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to dump VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
Checkpointing doesn't support &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device inside VE, which is usually used &lt;br /&gt;
for [[VPN via the TUN/TAP device]] in VE.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
You should not use &amp;lt;tt&amp;gt;tun&amp;lt;/tt&amp;gt; device in VE to migrate  it.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=642&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14826&amp;amp;#msg_14826&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Testimonials&amp;diff=3304</id>
		<title>Testimonials</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Testimonials&amp;diff=3304"/>
		<updated>2007-07-11T09:34:44Z</updated>

		<summary type="html">&lt;p&gt;Vass: one more added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Following are some comments we've received from OpenVZ users.'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I just wanted to congratulate you and the rest of the OpenVZ team for your&lt;br /&gt;
excellent, excellent work. We are now have an OpenVZ subject in our 120&lt;br /&gt;
hours Total Linux course here at the Bluepoint Foundation, and our&lt;br /&gt;
students really appreciate the work you've done. I'm learning a lot from&lt;br /&gt;
lurking in the devel list too. Thanks again and keep 'em coming! :D&lt;br /&gt;
&lt;br /&gt;
''Engels Antonio, [http://bluepoint.com.ph/ Bluepoint Foundation]''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I would say, OpenVZ is '''United States of Linux''' because i can run all my lovely different type of GNU/Linux distributions(States) on '''one single machine''' with '''one kernel''' model. As stable as guaranteed for production server and handy for software development (well no more dual, tri, quad boot partition). After all, it is just a good quality software piece for Linux User. Again, welcome to '''United States of Linux''' world!!&lt;br /&gt;
&lt;br /&gt;
''Victor, System Admin, [http://www.kholix.com kholix.com]''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Thanks for producing OpenVZ, we use it ourselves at PlanetMirror and&lt;br /&gt;
find that it's fantastic.&lt;br /&gt;
&lt;br /&gt;
''Robert McLeay, PlanetMirror.com stuff''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
OpenVZ has me seriously impressed, I was looking to try virtualisation technology and got OpenVZ up and running in only 3 trips to the coffee machine! ''-barf''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Hello all, just downloaded and installed OpenVZ, and i must say its a big improvement over other VPS systems that i have tested IMHO.&lt;br /&gt;
[http://forum.openvz.org/index.php?t=tree&amp;amp;goto=646&amp;amp;#msg_646]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Virtuozzo and openvz are wonderful - I don't know why more people aren't&lt;br /&gt;
using them. I hear a lot of hype for xen and usermode but&lt;br /&gt;
virtuozzo/openvz is so great for many common needs.&lt;br /&gt;
[http://forum.openvz.org/index.php?t=rview&amp;amp;goto=650#msg_650]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
For my needs, OpenVZ is better than Xen. The one-kernel approach conserves memory, leaving more for applications. And having all VPS in one disk partition saves disk space. A surprise bonus was the template cache management with yum. The ease of keeping templates updated and quickly installing new operating environments is yummy!&lt;br /&gt;
[http://forum.openvz.org/index.php?t=rview&amp;amp;goto=3119#msg_3119]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Last week when we were in limbo about what to do, it was decided to try out XEN Virtualization. From what is written in the press the Xen system has alot of promise, Features such as opensource with live migration and backups sounds great; but was far too complicated to get working in our configuration. OpenVZ was the only virtual server system that was simple to install and get working.&lt;br /&gt;
[http://forum.openvz.org/index.php?t=msg&amp;amp;goto=568#msg_568]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
It still amazes me how well OpenVZ works.&lt;br /&gt;
[http://forum.openvz.org/index.php?t=msg&amp;amp;th=368&amp;amp;#msg_2086]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[03:30:15] &amp;lt;pookey&amp;gt; well, I've been using openvz for all of about an hour, and I'm pretty impressed so far :)&amp;lt;br/&amp;gt;&lt;br /&gt;
''from #openvz IRC channel''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I am playing around for years with all major virtualization environments like all VMware products, Microsoft and several xen based solutions. But OpenVZ is the overall winner. [http://blog.openvz.org/14313.html]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I messed around with VMWare and Xen. I found VMWare to be somewhat over kill and Xen was damned hard to get working. The user community on the Xen mailing list is rather hostile. It looked like A number of people hang out there for the sole purpose of flaming the clueless.&lt;br /&gt;
&lt;br /&gt;
I've found the OpenVZ folks to be very helpful and knowledgeable. OpenVZ is simple to install and get running. It pretty much satisfies my needs. [http://blog.openvz.org/14313.html?thread=17897#t17897]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I'm a sysadm and have always used xen/qemu/virtualbox/vmware server for my VMs and my customer's ones. Yesterday I decided to give OpenVZ a try and... I'm amazed. It's fast, easy and reliable.Live migration works like a charm and the use of rsync assures low data transfers. Great. [http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14724&amp;amp;#msg_14724]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3303</id>
		<title>Migration fails</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Migration_fails&amp;diff=3303"/>
		<updated>2007-07-11T07:53:48Z</updated>

		<summary type="html">&lt;p&gt;Vass: second reason added: inotidy in VE&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article contents known reasons of migration failures.&lt;br /&gt;
&lt;br /&gt;
== Reason #1 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
After giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Error: undump failed: Invalid argumentStopping VE ...&lt;br /&gt;
Restoring failed:&lt;br /&gt;
iptables-restore exited with 1&lt;br /&gt;
rst_restore_net: -22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses some iptables modules, that are not&lt;br /&gt;
loaded on destination node. Consequently &amp;lt;tt&amp;gt;iptables-restore&amp;lt;/tt&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Load all iptables kernel modules that are used by VE on destination node.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=631&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;th=2756&amp;amp;mid=14198&amp;amp;&amp;amp;rev=&amp;amp;reveal=&lt;br /&gt;
&lt;br /&gt;
== Reason #2 ==&lt;br /&gt;
===  Symptomps ===&lt;br /&gt;
The system runs &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; or older kernels and &lt;br /&gt;
after giving &amp;lt;tt&amp;gt;vzmigrate -v --online &amp;lt;ip address&amp;gt; &amp;lt;veid&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
the following message appears:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Live migrating VE&lt;br /&gt;
    Suspending VE&lt;br /&gt;
Setting up checkpoint...&lt;br /&gt;
        suspend...&lt;br /&gt;
Can not suspend VE: Device or resource busy&lt;br /&gt;
file on unsupported FS: magic 0bad1dea&lt;br /&gt;
Checkpointing failed&lt;br /&gt;
Error:  Failed to suspend VE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reason ===&lt;br /&gt;
The VE which you wish to migrate uses inotify mechanism (magic 0bad1dea), that is not&lt;br /&gt;
supported by &amp;lt;tt&amp;gt;028stab031&amp;lt;/tt&amp;gt; and older kernels.&lt;br /&gt;
&lt;br /&gt;
=== Workaround ===&lt;br /&gt;
Update till &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; or newer kernel.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
&lt;br /&gt;
* http://bugzilla.openvz.org/show_bug.cgi?id=552&lt;br /&gt;
* http://forum.openvz.org/index.php?t=tree&amp;amp;goto=14780&amp;amp;#msg_14780&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3301</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3301"/>
		<updated>2007-07-10T12:20:39Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Downloading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.18&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=684 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=68 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-based CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt;  for CentOS-based CD and to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; for KNOPPIX-based CD.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}.&lt;br /&gt;
You can work around it by mounting some filesystem (&amp;lt;tt&amp;gt;ext2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ext3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;) to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
On CentOS-based LiveCD &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; is mounted on this directory automatically during the booting.&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3287</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3287"/>
		<updated>2007-07-06T09:52:26Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* CentOS LiveCD contents */ vzctl -&amp;gt; 3.0.18&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.18&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-based CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt;  for CentOS-based CD and to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; for KNOPPIX-based CD.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}.&lt;br /&gt;
You can work around it by mounting some filesystem (&amp;lt;tt&amp;gt;ext2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ext3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;) to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
On CentOS-based LiveCD &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; is mounted on this directory automatically during the booting.&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3286</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3286"/>
		<updated>2007-07-06T09:20:54Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ removing modules from initrd&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there, but you should use &amp;lt;tt&amp;gt;3.2&amp;lt;/tt&amp;gt;! :)&lt;br /&gt;
* While building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; some small fixes: &amp;lt;tt&amp;gt;i_blksize&amp;lt;/tt&amp;gt; field is missing in &amp;lt;tt&amp;gt;inode&amp;lt;/tt&amp;gt; structure, &amp;lt;tt&amp;gt;ino_t&amp;lt;/tt&amp;gt; should be changed to &amp;lt;tt&amp;gt;u64&amp;lt;/tt&amp;gt; in some functions.&lt;br /&gt;
&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* Only &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;2.0&amp;lt;/tt&amp;gt; is available for 2.6.20 kernel and it is distributed as a patch. Consequently modify &amp;lt;tt&amp;gt;spec&amp;lt;/tt&amp;gt;-file and configs while building the kernel&lt;br /&gt;
* &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;2.0&amp;lt;/tt&amp;gt; doesn't support unionctl. Consequently you have to modify &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file on &amp;lt;tt&amp;gt;initrd&amp;lt;/tt&amp;gt; image to mount all branches at once, but don't add them by ioctls.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;.&lt;br /&gt;
But when disk quota is off &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt; fails! ;) This is the [http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #512].&lt;br /&gt;
So, don't forget to apply the patch attached to this bug report to &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I also delete some not necessary kernel modules from initrd to free space.&lt;br /&gt;
They are stil on CD, so init sctipts will be able to load them later.&lt;br /&gt;
&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3285</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3285"/>
		<updated>2007-07-06T08:54:56Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Peculiarities of building 2.6.20 */ added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there, but you should use &amp;lt;tt&amp;gt;3.2&amp;lt;/tt&amp;gt;! :)&lt;br /&gt;
* While building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; some small fixes: &amp;lt;tt&amp;gt;i_blksize&amp;lt;/tt&amp;gt; field is missing in &amp;lt;tt&amp;gt;inode&amp;lt;/tt&amp;gt; structure, &amp;lt;tt&amp;gt;ino_t&amp;lt;/tt&amp;gt; should be changed to &amp;lt;tt&amp;gt;u64&amp;lt;/tt&amp;gt; in some functions.&lt;br /&gt;
&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* Only &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;2.0&amp;lt;/tt&amp;gt; is available for 2.6.20 kernel and it is distributed as a patch. Consequently modify &amp;lt;tt&amp;gt;spec&amp;lt;/tt&amp;gt;-file and configs while building the kernel&lt;br /&gt;
* &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;2.0&amp;lt;/tt&amp;gt; doesn't support unionctl. Consequently you have to modify &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file on &amp;lt;tt&amp;gt;initrd&amp;lt;/tt&amp;gt; image to mount all branches at once, but don't add them by ioctls.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;.&lt;br /&gt;
But when disk quota is off &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt; fails! ;) This is the [http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #512].&lt;br /&gt;
So, don't forget to apply the patch attached to this bug report to &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3284</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3284"/>
		<updated>2007-07-06T07:12:05Z</updated>

		<summary type="html">&lt;p&gt;Vass: moved information about shmpages to appropriate place&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ. ([[Download live CD]])&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is identified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/vz/template/cache/&amp;lt;/tt&amp;gt; (CentOS LiveCD)&lt;br /&gt;
or in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; (KNOPPIX LiveCD) directories for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# useradd new-user&lt;br /&gt;
# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
# mkdir /home/new-user&lt;br /&gt;
# chown new-user /home/new-user/&lt;br /&gt;
# su new-user&lt;br /&gt;
$ cd ~&lt;br /&gt;
$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
# ifconfig venet0 up&lt;br /&gt;
# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
#&lt;br /&gt;
# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need tot&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual &amp;lt;tt&amp;gt;apt-get&amp;lt;/tt&amp;gt; tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ Note|In the LiveCD environment, you may have to increase '''shmpages''' resource limit/barrier for the VE (read the next section) or you will run out of &amp;quot;disk space&amp;quot; when trying to install software }}&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. For example to set '''shmpages''' (shared memory pages) barrier:limit you&lt;br /&gt;
should give this command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 101 --shmpages 16384:16384 --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will give VE 101 64MB of '''shmpages''' (one page equals 4Kb on i386: 4Kb * 16384 = 64Mb)&lt;br /&gt;
&lt;br /&gt;
Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /proc/bc/101/resources # or /proc/user_beancounters on 2.6.9 kernels&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/ .&lt;br /&gt;
&lt;br /&gt;
If you experience some difficulties, contact us via http://forum.openvz.org/ . Templates and other tools are available from http://download.openvz.org/ .&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3283</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3283"/>
		<updated>2007-07-06T06:50:52Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* VE creation */ centos case added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ. ([[Download live CD]])&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is identified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/vz/template/cache/&amp;lt;/tt&amp;gt; (CentOS LiveCD)&lt;br /&gt;
or in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; (KNOPPIX LiveCD) directories for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change from the host by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# useradd new-user&lt;br /&gt;
# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
# mkdir /home/new-user&lt;br /&gt;
# chown new-user /home/new-user/&lt;br /&gt;
# su new-user&lt;br /&gt;
$ cd ~&lt;br /&gt;
$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
# ifconfig venet0 up&lt;br /&gt;
# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
#&lt;br /&gt;
# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual &amp;lt;tt&amp;gt;apt-get&amp;lt;/tt&amp;gt; tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/ .&lt;br /&gt;
&lt;br /&gt;
If you experience some difficulties, contact us via http://forum.openvz.org/ . Templates and other tools are available from http://download.openvz.org/ .&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3282</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3282"/>
		<updated>2007-07-06T06:39:23Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Changelog */ fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-based CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt;  for CentOS-based CD and to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; for KNOPPIX-based CD.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}.&lt;br /&gt;
You can work around it by mounting some filesystem (&amp;lt;tt&amp;gt;ext2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ext3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;) to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
On CentOS-based LiveCD &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; is mounted on this directory automatically during the booting.&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3281</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3281"/>
		<updated>2007-07-06T06:38:52Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Limitations */ small fixes, workaround for checkpointing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-based CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt;  for CentOS-based CD and to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; for KNOPPIX-based CD.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}.&lt;br /&gt;
You can work around it by mounting some filesystem (&amp;lt;tt&amp;gt;ext2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ext3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;) to &amp;lt;tt&amp;gt;/var/lib/vz/private&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
On CentOS-based LiveCD &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; is mounted on this directory automatically during the booting.&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3280</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3280"/>
		<updated>2007-07-06T06:18:18Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Booting */ missprint&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-based CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3279</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3279"/>
		<updated>2007-07-06T06:17:09Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Downloading */ formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files|This page]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-base CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3278</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3278"/>
		<updated>2007-07-06T06:15:01Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Downloading */ CentOS 4.4 LiveCD added.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.md5|size=}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=CentOS-4.4-OpenVZ-i386-LiveCD.iso.asc|size=}}&lt;br /&gt;
&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-base CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3277</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3277"/>
		<updated>2007-07-06T06:07:24Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Centos LiveCD contents */ formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== CentOS LiveCD contents ==&lt;br /&gt;
This CD is based on CentOS 4.4 Live CD and contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-base CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3276</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3276"/>
		<updated>2007-07-06T06:06:25Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Centos LiveCD contents */ 2.6.20 kernel added, vzctl updated, formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
We offer two live CDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. &lt;br /&gt;
&lt;br /&gt;
== Centos LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* '''kernels''':&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization (2.6.9-42.livecd.c4)&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
** 2.6.20-ovz007.1&lt;br /&gt;
* '''tools''':&lt;br /&gt;
** vzctl 3.0.17&lt;br /&gt;
** vzquota 3.0.9&lt;br /&gt;
* '''template tools''':&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* '''template metadatas''':&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* '''precreated templates''':&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.) in order&lt;br /&gt;
to free disk space for OpenVZ packages and templates.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-base CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3275</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3275"/>
		<updated>2007-07-05T13:49:09Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Peculiarities of building 2.6.18-rhel5 */ squshfs 3.2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there, but you should use &amp;lt;tt&amp;gt;3.2&amp;lt;/tt&amp;gt;! :)&lt;br /&gt;
* While building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; some small fixes: &amp;lt;tt&amp;gt;i_blksize&amp;lt;/tt&amp;gt; field is missing in &amp;lt;tt&amp;gt;inode&amp;lt;/tt&amp;gt; structure, &amp;lt;tt&amp;gt;ino_t&amp;lt;/tt&amp;gt; should be changed to &amp;lt;tt&amp;gt;u64&amp;lt;/tt&amp;gt; in some functions.&lt;br /&gt;
&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* FIXME&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;.&lt;br /&gt;
But when disk quota is off &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt; fails! ;) This is the [http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #512].&lt;br /&gt;
So, don't forget to apply the patch attached to this bug report to &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3265</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3265"/>
		<updated>2007-07-05T11:26:44Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ vzmigrate fix added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there! :)&lt;br /&gt;
* While building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; some small fixes: &amp;lt;tt&amp;gt;i_blksize&amp;lt;/tt&amp;gt; field is missing in &amp;lt;tt&amp;gt;inode&amp;lt;/tt&amp;gt; structure, &amp;lt;tt&amp;gt;ino_t&amp;lt;/tt&amp;gt; should be changed to &amp;lt;tt&amp;gt;u64&amp;lt;/tt&amp;gt; in some functions.&lt;br /&gt;
&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* FIXME&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;.&lt;br /&gt;
But when disk quota is off &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt; fails! ;) This is the [http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #512].&lt;br /&gt;
So, don't forget to apply the patch attached to this bug report to &amp;lt;tt&amp;gt;vzmigrate&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3264</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3264"/>
		<updated>2007-07-05T07:50:13Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Peculiarities of building 2.6.18-rhel5 */  unionfs build&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there! :)&lt;br /&gt;
* While building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; some small fixes: &amp;lt;tt&amp;gt;i_blksize&amp;lt;/tt&amp;gt; field is missing in &amp;lt;tt&amp;gt;inode&amp;lt;/tt&amp;gt; structure, &amp;lt;tt&amp;gt;ino_t&amp;lt;/tt&amp;gt; should be changed to &amp;lt;tt&amp;gt;u64&amp;lt;/tt&amp;gt; in some functions.&lt;br /&gt;
&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* FIXME&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3261</id>
		<title>Download/live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Download/live_CD&amp;diff=3261"/>
		<updated>2007-07-04T14:17:42Z</updated>

		<summary type="html">&lt;p&gt;Vass: CentOS 4.4. version added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you can find OpenVZ Live CD images. We have to LiveCDs at the moment. The first one is based on Knoppix 5.1.1 and the second one is based on Centos 4.4. Live CD is a great way to test drive the OpenVZ technology without a need to actually install it on your machine.&lt;br /&gt;
&lt;br /&gt;
== Centos LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernels:&lt;br /&gt;
** original CentOS 4.4 kernel without virtualization&lt;br /&gt;
** 2.6.9-023stab044.4&lt;br /&gt;
** 2.6.18-028stab035&lt;br /&gt;
** 2.6.18-028stab035-rhel5&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
* template tools:&lt;br /&gt;
** vzyum-2.4.0-11&lt;br /&gt;
** vzrpm44-4.4.1-22.5&lt;br /&gt;
** vzrpm43-4.3.3-7&lt;br /&gt;
** vzpkg-2.7.0-18&lt;br /&gt;
* template metadatas:&lt;br /&gt;
** vztmpl-centos-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-3-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-4-2.0-2&lt;br /&gt;
** vztmpl-fedora-core-5-2.0-2&lt;br /&gt;
* several precreated templates:&lt;br /&gt;
** centos-4-i386-minimal&lt;br /&gt;
** fedora-core-5-i386-minimal&lt;br /&gt;
** debian-3.1-i386-minimal&lt;br /&gt;
&lt;br /&gt;
The number of original CentOS packages were removed (&amp;lt;tt&amp;gt;openoffice&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, etc.)&lt;br /&gt;
to free space for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Knoppix LiveCD contents ==&lt;br /&gt;
This CD contains the following OpenVZ packages:&lt;br /&gt;
* kernel 2.6.18-028stab027&lt;br /&gt;
* vzctl 3.0.16&lt;br /&gt;
* vzquota 3.0.9&lt;br /&gt;
plus the number of precreated templates:&lt;br /&gt;
* Debian 3.1 minimal&lt;br /&gt;
* CentOS 4 minimal&lt;br /&gt;
* Fedora Core 5 minimal&lt;br /&gt;
&lt;br /&gt;
It also contains all the software from the original Knoppix 5.1.1 CD, excluding:&lt;br /&gt;
* OpenOffice&lt;br /&gt;
* GIMP&lt;br /&gt;
* Frozen Bubble&lt;br /&gt;
The above packages were taken out to make some room for OpenVZ packages.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
The precreated ISO image is available directly from [http://download.openvz.org/livecd/ download.openvz.org/livecd/] or any of the [[download mirrors]].&lt;br /&gt;
&lt;br /&gt;
{{KernelDownloadTableHead}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso|size=683 MB}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.md5|size=77 B}}&lt;br /&gt;
{{DownloadTableRow|path=http://download.openvz.org/livecd|file=KNOPPIX_V5.1.1-OPENVZ-CD-2007-01-04-EN.iso.asc|size=189 B}}&lt;br /&gt;
{{KernelDownloadTableTail}}&lt;br /&gt;
&lt;br /&gt;
Note that .md5 and .asc files does not need to be copied to the CD-R; they are here to check the authentity of the iso file. [[Package_signatures#Checking_files]] has some info on this topic.&lt;br /&gt;
&lt;br /&gt;
== Burning ==&lt;br /&gt;
&lt;br /&gt;
After downloading the image, you have to burn it to the actual media, i.e. a CD-R or CD-RW disk. The process depends on the actual OS and CD burning software that you have, and the exact details are out of scope of this article.&lt;br /&gt;
&lt;br /&gt;
If you don't know how to burn the ISO image to CD-R, try [http://www.knoppix.net/wiki/Downloading_FAQ#Q:_I_have_downloaded_the_ISO_file._How_do_I_burn_the_ISO.3F_How_is_the_ISO_supposed_to_be_burned.3F this document].&lt;br /&gt;
&lt;br /&gt;
== Booting ==&lt;br /&gt;
Just insert the fresh CD into your CD-ROM and reboot. In some cases you have to modify your BIOS settings in order to enable booting from a CD.&lt;br /&gt;
If you use CentOS-base CD you'll be able to choose the kernel to boot: &amp;lt;tt&amp;gt;ovz9rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz18rh&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ovz20&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;linux&amp;lt;/tt&amp;gt; (original CentOS kernel).&lt;br /&gt;
&lt;br /&gt;
== Using ==&lt;br /&gt;
Upon the successful boot, a browser window with some helful hints will appear to help you start using OpenVZ. The latest version of that document is also available on this wiki: [[Getting started with OpenVZ live CD]].&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Since this is a live CD, everything is created in RAM, i.e. is not persistent. If you will create a number of VEs, they will not be available after the reboot.&lt;br /&gt;
&lt;br /&gt;
A number of [[VE]]s that you can create using this live CD greatly depends on the amount of RAM your machine has, since the system uses RAM instead of a hard disk. On a 1 gigabyte RAM machine you can create about 5 VEs. To work around this, you have to have a disk partition mounted to /var/lib/vz.&lt;br /&gt;
&lt;br /&gt;
OpenVZ disk quota does not work on LiveCD at the moment due to {{Bug|558}}, so &amp;lt;code&amp;gt;df&amp;lt;/code&amp;gt; in [[VE]] shows ludicrous values if quota is on.&lt;br /&gt;
Because of it on CentOS 4.4 LiveCD disk quota is switched off by default.&lt;br /&gt;
&lt;br /&gt;
Checkpointing (and consequently live migration) doesn't work on KNOPPIX LiveCD at the moment due to {{Bug|606}}. But it '''works''' on CentOS-based LiveCD!&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
* 7 May 2007, initial version based on Knoppix 5.1.1&lt;br /&gt;
* 5 July 2007, second version based on Centos 4.4&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://knoppix.com/ knoppix.com], the home of Knoppix distribution&lt;br /&gt;
* [http://centos.org/ centos.org], the home of CentOS distribution&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3260</id>
		<title>Getting started with OpenVZ live CD</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Getting_started_with_OpenVZ_live_CD&amp;diff=3260"/>
		<updated>2007-07-04T13:42:56Z</updated>

		<summary type="html">&lt;p&gt;Vass: remove knoppix mentioning: we have now one more LiveCD based on Centos 4.4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is written for OpenVZ LiveCD and assumes that the reader only starts using OpenVZ. ([[Download live CD]])&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
So, as you probably know, OpenVZ allows the user to create [[VE]]s, or Virtual Environments, which seem very much&lt;br /&gt;
like real computers. Real computer can run various distributions: Debian, Gentoo, Red Hat and  Novell products, etc.&lt;br /&gt;
In the same way, a VE can be based on various [[OS template|OS (Operating System) templates]]. On the LiveCD only few minimal OS templates are installed because of disk space limit. Each VE is identified by its number -- a '''VEID'''.&lt;br /&gt;
&lt;br /&gt;
== VE creation ==&lt;br /&gt;
So, how to create a VE with VEID of 101 based on Debian template? Very easy. Just type the following commands in your&lt;br /&gt;
terminal (you must be root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl create 101 --ostemplate debian-3.1-i386-minimal&lt;br /&gt;
Creating VE private area (debian-3.1-i386-minimal)&lt;br /&gt;
Performing postcreate actions&lt;br /&gt;
VE private area was created&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''vzctl''' is the tool that manages VEs. Look in &amp;lt;tt&amp;gt;/var/lib/vz/template/cache/&amp;lt;/tt&amp;gt; directory for other OS templates available on LiveCD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 /var/lib/vz/template/cache/&lt;br /&gt;
centos-4-i386-minimal.tar.gz&lt;br /&gt;
debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of VEs ==&lt;br /&gt;
You can get the list of all created VEs on '''HN''' (Hardware Node) using '''vzlist''' command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#  vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          - stopped -               -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you see, VE 101 is in stopped state now.&lt;br /&gt;
&lt;br /&gt;
== Starting VE ==&lt;br /&gt;
Let's start it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl start 101&lt;br /&gt;
Starting VE ...&lt;br /&gt;
VE is mounted&lt;br /&gt;
Setting CPU units: 1000&lt;br /&gt;
VE start in progress...&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          5 running                 -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o Note: In the LiveCD environment, you may have to increase SHMPAGES for the VE or you will run out of &amp;quot;disk space&amp;quot; when trying to install software.  You can do this &amp;quot;on the fly&amp;quot; by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl set 101 --shmpages $((8192*8)):$((8192*8)) --save '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
o This will give VE 101 64MB of shmpages; you may wish to give it more if you're planning on doing more than just basic openvz testing.&lt;br /&gt;
&lt;br /&gt;
o You can verify the change from the host by issuing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
' vzctl exec 101 cat /proc/user_beancounters '&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Executing commands in VE ==&lt;br /&gt;
From the &amp;quot;vzlist&amp;quot; command you see that 5 processes are running inside VE 101. (The &amp;quot;NPROC&amp;quot; field indicates the number of Processes, or PIDs, that are active in the VE -- not the number of Processors, or CPUs.)  Being on usual [[hardware node]] you can use &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; command to identify those, and the same command can be used here. The only difference is that this command should be called inside VE.&lt;br /&gt;
&lt;br /&gt;
In order to perform any command inside VE `vzctl exec` is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl exec 101 ps&lt;br /&gt;
  PID TTY          TIME CMD&lt;br /&gt;
    1 ?        00:00:00 init&lt;br /&gt;
 7672 ?        00:00:00 rc&lt;br /&gt;
 7674 ?        00:00:00 S10sysklogd&lt;br /&gt;
 7677 ?        00:00:00 syslogd&lt;br /&gt;
 7678 ?        00:00:00 syslogd&lt;br /&gt;
 7683 ?        00:00:00 ps&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Entering VE ==&lt;br /&gt;
Any self-respected OS provides a shell for the user. This is how you can get the VE's shell:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this shell you can do almost all you can do on the real HN. For example create a new user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# useradd new-user&lt;br /&gt;
# passwd new-user&lt;br /&gt;
Enter new UNIX password:&lt;br /&gt;
Retype new UNIX password:&lt;br /&gt;
passwd: password updated successfully&lt;br /&gt;
# mkdir /home/new-user&lt;br /&gt;
# chown new-user /home/new-user/&lt;br /&gt;
# su new-user&lt;br /&gt;
$ cd ~&lt;br /&gt;
$ pwd&lt;br /&gt;
/home/new-user&lt;br /&gt;
exit&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to exit from VEs shell, just type exit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up VE networking ==&lt;br /&gt;
Let's set up networking in VE.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
# ifconfig venet0 up&lt;br /&gt;
# vzctl set 101 --ipadd 10.1.1.1 --save&lt;br /&gt;
Adding IP address(es): 10.1.1.1&lt;br /&gt;
Saved parameters for VE 1&lt;br /&gt;
# vzlist -a&lt;br /&gt;
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME&lt;br /&gt;
       101          4 running 10.1.1.1        -&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your [[Hardware Node]] can ping VE and VE can ping HN:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ping 10.1.1.1&lt;br /&gt;
PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=3.80 ms&lt;br /&gt;
&lt;br /&gt;
--- 10.1.1.1 ping statistics ---&lt;br /&gt;
1 packets transmitted, 1 received, 0% packet loss, time 0ms&lt;br /&gt;
rtt min/avg/max/mdev = 3.804/3.804/3.804/0.000 ms&lt;br /&gt;
#&lt;br /&gt;
# vzctl exec 101 ping 192.168.0.244&lt;br /&gt;
PING 192.168.0.244 (192.168.0.244) 56(84) bytes of data.&lt;br /&gt;
64 bytes from 192.168.0.244: icmp_seq=1 ttl=64 time=0.508 ms&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, it is not possible to ping other computers in the network: for it we need to&lt;br /&gt;
set up NAT (Network Address Translation) and set the nameserver.&lt;br /&gt;
&lt;br /&gt;
Assume that you've set up network on HN (for example via DHCP) and the IP address&lt;br /&gt;
of your node is 192.168.0.244 and nameserver IP address is 192.168.1.1.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A POSTROUTING -s 10.1.1.1 -o eth0 -j SNAT --to 192.168.0.244&lt;br /&gt;
# vzctl set 101 --nameserver 192.168.1.1 --save&lt;br /&gt;
File resolv.conf was modified&lt;br /&gt;
Saved parameters for VE 101&lt;br /&gt;
# vzctl exec 101 ping google.com&lt;br /&gt;
PING google.com (64.233.167.99) 56(84) bytes of data.&lt;br /&gt;
64 bytes from py-in-f99.google.com (64.233.167.99): icmp_seq=1 ttl=241 time=23.0 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installing software inside VE ==&lt;br /&gt;
I guess you've noted that there is not so many packages in VE. It is because minimal template was used.&lt;br /&gt;
But of course, you can install any software in VE by yourself. For example, in Debian usual &amp;lt;tt&amp;gt;apt-get&amp;lt;/tt&amp;gt; tool can be used.&lt;br /&gt;
&lt;br /&gt;
Now, for example, we can install gcc inside VE 101 for developing purposes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl enter 101&lt;br /&gt;
entered into VE 101&lt;br /&gt;
#&lt;br /&gt;
# apt-get install gcc&lt;br /&gt;
Reading Package Lists... Done&lt;br /&gt;
Building Dependency Tree... Done&lt;br /&gt;
The following extra packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc-3.3&lt;br /&gt;
Suggested packages:&lt;br /&gt;
  binutils-doc cpp-doc make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-3.3-doc&lt;br /&gt;
Recommended packages:&lt;br /&gt;
  libc-dev libc6-dev&lt;br /&gt;
The following NEW packages will be installed:&lt;br /&gt;
  binutils cpp cpp-3.3 gcc gcc-3.3&lt;br /&gt;
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.&lt;br /&gt;
Need to get 5220kB of archives.&lt;br /&gt;
After unpacking 13.6MB of additional disk space will be used.&lt;br /&gt;
Do you want to continue? [Y/n] y&lt;br /&gt;
Get:1 http://ftp.freenet.de stable/main binutils 2.15-6 [2221kB]&lt;br /&gt;
Get:2 http://ftp.freenet.de stable/main cpp-3.3 1:3.3.5-13 [1393kB]&lt;br /&gt;
Get:3 http://ftp.freenet.de stable/main cpp 4:3.3.5-3 [29.6kB]&lt;br /&gt;
Get:4 http://ftp.freenet.de stable/main gcc-3.3 1:3.3.5-13 [1570kB]&lt;br /&gt;
Get:5 http://ftp.freenet.de stable/main gcc 4:3.3.5-3 [4906B]&lt;br /&gt;
Fetched 5220kB in 10s (507kB/s)&lt;br /&gt;
Selecting previously deselected package binutils.&lt;br /&gt;
(Reading database ... 7436 files and directories currently installed.)&lt;br /&gt;
Unpacking binutils (from .../binutils_2.15-6_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp-3.3.&lt;br /&gt;
Unpacking cpp-3.3 (from .../cpp-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package cpp.&lt;br /&gt;
Unpacking cpp (from .../cpp_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc-3.3.&lt;br /&gt;
Unpacking gcc-3.3 (from .../gcc-3.3_1%3a3.3.5-13_i386.deb) ...&lt;br /&gt;
Selecting previously deselected package gcc.&lt;br /&gt;
Unpacking gcc (from .../gcc_4%3a3.3.5-3_i386.deb) ...&lt;br /&gt;
Setting up binutils (2.15-6) ...&lt;br /&gt;
&lt;br /&gt;
Setting up cpp-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up cpp (3.3.5-3) ...&lt;br /&gt;
Setting up gcc-3.3 (3.3.5-13) ...&lt;br /&gt;
Setting up gcc (3.3.5-3) ...&lt;br /&gt;
&lt;br /&gt;
# exit&lt;br /&gt;
logout&lt;br /&gt;
exited from VE 101&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resource limiting ==&lt;br /&gt;
The very important feature of VE is that you can limit it by resources: CPU, memory, disk space.&lt;br /&gt;
It is also performed via vzctl. Current usage values and limits of memory-related resources can be viewed through&lt;br /&gt;
&amp;lt;code&amp;gt;/proc/bc/VEID/resources&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /proc/bc/101/resources&lt;br /&gt;
            kmemsize         628209     976969    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        5238       6885      49152      53575          0&lt;br /&gt;
            shmpages           5012       5014       8192       8192          0&lt;br /&gt;
            numproc               3         11         65         65          0&lt;br /&gt;
            physpages          5084       6020          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       5084       6020       6144 2147483647          0&lt;br /&gt;
            numtcpsock            0          2         80         80          0&lt;br /&gt;
            numflock              1          5        100        110          0&lt;br /&gt;
            numpty                0          1         16         16          0&lt;br /&gt;
            numsiginfo            0          6        256        256          0&lt;br /&gt;
            tcpsndbuf             0       4440     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0      42180     319488     524288          0&lt;br /&gt;
            othersockbuf       2220       6660     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       2220     132096     132096          0&lt;br /&gt;
            numothersock          1          6         80         80          0&lt;br /&gt;
            dcachesize            0          0    1048576    1097728          0&lt;br /&gt;
            numfile             106        339       2048       2048          0&lt;br /&gt;
            numiptent            10         10        128        128          0&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First column is resource name, second is current usage, third is peak usage, forth and fifth are barrier and limit, and last column is fail counter.&lt;br /&gt;
&lt;br /&gt;
Note that if you have nonzero values in the last column, it means that this VE&lt;br /&gt;
experienced a resource shortage. This is very common reason why some application fail to&lt;br /&gt;
work in a VE. In this case you should increase limits/barriers accordingly; see&lt;br /&gt;
[[resource shortage]] for more info.&lt;br /&gt;
&lt;br /&gt;
== Stopping/removing VE ==&lt;br /&gt;
Well, let's stop VE and destroy it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl stop 101&lt;br /&gt;
Stopping VE ...&lt;br /&gt;
VE was stopped&lt;br /&gt;
VE is unmounted&lt;br /&gt;
# vzctl destroy 101&lt;br /&gt;
Destroying VE private area: /var/lib/vz/private/101&lt;br /&gt;
VE private area was destroyed&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
That's all you need to start playing with OpenVZ. Additional information can be found in man page on vzctl and at http://wiki.openvz.org/ .&lt;br /&gt;
&lt;br /&gt;
If you experience some difficulties, contact us via http://forum.openvz.org/ . Templates and other tools are available from http://download.openvz.org/ .&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3259</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3259"/>
		<updated>2007-07-04T13:11:06Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ quite remove&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there! :)&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* FIXME&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default! &lt;br /&gt;
&lt;br /&gt;
And I suggest to remove &amp;lt;tt&amp;gt;quite&amp;lt;/tt&amp;gt; parameter, to see what happens: it will help greatly if some problem will happen.&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3258</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3258"/>
		<updated>2007-07-04T13:08:53Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Building OpenVZ kernels */  peculiarities of building added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above. But some important differences in building&lt;br /&gt;
kernel of version other then 2.6.18 one is summarized below.&lt;br /&gt;
==== Peculiarities of building 2.6.9-rhel4 ====&lt;br /&gt;
* You should also include this path (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)&lt;br /&gt;
in building process. Hopefully will be fixed in &amp;lt;tt&amp;gt;2.6.9-044stab044.8&amp;lt;/tt&amp;gt; kernel.&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unionfs 1.0.14&amp;lt;/tt&amp;gt;, but not &amp;lt;tt&amp;gt;unionfs 1.1.5&amp;lt;/tt&amp;gt;, as offered at its official site!&lt;br /&gt;
* Small problems while building &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;: arguments of &amp;lt;tt&amp;gt;vfs_permissions()&amp;lt;/tt&amp;gt;. Just add &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;&lt;br /&gt;
to appropriate places.&lt;br /&gt;
==== Peculiarities of building 2.6.18-rhel5 ====&lt;br /&gt;
* Note, &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch is already there! :)&lt;br /&gt;
==== Peculiarities of building 2.6.20 ====&lt;br /&gt;
* FIXME&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3257</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3257"/>
		<updated>2007-07-04T12:45:21Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Embellishment */ desktop background change&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
One more thing we change is default desktop background. It resides in &amp;lt;tt&amp;gt;usr/share/backgrounds/images/default.png&amp;lt;/tt&amp;gt;.&lt;br /&gt;
I added OpenVZ logo there.&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3255</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3255"/>
		<updated>2007-07-04T10:32:18Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Creating ISO */  &amp;lt;tt&amp;gt; added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed &amp;lt;tt&amp;gt;make_iso.sh&amp;lt;/tt&amp;gt; script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ovz-livecd&lt;br /&gt;
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3253</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3253"/>
		<updated>2007-07-04T08:45:06Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Debugging LiveCD */  serial console add&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
Also it can be useful to redirect kernel output to serial console:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
console=ttyS0,115200 console=tty&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3252</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3252"/>
		<updated>2007-07-04T08:23:45Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Embellishment */ information about splash.cfg and splash.lss added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
If you want to release LiveCD to other people some &amp;quot;embelishments&amp;quot; should be added.&lt;br /&gt;
&lt;br /&gt;
First, edit &amp;lt;tt&amp;gt;splash.cfg&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help1.txt&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;help2.txt&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;help3.txt&amp;lt;/tt&amp;gt;&lt;br /&gt;
files (that are in &amp;lt;tt&amp;gt;~/workbench/ovz-livecd/boot/help&amp;lt;/tt&amp;gt; directory) to contain appropriate information.&lt;br /&gt;
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.&lt;br /&gt;
&lt;br /&gt;
Also, you can note, that CentOS logo appears at this moment. This logo resides in &amp;lt;tt&amp;gt;ovz-livecd/boot/splash.lss&amp;lt;/tt&amp;gt;&lt;br /&gt;
file. I added OpenVZ logo there. The following tools will help you: &amp;lt;tt&amp;gt;lss16toppm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ppmtolss16&amp;lt;/tt&amp;gt; and&lt;br /&gt;
of course &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt; :)&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3251</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3251"/>
		<updated>2007-07-04T08:12:01Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Technical details */ embelishment section added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Embellishment ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3250</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3250"/>
		<updated>2007-07-03T14:56:59Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ ramdisk_size change&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=102400 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also '''don't forget''' to change &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; to 102400 for all kernels including Centos 4.4 default!&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3249</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3249"/>
		<updated>2007-07-03T13:39:14Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ increase initrd size&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patches to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file. Initrd image that goes with Centos 4.4 is&lt;br /&gt;
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of&lt;br /&gt;
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.&lt;br /&gt;
Don't forget to update &amp;lt;tt&amp;gt;ramdisk_size&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;isolinux.cfg&amp;lt;/tt&amp;gt; file later!&lt;br /&gt;
&lt;br /&gt;
Creating &amp;quot;big&amp;quot; initrd with original content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount-old&lt;br /&gt;
# gunzip initrd-old.gz &lt;br /&gt;
# mount -o loop initrd-old mount-old/&lt;br /&gt;
# dd if=/dev/zero of=initrd bs=1048576 count=100&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -a mount-old/* mount/&lt;br /&gt;
# umount mount-old/&lt;br /&gt;
# rm -rf mount-old initrd-old&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3245</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3245"/>
		<updated>2007-07-03T10:48:51Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ switch off disk quota by default&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the moment vzquota doesn't support &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).&lt;br /&gt;
We're working on this problem, but for now '''switching the disk quota off''' in &amp;lt;tt&amp;gt;/etc/vz/vz.conf&amp;lt;/tt&amp;gt;: &amp;lt;tt&amp;gt;DISK_QUOTA=no&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3244</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3244"/>
		<updated>2007-07-03T10:41:22Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ tmpfs on /vz/private added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As mentioned earlier we want to mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on /vz/private automatically. Just apply this patch to&lt;br /&gt;
&amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig-fstab     2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400&lt;br /&gt;
@@ -414,6 +414,7 @@ activate_fstab()&lt;br /&gt;
    echo &amp;quot;tmpfs            /                tmpfs       defaults         0   0&amp;quot; &amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;devpts           /dev/pts         devpts      gid=5,mode=620   0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
    echo &amp;quot;proc             /proc            proc        defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
+   echo &amp;quot;tmpfs            /vz/private      tmpfs       defaults         0   0&amp;quot; &amp;gt;&amp;gt;$FSTAB&lt;br /&gt;
&lt;br /&gt;
    # now done by fstab-sync&lt;br /&gt;
    # list_cdrom_devices | while read DEVICE; do&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3243</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3243"/>
		<updated>2007-07-03T10:08:05Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ /vz/private creation for tmpfs on it later&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment&lt;br /&gt;
chekpointing isn't supported on &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem ([http://bugzilla.openvz.org/show_bug.cgi?id=606  Bug #606]).&lt;br /&gt;
But we want of course checkpoiting to work on LiveCD. If we mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; on &amp;lt;tt&amp;gt;/vz/private/&amp;lt;/tt&amp;gt; on '''booted''' LiveCD,&lt;br /&gt;
then all newly created VEs reside on &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; and checkpointing works. Moreover we do not introduce any additional memory usage,&lt;br /&gt;
because even without &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt; all VEs reside in RAM (they contain new/updated files for &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Create &amp;lt;tt&amp;gt;/vz/private&amp;lt;/tt&amp;gt; directory, later, while modifying initrd image we will add the line that will mount &amp;lt;tt&amp;gt;tmpfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
on this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir root/vz/private/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3242</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3242"/>
		<updated>2007-07-03T07:36:23Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Building OpenVZ kernels */ path fixing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SPECS/&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3241</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3241"/>
		<updated>2007-07-03T07:18:29Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Creating booted LiveCD root filesystem */ compatibility to old squashfs added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able to mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;) and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools.&lt;br /&gt;
Here is '''an important''' note. We want, our LiveCD to be able to boot original Centos 4.4 kernel. This original kernel doesn't support&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; of version &amp;lt;tt&amp;gt;3&amp;lt;/tt&amp;gt;. Consequently we use &amp;lt;tt&amp;gt;sqashfs2.2-r2&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;mksquasfs&amp;lt;/tt&amp;gt; tool, but for &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool and later for compiling fresh OpenVZ kernels with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support we use &amp;lt;tt&amp;gt;sqashfs3.2-r2&amp;lt;/tt&amp;gt; sources/patches, because they are back compatible with &amp;lt;tt&amp;gt;sqashfs v2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs2.2-r2.tar.gz&lt;br /&gt;
# cd squashfs2.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -o mksquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3240</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3240"/>
		<updated>2007-07-03T06:31:50Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Creating ISO */ fix missprint&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this script, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3239</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3239"/>
		<updated>2007-07-02T15:23:47Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ short names in isolinux.cfg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD. It is important to give '''short name''' (not greater&lt;br /&gt;
than 8 characters) to kernel image, otherwise &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; will not see it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig   2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-07-02 19:10:51.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
&lt;br /&gt;
+label ovz18 &lt;br /&gt;
+kernel boot/ovz18&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3238</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3238"/>
		<updated>2007-07-02T14:16:42Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Vmlinux, initrd and isolinux.cfg */ cdrom modules loading patch added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there&lt;br /&gt;
and apply small patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Mount initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Copy modules to initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.&lt;br /&gt;
It works well for CentOS kernel, because cdrom support is built-in there.&lt;br /&gt;
But OpenVZ kernel supports cdrom (usual ide cdrom) via kernel module.&lt;br /&gt;
Consequetnly we need to apply the following patch to &amp;lt;tt&amp;gt;liblinuxlive&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- liblinuxlive.orig   2006-08-19 08:53:11.000000000 +0400&lt;br /&gt;
+++ liblinuxlive        2007-07-02 17:50:34.000000000 +0400&lt;br /&gt;
@@ -337,6 +337,9 @@ modprobe_essential_modules()&lt;br /&gt;
 {&lt;br /&gt;
    echolog &amp;quot;starting loop device support&amp;quot;&lt;br /&gt;
    modprobe_module loop max_loop=32&lt;br /&gt;
+   echolog &amp;quot;starting cdrom support&amp;quot;&lt;br /&gt;
+   modprobe_module cdrom&lt;br /&gt;
+   modprobe_module ide-cd&lt;br /&gt;
    echolog &amp;quot;starting cdrom filesystem support&amp;quot;&lt;br /&gt;
    modprobe_module isofs&lt;br /&gt;
    echolog &amp;quot;starting squashfs support&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finishing actions with initrd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig        2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-06-29 18:22:29.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz-2.6.18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
 &lt;br /&gt;
+label ovz-2.6.18 &lt;br /&gt;
+kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3237</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3237"/>
		<updated>2007-07-02T14:05:26Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ removing ~/.bash_history file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While being in chrooted environment bash history was written to &amp;lt;tt&amp;gt;~/.bash_history&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
Clean it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm root/root/.bash_history&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we just need to add OpenVZ kernel modules there:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig        2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-06-29 18:22:29.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz-2.6.18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
 &lt;br /&gt;
+label ovz-2.6.18 &lt;br /&gt;
+kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3236</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3236"/>
		<updated>2007-07-02T13:49:15Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ removal list updated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gnome-games&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;tetex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;latex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;k3b&amp;lt;/tt&amp;gt; and printing related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we just need to add OpenVZ kernel modules there:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig        2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-06-29 18:22:29.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz-2.6.18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
 &lt;br /&gt;
+label ovz-2.6.18 &lt;br /&gt;
+kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3235</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3235"/>
		<updated>2007-07-02T13:28:58Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ rpm -e fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;  related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex tetex tetex-afm \&lt;br /&gt;
tetex-dvips tetex-fonts tetex-xdvi&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we just need to add OpenVZ kernel modules there:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig        2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-06-29 18:22:29.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz-2.6.18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
 &lt;br /&gt;
+label ovz-2.6.18 &lt;br /&gt;
+kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3234</id>
		<title>Creating OpenVZ LiveCD based on Centos 4.4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Creating_OpenVZ_LiveCD_based_on_Centos_4.4&amp;diff=3234"/>
		<updated>2007-07-02T13:27:36Z</updated>

		<summary type="html">&lt;p&gt;Vass: /* Install all these finally */ remove gimp package from LiveCD&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is a step by step guide explaining how to add OpenVZ functionality to Centos 4.4 LiveCD.&lt;br /&gt;
As a result, you will have a LiveCD, that can boot in various OpenVZ kernels (rhel4-2.6.9, 2.6.18,&lt;br /&gt;
rhel5-2.6.18, 2.6.20) and in original CentOS kernel also. After booting from the CD, you will be able &lt;br /&gt;
to create [[VE]]s, start them, enter them - i.e. perform [[Getting started with OpenVZ live CD | common OpenVZ activity]].&lt;br /&gt;
&lt;br /&gt;
CentOS 5 LiveCD is already announced and as soon as it will be available we'll update the article.&lt;br /&gt;
&lt;br /&gt;
== General actions ==&lt;br /&gt;
It is quite easy to add OpenVZ functionality to existent LiveCD. The most difficult work is already done&lt;br /&gt;
by the original LiveCD creators. But it requires pretty much hand job. Probably some day some good guy will&lt;br /&gt;
automatize this process. ;)&lt;br /&gt;
&lt;br /&gt;
Actually you need to accomplish the following general actions - everything else is only technical details:&lt;br /&gt;
* Get a copy of CentOS 4.4 LiveCD image &lt;br /&gt;
* Use &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool to extract the contents of *.mo files, located on the image&lt;br /&gt;
* Construct '''booted''' LiveCD root filesystem from extracted files&lt;br /&gt;
* Create OpenVZ kernel RPM-packages  with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support&lt;br /&gt;
* Compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel modules against OpenVZ kernels&lt;br /&gt;
* Get OpenVZ tools RPM-packages: vzctl, vzquota, vzpkg, etc. Get template metadatas and precreated templates&lt;br /&gt;
* Remove some RPM-packages from '''booted''' LiveCD root filesystem (conflicting with OpenVZ kernel packages and redundant packages - to free some disk space)&lt;br /&gt;
* Install OpenVZ kernels, tools and templates in '''booted''' LiveCD root filesystem&lt;br /&gt;
* Using &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool compress '''booted''' CD root filesystem&lt;br /&gt;
* Modify initrd image: add there kernel modules for OpenVZ kernels&lt;br /&gt;
* Introduce small modifications to isolinux configuration file&lt;br /&gt;
* Create new iso image&lt;br /&gt;
&lt;br /&gt;
== Technical details ==&lt;br /&gt;
This part contains detailed description of LiveCD creation. I've removed the output of some&lt;br /&gt;
commands in order to simplify the reading.&lt;br /&gt;
&lt;br /&gt;
=== Creating booted LiveCD root filesystem ===&lt;br /&gt;
Create a directory, that will be our &amp;quot;workbench&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd ~&lt;br /&gt;
# mkdir workbench&lt;br /&gt;
# cd workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all we need some raw material - CentOS 4.4 LiveCD image:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/CentOS-4.4-i386-LiveCD.iso&lt;br /&gt;
# wget http://mirror.nsc.liu.se/CentOS/4.4/isos/i386/md5sum.livecd&lt;br /&gt;
# md5sum --check md5sum.livecd &lt;br /&gt;
CentOS-4.4-i386-LiveCD.iso: OK&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the contents of CD to the directory, where we will form the OpenVZ LiveCD filesystem.&lt;br /&gt;
I named this directory &amp;quot;ovz-livecd&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir ovz-livecd&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# mount -o loop -t iso9660 CentOS-4.4-i386-LiveCD.iso mount/&lt;br /&gt;
# cp -a mount/* ovz-livecd/&lt;br /&gt;
# umount mount&lt;br /&gt;
# rm -rf mount&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see, that &amp;lt;tt&amp;gt;ovz-livecd/base/&amp;lt;/tt&amp;gt; directory owns several *.mo files - images of squashfs filesystem,&lt;br /&gt;
and each image holds one directory of '''booted''' LiveCD root filesystem: &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;usr&amp;lt;/tt&amp;gt; and so on:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls -1 ovz-livecd/base&lt;br /&gt;
bin.mo etc.mo lib.mo root.mo sbin.mo usr.mo var.mo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to decompress these images we need &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt; tool. &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; source archive contains&lt;br /&gt;
patches for various kernel versions (to be able mount &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;), and user-space tools for compressing usual filesytem into &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; filesystem and for decompressing it back. Well, we don't need kernel patches right now (but we will need them later), we only want to install &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; user-space tools:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz&lt;br /&gt;
# tar xzf squashfs3.2-r2.tar.gz&lt;br /&gt;
# cd squashfs3.2-r2/squashfs-tools/&lt;br /&gt;
# make&lt;br /&gt;
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs&lt;br /&gt;
cc unsquashfs.o -lz -o unsquashfs&lt;br /&gt;
# cp mksquashfs /usr/bin/&lt;br /&gt;
# cp unsquashfs /usr/bin/&lt;br /&gt;
# cd ~/workbench&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Well, having the intruments in hand, why not extract the images? Create a directory, called &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt;,&lt;br /&gt;
that will store the root filesystem of '''booted''' LiveCD. I.e. it will contain &amp;lt;tt&amp;gt;/bin&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sbin&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc&amp;lt;/tt&amp;gt; and other directories, which you will see after booting the LiveCD. Unfortunately &amp;lt;tt&amp;gt;unsquashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
tool is not very convenient, and I found only this way to use it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir livecd-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/bin.mo &lt;br /&gt;
# mv squashfs-root/bin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/etc.mo &lt;br /&gt;
# mv squashfs-root/etc/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/lib.mo &lt;br /&gt;
# mv squashfs-root/lib/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/root.mo &lt;br /&gt;
# mv squashfs-root/root/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/sbin.mo &lt;br /&gt;
# mv squashfs-root/sbin/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/usr.mo    # this action takes some time, be patient ;)&lt;br /&gt;
# mv squashfs-root/usr/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&lt;br /&gt;
# unsquashfs ovz-livecd/base/var.mo&lt;br /&gt;
# mv squashfs-root/var/ livecd-root/&lt;br /&gt;
# rm -rf squashfs-root&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yet we have nearly complete root filesystem of '''booted''' LiveCD in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory. However some things&lt;br /&gt;
are missing, and I guess you know what are they: &amp;lt;tt&amp;gt;/dev&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/proc&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/sys&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;/tmp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/boot&amp;lt;/tt&amp;gt; directories. We need them, because some tools (&amp;lt;tt&amp;gt;rpm&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;, ...) will not work without them in chrooted environment later.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir root/dev&lt;br /&gt;
# cp -a /dev/* root/dev&lt;br /&gt;
# mkdir root/proc&lt;br /&gt;
# mount -t proc proc root/proc/&lt;br /&gt;
# mkdir root/sys&lt;br /&gt;
# mount -t sysfs sysfs root/sys/&lt;br /&gt;
# mkdir root/tmp&lt;br /&gt;
# mkdir root/boot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's it. We have '''booted''' LiveCD root filesystem in &amp;lt;tt&amp;gt;livecd-root&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
Now we can &amp;lt;tt&amp;gt;chroot&amp;lt;/tt&amp;gt; in this directory and install all needed packages. But what&lt;br /&gt;
packages do we need?&lt;br /&gt;
* OpenVZ kernels&lt;br /&gt;
* OpenVZ tools: vzctl, vzquota, vzpkg, vzrpm43, vzrpm44, vzyum&lt;br /&gt;
* OpenVZ template metadatas: centos-4, fc-3, fc4 and fc-5&lt;br /&gt;
* Some OpenVZ precreated templates&lt;br /&gt;
* Some CentOS tool updates: sqlite package&lt;br /&gt;
Tools and templates related packages can be simply downloaded and installed.&lt;br /&gt;
But it is not so easy with kernel. Usual OpenVZ kernel won't work: it doesn't&lt;br /&gt;
support &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;. The next chapter explains how to create RPM-package with&lt;br /&gt;
OpenVZ kernel, that supports &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building OpenVZ kernels ===&lt;br /&gt;
Let's consider, how to build &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt; OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support.&lt;br /&gt;
First  download and install OpenVZ source RPM:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget http://download.openvz.org/kernel/branches/2.6.18/028stab035.1/kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
# rpm -ivh kernel-2.6.18-ovz028stab035.1.src.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; sources contain the patch against &amp;lt;tt&amp;gt;2.6.18&amp;lt;/tt&amp;gt;. Let's copy this patch to RPM build directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp squashfs3.2-r2/kernel-patches/linux-2.6.18/squashfs3.2-patch /usr/src/redhat/SOURCES/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now we need to modify the spec-file (&amp;lt;tt&amp;gt;/usr/src/redhat/SPECS/kernel-ovz.spec&amp;lt;/tt&amp;gt;) in order to add &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch to build process. Below are the changes you should introduce in diff format.&lt;br /&gt;
The meaning of changes is transparent: firstly, do not build UP, enterprise and debug kernels (our LiveCD will be&lt;br /&gt;
based on SMP kernel) and secondly, apply &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; patch before compilation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- kernel-ovz.spec.orig        2007-06-09 11:40:15.000000000 +0400&lt;br /&gt;
+++ kernel-ovz.spec     2007-06-28 17:42:41.000000000 +0400&lt;br /&gt;
@@ -5,13 +5,13 @@ Summary: The Linux kernel (the core of t&lt;br /&gt;
&lt;br /&gt;
 # normal/debug/debuginfo&lt;br /&gt;
 %define buildnormal 1&lt;br /&gt;
-%define builddebug 1&lt;br /&gt;
+%define builddebug 0&lt;br /&gt;
 %define builddebuginfo 0&lt;br /&gt;
&lt;br /&gt;
 # kernels we want to build&lt;br /&gt;
-%define buildup 1&lt;br /&gt;
+%define buildup 0&lt;br /&gt;
 %define buildsmp 1&lt;br /&gt;
-%define buildenterprise 1&lt;br /&gt;
+%define buildenterprise 0&lt;br /&gt;
 %define buildentnosplit 0&lt;br /&gt;
&lt;br /&gt;
 # versions&lt;br /&gt;
@@ -161,6 +161,9 @@ Patch2104: linux-2.6.18-drbd-0.7.22-0.8.&lt;br /&gt;
 Patch2105: linux-2.6.18-drbd-8.0.0-8.0.2.patch&lt;br /&gt;
 Patch2106: linux-2.6.18-drbd-8.0.2-8.0.3.patch&lt;br /&gt;
&lt;br /&gt;
+# squashfs3.2-patch&lt;br /&gt;
+Patch2107: squashfs3.2-patch&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root&lt;br /&gt;
@@ -318,6 +321,8 @@ cd linux-%{kversion}&lt;br /&gt;
 %patch2105 -p1&lt;br /&gt;
 %patch2106 -p1&lt;br /&gt;
&lt;br /&gt;
+%patch2107 -p1&lt;br /&gt;
+&lt;br /&gt;
 # ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 mkdir configs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We need one more tiny hack in order RPM-build process to walk smoothly.&lt;br /&gt;
There are config files for various OpenVZ kernel flavours &lt;br /&gt;
in &amp;lt;tt&amp;gt;/usr/src/redhat/SOURCES&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/SOURCES/*.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686.config.ovz             /usr/src/redhat/SOURCES/kernel-2.6.18-ppc64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-enterprise.config.ovz  /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-i686-smp.config.ovz         /usr/src/redhat/SOURCES/kernel-2.6.18-x86_64-smp.config.ovz&lt;br /&gt;
/usr/src/redhat/SOURCES/kernel-2.6.18-ia64.config.ovz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''All''' these files should contain information about &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt;.&lt;br /&gt;
In fact, only two additional lines are necessary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I did it with the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd /usr/src/redhat/SOURCES/&lt;br /&gt;
# echo &amp;quot;CONFIG_SQUASHFS=m&lt;br /&gt;
&amp;gt; CONFIG_SQUASHFS_EMBEDDED=n&amp;quot; | tee -a *.config.ovz&lt;br /&gt;
CONFIG_SQUASHFS=m&lt;br /&gt;
CONFIG_SQUASHFS_EMBEDDED=n&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After all efforts, building the RPM-package is very easy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpmbuild --target=i686 -ba kernel-ovz.spec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with &amp;lt;tt&amp;gt;squashfs&amp;lt;/tt&amp;gt; support. Let's copy it to our local directory &amp;lt;tt&amp;gt;to_booted_livecd/kernels/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ls /usr/src/redhat/RPMS/i686/&lt;br /&gt;
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm&lt;br /&gt;
# mkdir -p to_booted_livecd/kernels&lt;br /&gt;
# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm to_booted_livecd/kernels/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,&lt;br /&gt;
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description&lt;br /&gt;
below are based on &amp;lt;tt&amp;gt;028stab035&amp;lt;/tt&amp;gt; kernel, that has been just build above.&lt;br /&gt;
&lt;br /&gt;
=== Unionfs kernel module ===&lt;br /&gt;
In most present-day LiveCDs &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem is used. This filesystem &amp;quot;can appear to merge the contents of several directories, while keeping their physical content separate&amp;quot;. For example, after the command&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you will see merged contents of &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt; directories in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
At that, &amp;lt;tt&amp;gt;cdrom&amp;lt;/tt&amp;gt; will be read-only. I.e. if you will write to some file in &amp;lt;tt&amp;gt;/union&amp;lt;/tt&amp;gt; directory, &lt;br /&gt;
that resides in &amp;lt;tt&amp;gt;/cdrom&amp;lt;/tt&amp;gt; in fact, this modified file will be automatically moved to &amp;lt;tt&amp;gt;/tmp/changes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Such useful property is logically used in LiveCDs: &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; merges cdrom contents (that is read-only)&lt;br /&gt;
and temporary in-memory filesystem.&lt;br /&gt;
In order to add support of &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; filesystem to OpenVZ kernel we need to compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt; kernel&lt;br /&gt;
module against used kernel. Download the sources of unionfs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz&lt;br /&gt;
# tar xzf unionfs-1.4.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because&lt;br /&gt;
this packages contents kernel headers, required for building kernel modules.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
Preparing...                ########################################### [100%]&lt;br /&gt;
   1:kernel-smp             ########################################### [100%]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now compile &amp;lt;tt&amp;gt;unionfs&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cd unionfs-1.4&lt;br /&gt;
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/&lt;br /&gt;
&amp;gt; TOPINC=-I$(LINUXSRC)/include&lt;br /&gt;
&amp;gt; MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' &amp;gt; fistdev.mk&lt;br /&gt;
# make&lt;br /&gt;
# ls unionfs.ko &lt;br /&gt;
unionfs.ko&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Later we will place &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to appropriate place in '''booted''' LiveCD filesystem.&lt;br /&gt;
At the moment copy it to local &amp;lt;tt&amp;gt;to_booted_livecd/unionfs-modules/2.6.18/&amp;lt;/tt&amp;gt; directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I repeat once again: if you want to use several kernels on LiveCD - the operation above should&lt;br /&gt;
be repeated for each wishful kernel.&lt;br /&gt;
&lt;br /&gt;
=== OpenVZ tools and templates. CentOS updates ===&lt;br /&gt;
We have now the kernel RPM-package. But we also need OpenVZ tools RPM-packages.&lt;br /&gt;
It is much easier with them: just download these packages from http://openvz.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/tools&lt;br /&gt;
# cd to_booted_livecd/tools/&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzctl/3.0.16/vzctl-lib-3.0.16-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/utils/vzquota/3.0.9/vzquota-3.0.9-1.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzpkg/2.7.0-18/vzpkg-2.7.0-18.noarch.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm43/current/vzrpm43-python-4.3.3-7_nonptl.6.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzrpm44/current/vzrpm44-python-4.4.1-22.5.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/utils/vzyum/current/vzyum-2.4.0-11.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../template-metadatas&lt;br /&gt;
# cd ../template-metadatas&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/centos-4/vztmpl-centos-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-3/vztmpl-fedora-core-3-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-4/vztmpl-fedora-core-4-2.0-2.i386.rpm&lt;br /&gt;
# wget http://download.openvz.org/template/metadata/fedora-core-5/vztmpl-fedora-core-5-2.0-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# mkdir ../precreated&lt;br /&gt;
# cd ../precreated&lt;br /&gt;
&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/centos-4-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz&lt;br /&gt;
# wget http://download.openvz.org/template/precreated/fedora-core-5-i386-minimal.tar.gz&lt;br /&gt;
&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you understand, you can add other precreated templates to LiveCD. The main thing here is that usual CD is &lt;br /&gt;
not rubber and precreated templates are rather big! ;)&lt;br /&gt;
&lt;br /&gt;
Centos 4.4 LiveCD has a serios problem: &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package is broken and consequently&lt;br /&gt;
&amp;lt;tt&amp;gt;yum&amp;lt;/tt&amp;gt; doesn't work. In order to fix this problem we need updated &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt; package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir to_booted_livecd/updates&lt;br /&gt;
# cd to_booted_livecd/updates&lt;br /&gt;
# wget http://centos.arcticnetwork.ca/4.5/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
# cd ~/workbench/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install all these finally ===&lt;br /&gt;
We have all components that will be on '''booted''' LiveCD ready. Let's install them&lt;br /&gt;
in &amp;lt;tt&amp;gt;chrooted&amp;lt;/tt&amp;gt; environment. But before uninstall &amp;lt;tt&amp;gt;lsctp-tools&amp;lt;/tt&amp;gt; package,&lt;br /&gt;
because these tools need kernel version prior to 2.6.10. Then update &amp;lt;tt&amp;gt;sqlite&amp;lt;/tt&amp;gt;&lt;br /&gt;
package. Also we need to remove some other packages in order to free some disk space:&lt;br /&gt;
I've removed &amp;lt;tt&amp;gt;openoffice.org&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gimp&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;dia&amp;lt;/tt&amp;gt;  related packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -r to_booted_livecd/ root/tmp/&lt;br /&gt;
# chroot root/&lt;br /&gt;
&lt;br /&gt;
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386&lt;br /&gt;
&lt;br /&gt;
# rpm -e openoffice.org-libs openoffice.org&lt;br /&gt;
# rpm -e gimp-data-extras xsane-gimp gimp-print-plugin gimp-print-utils&lt;br /&gt;
# rpm -e gimp gimp-print gimp-help gimp-gap&lt;br /&gt;
# rpm -e dia&lt;br /&gt;
# rpm -e planner&lt;br /&gt;
# rpm -e gnome-games&lt;br /&gt;
# rpm -e tetex-latex jadetex xmltex passivetex&lt;br /&gt;
# rpm -e tetex&lt;br /&gt;
# rpm -e tetex-afm tetex-dvips-2.0.2-22.EL4.7 tetex-fonts-2.0.2-22.EL4.7 tetex-xdvi-2.0.2-22.EL4.7&lt;br /&gt;
# rpm -e k3b&lt;br /&gt;
# rpm -e foomatic Omni Omni-foomatic system-config-printer \&lt;br /&gt;
system-config-printer-gui hal-cups-utils desktop-printing&lt;br /&gt;
&lt;br /&gt;
# cd /tmp/to_booted_livecd/&lt;br /&gt;
&lt;br /&gt;
# rpm -Uvh updates/sqlite-3.3.6-2.i386.rpm&lt;br /&gt;
&lt;br /&gt;
# rpm -ivh kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm &lt;br /&gt;
# rpm -ivh tools/*.rpm&lt;br /&gt;
# rpm -ivh template-metadatas/*.rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy precreated templates to appropriate place:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp  precreated/* /vz/template/cache/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Add &amp;lt;tt&amp;gt;unionfs.ko&amp;lt;/tt&amp;gt; to other kernel modules and run &amp;lt;tt&amp;gt;depmod&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs&lt;br /&gt;
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/&lt;br /&gt;
# depmod 2.6.18-ovz028stab035.1-smp&lt;br /&gt;
# exit&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Booted''' LiveCD filesystem is ready, congratulations!&lt;br /&gt;
&lt;br /&gt;
=== Compressing '''booted''' LiveCD filesystem ===&lt;br /&gt;
Since &amp;lt;tt&amp;gt;mksquashfs&amp;lt;/tt&amp;gt; tool is already installed we can simply use it to create&lt;br /&gt;
&amp;lt;tt&amp;gt;*.mo&amp;lt;/tt&amp;gt; files: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# rm -f ovz-livecd/base/*.mo&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory         # it can take long...&lt;br /&gt;
# mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory&lt;br /&gt;
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Vmlinux, initrd and isolinux.cfg ===&lt;br /&gt;
The next step is to force &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; (cdrom boot loader) to boot OpenVZ kernel.&lt;br /&gt;
First, copy kernel image to OpenVZ CD:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modify initrd image. More precisely, we just need to add OpenVZ kernel modules there:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir initrd.d&lt;br /&gt;
# cp ovz-livecd/boot/initrd.gz initrd.d/&lt;br /&gt;
# cd initrd.d/&lt;br /&gt;
# mkdir mount&lt;br /&gt;
# gunzip initrd.gz &lt;br /&gt;
# mount -o loop initrd mount/&lt;br /&gt;
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/&lt;br /&gt;
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build                 # we don't neet it on initrd image&lt;br /&gt;
# sync&lt;br /&gt;
# umount mount/&lt;br /&gt;
# gzip initrd&lt;br /&gt;
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz&lt;br /&gt;
# cd ..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we should modify &amp;lt;tt&amp;gt;ovz-livecd/isolinux.cfg&amp;lt;/tt&amp;gt; file, that controls &amp;lt;tt&amp;gt;isolinux&amp;lt;/tt&amp;gt; boot loader.&lt;br /&gt;
We inform boot loader, that new kernel was added by introducing the following changes (in diff format):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--- ovz-livecd/isolinux.cfg.orig        2006-08-19 08:53:09.000000000 +0400&lt;br /&gt;
+++ ovz-livecd/isolinux.cfg     2007-06-29 18:22:29.000000000 +0400&lt;br /&gt;
@@ -1,5 +1,5 @@&lt;br /&gt;
 display boot/splash.cfg&lt;br /&gt;
-default linux&lt;br /&gt;
+default ovz-2.6.18&lt;br /&gt;
 prompt 1&lt;br /&gt;
 timeout 300&lt;br /&gt;
 F1 boot/help1.txt&lt;br /&gt;
@@ -11,5 +11,9 @@ label linux&lt;br /&gt;
 kernel boot/vmlinuz&lt;br /&gt;
 append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
 &lt;br /&gt;
+label ovz-2.6.18 &lt;br /&gt;
+kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp&lt;br /&gt;
+append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=40000 root=/dev/ram0 rw rhgb quiet&lt;br /&gt;
+&lt;br /&gt;
 label memtest&lt;br /&gt;
 kernel boot/memtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating ISO ===&lt;br /&gt;
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.&lt;br /&gt;
Using this sctipt, it is very easy to create iso:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging LiveCD ==&lt;br /&gt;
If you have trouble with created OpenVZ LiveCD, boot the kernel with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vga=0 debug&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
command line options. It will help you to diagnose the problem more precisely.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://centos.org Official CentOS community website]&lt;br /&gt;
* [http://kernel.org Linux kernel website]&lt;br /&gt;
* [http://redhat.com RedHat Inc. website]&lt;br /&gt;
* [http://squashfs.sourceforge.net/ squashfs website]&lt;br /&gt;
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]&lt;/div&gt;</summary>
		<author><name>Vass</name></author>
		
	</entry>
</feed>