Open main menu

OpenVZ Virtuozzo Containers Wiki β

Changes

Creating OpenVZ LiveCD

685 bytes added, 07:25, 17 April 2007
Revision of 1st part
integrating OpenVZ in one of its special releases. The article starts from
conceptual actions required to create OpenVZ LiveCD and then step-by-step
describes technical aspects. I want to note, that technical aspects depend a biton certain version of kernel, aufs and cloop you're using. For example some smallchanges in code (functions argument type change and alike) are necessary. I usedaufs-20061113 and cloop-2.05-1 because these versions were used on in KNOPPIX 5.1.1.2.6.18-8.el5-028stab027 OpenVZ kernel was used.
== Concepts ==
 
# Download KNOPPIX iso and get access to its content
# Extract KNOPPIX compressed image
# Create Somehow obtain OpenVZ Debian package packages: kernel, vzctl, vzquota and some other kernel-related packagestemplate# Uninstall old previous Linux kernel and related packages from extracted tree and# install Install OpenVZ kernel Debian packages there# Uninstall some packages from extracted tree in order to free some space for# the next step# Install vzctl/vzquota/templates in the tree
# Compress the tree
# Build aufs and cloop kernel modules against OpenVZ kernel# Copy required kernel these modules in appropriate places on the disc# Modify initrd image of KNOPPIX
# Create new ISO image
wget ftp://ftp.chg.ru/pub/Linux/knoppix/KNOPPIX_V5.1.1CD-2007-01-04-EN.iso
</pre>
 Let's copy contents of this iso to to the hard drive:
