Editing Creating OpenVZ LiveCD
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
integrating OpenVZ in one of its special releases. The article starts from | integrating OpenVZ in one of its special releases. The article starts from | ||
conceptual actions required to create OpenVZ LiveCD and then step-by-step | conceptual actions required to create OpenVZ LiveCD and then step-by-step | ||
− | describes technical aspects | + | describes technical aspects. |
− | |||
− | |||
− | |||
− | |||
== Concepts == | == Concepts == | ||
+ | |||
# Download KNOPPIX iso and get access to its content | # Download KNOPPIX iso and get access to its content | ||
# Extract KNOPPIX compressed image | # Extract KNOPPIX compressed image | ||
− | # | + | # Create OpenVZ Debian package and some other kernel-related packages |
− | # Uninstall | + | # Uninstall old Linux kernel and related packages from extracted tree and |
− | # | + | # install OpenVZ kernel 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 | # Compress the tree | ||
− | # | + | # Copy required kernel modules in appropriate places on the disc |
− | |||
− | |||
# Create new ISO image | # Create new ISO image | ||
Line 38: | Line 36: | ||
wget ftp://ftp.chg.ru/pub/Linux/knoppix/KNOPPIX_V5.1.1CD-2007-01-04-EN.iso | wget ftp://ftp.chg.ru/pub/Linux/knoppix/KNOPPIX_V5.1.1CD-2007-01-04-EN.iso | ||
</pre> | </pre> | ||
− | + | Let's copy contents of iso to to hard drive: | |
− | Let's copy contents of | ||
<pre> | <pre> | ||
mkdir mnt | mkdir mnt | ||
Line 46: | Line 43: | ||
cp -a mnt/* cd-contents/ | cp -a mnt/* cd-contents/ | ||
umount mnt | umount mnt | ||
− | rm - | + | rm -f mnt |
</pre> | </pre> | ||
− | |||
When you're booted in KNOPPIX LiveCD you can observe a lot of files and use | When you're booted in KNOPPIX LiveCD you can observe a lot of files and use | ||
− | + | variouse applications. On CD all this information is stored in one file: | |
<pre> | <pre> | ||
ls -lh cd-contents/KNOPPIX/KNOPPIX | ls -lh cd-contents/KNOPPIX/KNOPPIX | ||
-rw-r--r-- 1 vass vass 691M Jan 4 03:50 cd-contents/KNOPPIX/KNOPPIX | -rw-r--r-- 1 vass vass 691M Jan 4 03:50 cd-contents/KNOPPIX/KNOPPIX | ||
</pre> | </pre> | ||
− | |||
As you can see its size is 691M, but after uncompressing it'll be | 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: | approximately 2Gb. In order to uncompress this file we need special tools: | ||
Line 68: | Line 63: | ||
cd .. | cd .. | ||
</pre> | </pre> | ||
− | |||
After we have extract_compressed_fs tool in hand, let's extract KNOPPIX image: | After we have extract_compressed_fs tool in hand, let's extract KNOPPIX image: | ||
<pre> | <pre> | ||
Line 75: | Line 69: | ||
-rw-rw-r-- 1 vass vass 2.0G Apr 12 17:38 KNOPPIX.img | -rw-rw-r-- 1 vass vass 2.0G Apr 12 17:38 KNOPPIX.img | ||
</pre> | </pre> | ||
− | + | KNOPPIX.img file can be mounted using usual '-o loop' option. Next our step is to create a copy of file system tree on hard drive. | |
− | KNOPPIX.img file can be mounted using usual '-o loop' option. | + | Note, that we can't use 'cp' tool here, because of hardlinks and special files. We need to use rsynс: |
− | Next our step is to create a copy of | ||
− | Note, that we can't use 'cp' tool here, because of hardlinks and special files. | ||
− | We | ||
<pre> | <pre> | ||
mkdir mnt | mkdir mnt | ||
Line 88: | Line 79: | ||
rm -r mnt | rm -r mnt | ||
</pre> | </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 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 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: | |
− | 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 | ||
− | 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> | <pre> | ||
mkdir ovz-kernel | mkdir ovz-kernel | ||
Line 102: | Line 91: | ||
patch -p1 -d linux-2.6.18 < diff-ubc-mm-null-pointer-for-kthread-20070406 | 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 | mv linux-2.6.18 linux-2.6.18-8.el5-028test027 | ||
− | vim linux-2.6.18-8.el5-028test027/Makefile | + | vim linux-2.6.18-8.el5-028test027/Makefile # here we add right release: -8.el5-028test027 |
− | cp | + | cp kernel-2.6.18-i686.config.ovz linux-2.6.18/.config |
− | |||
− | |||
− | |||
make-kpkg --revision=.1 kernel_image | make-kpkg --revision=.1 kernel_image | ||
− | |||
cd .. | cd .. | ||
</pre> | </pre> | ||
− | |||
If everything went smoothly, in the top directory we'll be able to see linux-image file: | If everything went smoothly, in the top directory we'll be able to see linux-image file: | ||
<pre> | <pre> | ||
Line 117: | Line 101: | ||
-rw-r--r-- 1 vass vass 13364308 Apr 16 11:06 linux-image-2.6.18-8.el5-028stab027_.1_i386.deb | -rw-r--r-- 1 vass vass 13364308 Apr 16 11:06 linux-image-2.6.18-8.el5-028stab027_.1_i386.deb | ||
</pre> | </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. | |
− | Don't delete sources and compilation of this kernel. | + | Now I download vzctl and vzquota Debian packages from http://debian.systs.org and on template: |
− | 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 | ||
<pre> | <pre> | ||
wget http://debian.systs.org/debian/pool/openvz/v/vzctl/vzctl_3.0.16-1dso2~sarge0_i386.deb | wget http://debian.systs.org/debian/pool/openvz/v/vzctl/vzctl_3.0.16-1dso2~sarge0_i386.deb | ||
Line 126: | Line 108: | ||
wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz | wget http://download.openvz.org/template/precreated/debian-3.1-i386-minimal.tar.gz | ||
</pre> | </pre> | ||
− | + | Now copy packages to KNOPPIX tree and chroot there: | |
− | |||
<pre> | <pre> | ||
cp linux-image-2.6.18-8.el5-028stab027_.1_i386.deb KNOPPIX-content/root | cp linux-image-2.6.18-8.el5-028stab027_.1_i386.deb KNOPPIX-content/root | ||
Line 138: | Line 119: | ||
cd /root | cd /root | ||
</pre> | </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 easily | |
− | In chrooted environment we need to remove all kernel related packages. | + | identify all kernel-related packages and eliminate them using this knowledge: |
− | In KNOPPIX 5.1.1 2.6.19 vanilla kernel is used, so we can easily identify | ||
− | all kernel-related packages and eliminate them using this knowledge: | ||
<pre> | <pre> | ||
dpkg-query --list | grep 2.6.19 | dpkg-query --list | grep 2.6.19 | ||
Line 150: | Line 129: | ||
apt-get remove rt2x00-cvs-modules-2.6.19 | apt-get remove rt2x00-cvs-modules-2.6.19 | ||
apt-get remove loop-aes-modules-2.6.19 | apt-get remove loop-aes-modules-2.6.19 | ||
− | apt-get remove | + | apt-get remove linuxt-image-2.6.19 |
</pre> | </pre> | ||
− | + | And now install new tools (don't be afraid about warnings: they are ok) | |
− | |||
<pre> | <pre> | ||
apt-get install linux-image-2.6.18-8.el5-028stab027_.1_i386.deb | apt-get install linux-image-2.6.18-8.el5-028stab027_.1_i386.deb | ||
Line 160: | Line 138: | ||
mv debian-3.1-i386-minimal.tar.gz /var/lib/vz/template/cache/ | mv debian-3.1-i386-minimal.tar.gz /var/lib/vz/template/cache/ | ||
</pre> | </pre> | ||
− | + | [TODO: remove other packages to free disk space] | |
− | + | Cleaning all up: | |
− | |||
− | |||
− | |||
<pre> | <pre> | ||
umount /proc | umount /proc | ||
Line 171: | Line 146: | ||
exit | exit | ||
</pre> | </pre> | ||
− | + | That's greate, now we have all the tree ready, let's compress it in new image using create_compressed_fs tool: | |
− | That's | ||
− | let's compress it in | ||
− | |||
<pre> | <pre> | ||
mkisofs -R -iso-level 4 -force-rr -J ./KNOPPIX-content-modif/ > KNOPPIX-modif.img | 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 | ./cloop-2.05/create_compressed_fs KNOPPIX-modif.img 65536 > KNOPPIX-modif | ||
− | |||
</pre> | </pre> | ||
− | + | Now we need to compile aufs and cloop kernel modules for our new kernel. Let's start from cloop module. | |
− | + | We uncomment one definition in source, because we're using RHEL-based kernel. The patch below shows what to do: | |
− | Let's start from cloop module. | ||
− | because we're using RHEL-based kernel. The patch below shows what to do: | ||
<pre> | <pre> | ||
--- cloop-2.05/compressed_loop.c.rh 2006-10-13 23:39:41.000000000 +0400 | --- cloop-2.05/compressed_loop.c.rh 2006-10-13 23:39:41.000000000 +0400 | ||
Line 197: | Line 166: | ||
#include <linux/version.h> | #include <linux/version.h> | ||
</pre> | </pre> | ||
− | + | OK, let's compile cloop | |
− | |||
<pre> | <pre> | ||
wget http://debian-knoppix.alioth.debian.org/sources/cloop_2.05-1.tar.gz | wget http://debian-knoppix.alioth.debian.org/sources/cloop_2.05-1.tar.gz | ||
tar xzf cloop_2.05-1.tar.gz | tar xzf cloop_2.05-1.tar.gz | ||
cd cloop-2.05/ | cd cloop-2.05/ | ||
− | vim compressed_loop.c | + | vim compressed_loop.c # uncommenting define here |
make KERNEL_DIR=../linux-2.6.18-8.el5-028stab027/ module | make KERNEL_DIR=../linux-2.6.18-8.el5-028stab027/ module | ||
</pre> | </pre> | ||
− | + | After that you should have cloop.ko file in current directory. Later we copy it to appropriate place. | |
− | After that you should have cloop.ko file in current directory. Later we | + | What about aufs? Get this module from cvs. I use this version (20061113), because this version is used in KNOPPIX 5.1.1. |
− | What about aufs? Get | + | The following changes are required in AUFS, because we use rhel5-based kernel: |
− | The following changes are required in | ||
<pre> | <pre> | ||
--- aufs/fs/aufs/cpup.c.orig 2006-10-23 12:58:33.000000000 +0000 | --- aufs/fs/aufs/cpup.c.orig 2006-10-23 12:58:33.000000000 +0000 | ||
Line 246: | Line 213: | ||
ino_t ino; | ino_t ino; | ||
</pre> | </pre> | ||
− | + | TODO: (FOR NEWER AUFS ONE MORE PATCH with "(deleted)" | |
+ | <pre> | ||
+ | </pre> | ||
<pre> | <pre> | ||
cvs -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs login | 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 | cvs -z3 -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs co -D20061113 aufs | ||
cd aufs | cd aufs | ||
− | |||
− | |||
− | |||
make KDIR=../../linux-2.6.18-8.el5-028stab027/ -f local.mk | make KDIR=../../linux-2.6.18-8.el5-028stab027/ -f local.mk | ||
</pre> | </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 PART. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Result == | == Result == | ||
− | |||
== Links == | == Links == | ||
Line 334: | Line 233: | ||
# http://www.knoppix.net/wiki/Knoppix_Remastering_Howto | # http://www.knoppix.net/wiki/Knoppix_Remastering_Howto | ||
# http://debian.systs.org/ | # http://debian.systs.org/ | ||
− | |||
− | |||
− | |||
− |