Changes

Jump to: navigation, search

Creating OpenVZ LiveCD based on Centos 4.4

2,267 bytes added, 11:51, 29 June 2007
information about unionfs compilation added
# rpmbuild --target=i686 -ba kernel-ovz.spec
</pre>
If everything goes smoothly, in several tens of minutes depending on the power of your node you willl have OpenVZ kernel RPM-package with <tt>squashfs</tt> support. Let's copy it to our local directory <tt>rpmsto_booted_livecd/kernels/</tt>:
<pre>
# ls /usr/src/redhat/RPMS/i686/
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm
# mkdir -p rpmsto_booted_livecd/kernels# cp /usr/src/redhat/RPMS/i686/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm rpmsto_booted_livecd/kernels/
</pre>
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels,
=== Unionfs kernel module ===
In most present-day LiveCDs <tt>unionfs</tt> filesystem is used. This filesystem "can appear to merge the contents of several directories, while keeping their physical content separate". For example, after the command
<pre>
# mount -t unionfs -o dirs=/tmp/changes=rw:/cdrom=ro unionfs /union
</pre>
you will see merged contents of <tt>/cdrom</tt> and <tt>/tmp/changes</tt> directories in <tt>/union</tt> directory.
At that, <tt>cdrom</tt> will be read-only. I.e. if you will write to some file in <tt>/union</tt> directory,
that resides in <tt>/cdrom</tt> in fact, this modified file will be automatically moved to <tt>/tmp/changes</tt>.
Such useful property is logically used in LiveCDs: <tt>unionfs</tt> merges cdrom contents (that is read-only)
and temporary in-memory filesystem.
In order to add support of <tt>unionfs</tt> filesystem to OpenVZ kernel we need to compile <tt>unionfs</tt> kernel
module against used kernel. Download the sources of unionfs:
<pre>
# wget ftp://ftp.filesystems.org/pub/unionfs/unionfs-1.x/unionfs-1.4.tar.gz
# tar xzf unionfs-1.4.tar.gz
</pre>
In previous chapter we have created an RPM-package with OpenVZ kernel. We should install it: because
this packages contents kernel headers, required for building kernel modules.
<pre>
# rpm -ivh to_booted_livecd/kernels/kernel-smp-2.6.18-ovz028stab035.1.i686.rpm
Preparing... ########################################### [100%]
1:kernel-smp ########################################### [100%]
</pre>
Now compile <tt>unionfs</tt>:
<pre>
# cd unionfs-1.4
# echo 'LINUXSRC=/lib/modules/2.6.18-ovz028stab035.1-smp/build/
> TOPINC=-I$(LINUXSRC)/include
> MODDIR=/lib/modules/2.6.18-ovz028stab035.1-smp/' > fistdev.mk
# make
# ls unionfs.ko
unionfs.ko
# cd ..
</pre>
Later we will place <tt>unionfs.ko</tt> to appropriate place in '''booted''' LiveCD filesystem.
At the moment copy it to local <tt>to_booted_livecd/unionfs-modules/2.6.18/</tt> directory:
<pre>
# mkdir -p to_booted_livecd/unionfs-modules/2.6.18/
# cp unionfs-1.4/unionfs.ko to_booted_livecd/unionfs-modules/2.6.18/
</pre>
I repeat once again: if you want to use several kernels on LiveCD - the operation above should
be repeated for each wishful kernel.
=== Installing RPMs ===
We have the RPM package for the kernel. But we also need
<pre>
 </pre>
To be continued...
172
edits

Navigation menu