<pre>
mkdir mnt
cp -a mnt/* cd-contents/
umount mnt
rm -f r mnt
</pre>
 
When you're booted in KNOPPIX LiveCD you can observe a lot of files and use
variouse various applications. On CD all this information is stored in one a single file:
<pre>
ls -lh cd-contents/KNOPPIX/KNOPPIX
-rw-r--r-- 1 vass vass 691M Jan 4 03:50 cd-contents/KNOPPIX/KNOPPIX
</pre>
 
As you can see its size is 691M, but after uncompressing it'll be
approximately 2Gb. In order to uncompress this file we need special tools:
cd ..
</pre>
 
After we have extract_compressed_fs tool in hand, let's extract KNOPPIX image:
<pre>
-rw-rw-r-- 1 vass vass 2.0G Apr 12 17:38 KNOPPIX.img
</pre>
 KNOPPIX.img file can be mounted using usual '-o loop' option. Next our step is to create a copy of KNOPPIX file system tree on the hard drivedisk.Note, that we can't use 'cp' tool here, because of hardlinks and special files. We need to should use rsynс:
<pre>
mkdir mnt
rm -r mnt
</pre>
 Now we should set up OpenVZ environment in obtained tree: kernel, vzctl, vzquota, template. For vzctl and vzquota we can use precompiled packages from http://debian.systs.org. But at the moment we have to create kernel Debian package by self, because at the moment we need additional patches in order all to work smoothly (but this it will be unnecessary soon, when patches will be included in main OpenVZ patch). I created a Debian VE on my machine and install there kernel-package package, that allows to create Debian kernel packages easily. After that the creation of package is something like that:
<pre>
mkdir ovz-kernel
patch -p1 -d linux-2.6.18 < diff-ubc-mm-null-pointer-for-kthread-20070406
mv linux-2.6.18 linux-2.6.18-8.el5-028test027
vim linux-2.6.18-8.el5-028test027/Makefile # here we add right releaseextraversion: -8.el5-028test027
cp kernel-2.6.18-i686.config.ovz linux-2.6.18/.config
make-kpkg --revision=.1 kernel_image
cd ..
</pre>
 
If everything went smoothly, in the top directory we'll be able to see linux-image file:
<pre>
-rw-r--r-- 1 vass vass 13364308 Apr 16 11:06 linux-image-2.6.18-8.el5-028stab027_.1_i386.deb
</pre>
 Don't delete sources and compilation of this kernel. A bit later we'll need to build aufs and cloop kernel modules against this kernel.Now I download vzctl and vzquota Debian packages from http://debian.systs.org and on a template:
<pre>
wget http://debian.systs.org/debian/pool/openvz/v/vzctl/vzctl_3.0.16-1dso2~sarge0_i386.deb
wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz
</pre>
Now copy Copying packages to KNOPPIX tree and chroot there:
<pre>
cp linux-image-2.6.18-8.el5-028stab027_.1_i386.deb KNOPPIX-content/root
cd /root
</pre>
 In chrooted environment we need to remove all kernel related packages. In KNOPPIX 5.1.1 2.6.19 vanilla kernel is used, so we can easilyidentifyidentify all kernel-related packages and eliminate them using this knowledge:
<pre>
dpkg-query --list | grep 2.6.19
apt-get remove rt2x00-cvs-modules-2.6.19
apt-get remove loop-aes-modules-2.6.19
apt-get remove linuxtlinux-image-2.6.19
</pre>
And now install new Installing OpenVZ tools (don't be afraid about warnings: they are ok)
<pre>
apt-get install linux-image-2.6.18-8.el5-028stab027_.1_i386.deb
mv debian-3.1-i386-minimal.tar.gz /var/lib/vz/template/cache/
</pre>
[TODO: remove other Here I want to note one thing. We added some data to the KNOPPIX image,so its size increased. If you want to burn iso on CD/DVD later you shouldthink of removing some packages to free disk space]. I miss this point, but you're aware.Cleaning After all we need to clean upchrooted environment:
<pre>
umount /proc
exit
</pre>
 That's greategreat, now we have all the tree ready, let's compress it in the new image using create_compressed_fs tool:
<pre>
mkisofs -R -iso-level 4 -force-rr -J ./KNOPPIX-content-modif/ > KNOPPIX-modif.img
./cloop-2.05/create_compressed_fs KNOPPIX-modif.img 65536 > KNOPPIX-modif
</pre>
Now we need The next our step is to compile aufs and cloop kernel modules for our new against OpenVZ kernel. Let's start from cloop module.We uncomment one A definition in sourcemust be commented, because we're using RHEL-based kernel. The patch below shows what to do:
<pre>
--- cloop-2.05/compressed_loop.c.rh 2006-10-13 23:39:41.000000000 +0400
#include <linux/version.h>
</pre>
OKGetting the sources, let's compile cloopbuilding:
<pre>
wget http://debian-knoppix.alioth.debian.org/sources/cloop_2.05-1.tar.gz
tar xzf cloop_2.05-1.tar.gz
cd cloop-2.05/
vim compressed_loop.c # uncommenting define here
make KERNEL_DIR=../linux-2.6.18-8.el5-028stab027/ module
</pre>
 After that you should have cloop.ko file in current directory. Later we will copy it to appropriate place.What about aufs? Get this module the sources from cvs. I use this used 20061113 version (20061113), because this version is used in KNOPPIX 5.1.1.The following changes are required in AUFSaufs, because we use 're using rhel5-based kernel:
<pre>
--- aufs/fs/aufs/cpup.c.orig 2006-10-23 12:58:33.000000000 +0000
ino_t ino;
</pre>
TODOBuilding aufs: (FOR NEWER AUFS ONE MORE PATCH with "(deleted)"<pre></pre>
<pre>
cvs -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs login
cvs -z3 -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs co -D20061113 aufs
cd aufs
vim fs/aufs/cpup.c #
vim fs/aufs/dir.c # Introducing required changes
vim fs/aufs/vdir.c #
make KDIR=../../linux-2.6.18-8.el5-028stab027/ -f local.mk
</pre>
After this step you have an aufs.ko file in current directory.
Next step is too create add this (and some other) modules to initrd. It'll be tomorrow ;)
[TODO] CREATE GOOD CONTENTS TABLE OF THIS PARTNow you have an aufs.ko file in current directory. Next we need to add these modules to the disc. 
== Result ==
172
edits