Editing Creating OpenVZ LiveCD based on Centos 4.4
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 28: | Line 28: | ||
This part contains detailed description of LiveCD creation. I've removed the output of some | This part contains detailed description of LiveCD creation. I've removed the output of some | ||
commands in order to simplify the reading. | commands in order to simplify the reading. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Creating booted LiveCD root filesystem === | === Creating booted LiveCD root filesystem === | ||
Line 74: | Line 64: | ||
In order to decompress these images we need <tt>unsquashfs</tt> tool. <tt>squashfs</tt> source archive contains | In order to decompress these images we need <tt>unsquashfs</tt> tool. <tt>squashfs</tt> source archive contains | ||
− | patches for various kernel versions (to be able | + | patches for various kernel versions (to be able mount <tt>squashfs</tt>), and user-space tools for compressing usual filesytem into <tt>squashfs</tt> 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 <tt>squashfs</tt> user-space tools: |
− | |||
− | |||
<pre> | <pre> | ||
− | # wget | + | # wget wget http://switch.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# tar xzf squashfs3.2-r2.tar.gz | # tar xzf squashfs3.2-r2.tar.gz | ||
# cd squashfs3.2-r2/squashfs-tools/ | # cd squashfs3.2-r2/squashfs-tools/ | ||
Line 92: | Line 72: | ||
cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs | cc mksquashfs.o read_fs.o sort.o -lz -lpthread -lm -o mksquashfs | ||
cc unsquashfs.o -lz -o unsquashfs | cc unsquashfs.o -lz -o unsquashfs | ||
+ | # cp mksquashfs /usr/bin/ | ||
# cp unsquashfs /usr/bin/ | # cp unsquashfs /usr/bin/ | ||
− | # cd | + | # cd ~/workbench |
</pre> | </pre> | ||
Well, having the intruments in hand, why not extract the images? Create a directory, called <tt>livecd-root</tt>, | Well, having the intruments in hand, why not extract the images? Create a directory, called <tt>livecd-root</tt>, | ||
Line 102: | Line 83: | ||
# mkdir livecd-root | # mkdir livecd-root | ||
− | # | + | # unsquashfs ovz-livecd/base/bin.mo |
− | + | # mv squashfs-root/bin/ livecd-root/ | |
− | + | # rm -rf squashfs-root | |
− | + | ||
− | + | # unsquashfs ovz-livecd/base/etc.mo | |
− | + | # mv squashfs-root/etc/ livecd-root/ | |
+ | # rm -rf squashfs-root | ||
+ | |||
+ | # unsquashfs ovz-livecd/base/lib.mo | ||
+ | # mv squashfs-root/lib/ livecd-root/ | ||
+ | # rm -rf squashfs-root | ||
+ | |||
+ | # unsquashfs ovz-livecd/base/root.mo | ||
+ | # mv squashfs-root/root/ livecd-root/ | ||
+ | # rm -rf squashfs-root | ||
+ | |||
+ | # unsquashfs ovz-livecd/base/sbin.mo | ||
+ | # mv squashfs-root/sbin/ livecd-root/ | ||
+ | # rm -rf squashfs-root | ||
− | + | # unsquashfs ovz-livecd/base/usr.mo # this action takes some time, be patient ;) | |
+ | # mv squashfs-root/usr/ livecd-root/ | ||
+ | # rm -rf squashfs-root | ||
+ | # unsquashfs ovz-livecd/base/var.mo | ||
+ | # mv squashfs-root/var/ livecd-root/ | ||
+ | # rm -rf squashfs-root | ||
+ | </pre> | ||
Yet we have nearly complete root filesystem of '''booted''' LiveCD in <tt>livecd-root</tt> directory. However some things | Yet we have nearly complete root filesystem of '''booted''' LiveCD in <tt>livecd-root</tt> directory. However some things | ||
are missing, and I guess you know what are they: <tt>/dev</tt>, <tt>/proc</tt>, <tt>/sys</tt>, <tt>/tmp</tt> and <tt>/boot</tt> directories. We need them, because some tools (<tt>rpm</tt>, <tt>bash</tt>, ...) will not work without them in chrooted environment later. | are missing, and I guess you know what are they: <tt>/dev</tt>, <tt>/proc</tt>, <tt>/sys</tt>, <tt>/tmp</tt> and <tt>/boot</tt> directories. We need them, because some tools (<tt>rpm</tt>, <tt>bash</tt>, ...) will not work without them in chrooted environment later. | ||
<pre> | <pre> | ||
− | # | + | # mkdir root/dev |
− | + | # cp -a /dev/* root/dev | |
− | # cp -a /dev/* dev | + | # mkdir root/proc |
− | # mkdir proc | + | # mount -t proc proc root/proc/ |
− | # mount -t proc proc proc/ | + | # mkdir root/sys |
− | # mkdir sys | + | # mount -t sysfs sysfs root/sys/ |
− | # mount -t sysfs sysfs sys/ | + | # mkdir root/tmp |
− | # mkdir tmp | + | # mkdir root/boot |
− | # mkdir boot | ||
− | |||
</pre> | </pre> | ||
− | That's it. We have ''' | + | That's it. We have '''booted''' LiveCD root filesystem in <tt>livecd-root</tt> directory. |
Now we can <tt>chroot</tt> in this directory and install all needed packages. But what | Now we can <tt>chroot</tt> in this directory and install all needed packages. But what | ||
packages do we need? | packages do we need? | ||
Line 216: | Line 214: | ||
CONFIG_SQUASHFS=m | CONFIG_SQUASHFS=m | ||
CONFIG_SQUASHFS_EMBEDDED=n | CONFIG_SQUASHFS_EMBEDDED=n | ||
+ | # cd ~/workbench/ | ||
</pre> | </pre> | ||
After all efforts, building the RPM-package is very easy: | After all efforts, building the RPM-package is very easy: | ||
<pre> | <pre> | ||
− | |||
# rpmbuild --target=i686 -ba kernel-ovz.spec | # rpmbuild --target=i686 -ba kernel-ovz.spec | ||
</pre> | </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>to_booted_livecd/kernels/</tt>: | 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>to_booted_livecd/kernels/</tt>: | ||
<pre> | <pre> | ||
− | |||
# ls /usr/src/redhat/RPMS/i686/ | # ls /usr/src/redhat/RPMS/i686/ | ||
kernel-smp-2.6.18-ovz028stab035.1.i686.rpm | kernel-smp-2.6.18-ovz028stab035.1.i686.rpm | ||
Line 232: | Line 229: | ||
OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels, | OpenVZ LiveCD supports several kernels. So, the actions mentioned above should be accomplished to all kernels, | ||
that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description | that you need on LiveCD. In this article I skip the description of building RPMS for all kernels. All description | ||
− | below are based on <tt>028stab035</tt> kernel, that has been just build above | + | below are based on <tt>028stab035</tt> kernel, that has been just build above. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Unionfs kernel module === | === Unionfs kernel module === | ||
Line 343: | Line 325: | ||
because these tools need kernel version prior to 2.6.10. Then update <tt>sqlite</tt> | because these tools need kernel version prior to 2.6.10. Then update <tt>sqlite</tt> | ||
package. Also we need to remove some other packages in order to free some disk space: | package. Also we need to remove some other packages in order to free some disk space: | ||
− | I've removed <tt>openoffice.org | + | I've removed <tt>openoffice.org</tt> and related packages: |
− | |||
<pre> | <pre> | ||
− | # cp -r to_booted_livecd/ | + | # cp -r to_booted_livecd/ root/tmp/ |
− | # chroot | + | # chroot root/ |
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386 | # rpm -e lksctp-tools-1.0.2-6.4E.1.i386 | ||
− | + | # rpm -e openoffice.org-libs-1.1.5-4.6.0.EL4 openoffice.org-1.1.5-4.6.0.EL4 | |
− | # rpm -e openoffice.org-libs openoffice.org | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# cd /tmp/to_booted_livecd/ | # cd /tmp/to_booted_livecd/ | ||
Line 376: | Line 346: | ||
# cp precreated/* /vz/template/cache/ | # cp precreated/* /vz/template/cache/ | ||
</pre> | </pre> | ||
− | Add <tt>unionfs.ko</tt> to other kernel modules | + | Add <tt>unionfs.ko</tt> to other kernel modules: |
<pre> | <pre> | ||
# mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs | # mkdir /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs | ||
# cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/ | # cp unionfs-modules/2.6.18/unionfs.ko /lib/modules/2.6.18-ovz028stab035.1-smp/kernel/fs/unionfs/ | ||
− | |||
# exit | # exit | ||
exit | exit | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
'''Booted''' LiveCD filesystem is ready, congratulations! | '''Booted''' LiveCD filesystem is ready, congratulations! | ||
Line 412: | Line 360: | ||
<pre> | <pre> | ||
# rm -f ovz-livecd/base/*.mo | # rm -f ovz-livecd/base/*.mo | ||
− | # | + | # mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory |
− | + | # mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory | |
− | + | # mksquashfs root/lib/ ovz-livecd/base/lib.mo -keep-as-directory | |
+ | # mksquashfs root/root/ ovz-livecd/base/root.mo -keep-as-directory | ||
+ | # mksquashfs root/sbin/ ovz-livecd/base/sbin.mo -keep-as-directory | ||
+ | # mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory # it can take long... | ||
+ | # mksquashfs root/var/ ovz-livecd/base/var.mo -keep-as-directory | ||
</pre> | </pre> | ||
=== Vmlinux, initrd and isolinux.cfg === | === Vmlinux, initrd and isolinux.cfg === | ||
The next step is to force <tt>isolinux</tt> (cdrom boot loader) to boot OpenVZ kernel. | The next step is to force <tt>isolinux</tt> (cdrom boot loader) to boot OpenVZ kernel. | ||
− | First, copy kernel image to OpenVZ CD | + | First, copy kernel image to OpenVZ CD: |
− | |||
<pre> | <pre> | ||
− | # cp | + | # cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ |
</pre> | </pre> | ||
− | Modify initrd image. More precisely, we need to add OpenVZ kernel modules there | + | Modify initrd image. More precisely, we just need to add OpenVZ kernel modules there: |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<pre> | <pre> | ||
# mkdir initrd.d | # mkdir initrd.d | ||
− | # cp ovz-livecd/boot/initrd.gz initrd.d/ | + | # cp ovz-livecd/boot/initrd.gz initrd.d/ |
# cd initrd.d/ | # cd initrd.d/ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# mkdir mount | # mkdir mount | ||
+ | # gunzip initrd.gz | ||
# mount -o loop initrd mount/ | # mount -o loop initrd mount/ | ||
− | + | # cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | # cp -r ../ | ||
# rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build # we don't neet it on initrd image | # rm -rf mount/lib/modules/2.6.18-ovz028stab035.1-smp/build # we don't neet it on initrd image | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# sync | # sync | ||
# umount mount/ | # umount mount/ | ||
# gzip initrd | # gzip initrd | ||
− | # cp initrd.gz ../ovz-livecd/boot/initrd.gz | + | # /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz |
# cd .. | # cd .. | ||
</pre> | </pre> | ||
+ | |||
Now we should modify <tt>ovz-livecd/isolinux.cfg</tt> file, that controls <tt>isolinux</tt> boot loader. | Now we should modify <tt>ovz-livecd/isolinux.cfg</tt> file, that controls <tt>isolinux</tt> boot loader. | ||
We inform boot loader, that new kernel was added by introducing the following changes (in diff format): | We inform boot loader, that new kernel was added by introducing the following changes (in diff format): | ||
<pre> | <pre> | ||
− | --- ovz-livecd/isolinux.cfg.orig | + | --- ovz-livecd/isolinux.cfg.orig 2006-08-19 08:53:09.000000000 +0400 |
− | +++ ovz-livecd/isolinux.cfg 2007- | + | +++ ovz-livecd/isolinux.cfg 2007-06-29 18:22:29.000000000 +0400 |
@@ -1,5 +1,5 @@ | @@ -1,5 +1,5 @@ | ||
display boot/splash.cfg | display boot/splash.cfg | ||
-default linux | -default linux | ||
− | +default | + | +default ovz-2.6.18 |
prompt 1 | prompt 1 | ||
timeout 300 | timeout 300 | ||
Line 512: | Line 407: | ||
kernel boot/vmlinuz | kernel boot/vmlinuz | ||
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 | 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 | ||
− | + | ||
− | +label | + | +label ovz-2.6.18 |
− | +kernel boot/ | + | +kernel boot/vmlinuz-2.6.18-ovz028stab035.1-smp |
− | +append max_loop=32 vga=791 initrd=boot/initrd.gz init=linuxrc load_ramdisk=1 prompt_ramdisk=0 ramdisk_size= | + | +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 |
+ | + | ||
label memtest | label memtest | ||
kernel boot/memtest | kernel boot/memtest | ||
− | |||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Creating ISO === | === Creating ISO === | ||
− | Centos 4.4 LiveCD creators were very gentle and have placed | + | Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD. |
− | Using this | + | Using this sctipt, it is very easy to create iso: |
<pre> | <pre> | ||
− | + | ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso | |
− | |||
</pre> | </pre> | ||
Line 554: | Line 429: | ||
</pre> | </pre> | ||
command line options. It will help you to diagnose the problem more precisely. | command line options. It will help you to diagnose the problem more precisely. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== External Links == | == External Links == | ||
Line 567: | Line 436: | ||
* [http://squashfs.sourceforge.net/ squashfs website] | * [http://squashfs.sourceforge.net/ squashfs website] | ||
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage] | * [http://www.filesystems.org/project-unionfs.html uninonfs official homepage] | ||
− | |||
− | |||
− |