Editing Creating OpenVZ LiveCD based on Centos 4.4

Jump to: navigation, search

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.
 
Note: before proceed with commands below, one needs to disable SE Linux on the host, otherwise rpm operations
 
in cdroot-ed environment described later on will fail due to inability to restore security file context. So, please,
 
do:
 
<pre>
 
# setenforce 0
 
</pre>
 
This will put SE linux in so-called 'permissive' mode, where all the blockers will be substituted by warnings.
 
If you wanna get rid of the warnings (rather annoying), the only way to do is to edit <tt>/etc/sysconfig/selinux</tt>
 
to read <tt>SELINUX=disabled</tt> and then reboot the host.
 
  
 
=== Creating booted LiveCD root filesystem ===
 
=== Creating booted LiveCD root filesystem ===
Line 85: Line 75:
 
# cp mksquashfs /usr/bin/
 
# cp mksquashfs /usr/bin/
  
# cd -
+
# cd ~/workbench/
 
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz
 
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz
 
# tar xzf squashfs3.2-r2.tar.gz
 
# tar xzf squashfs3.2-r2.tar.gz
Line 93: Line 83:
 
cc unsquashfs.o -lz -o unsquashfs
 
cc unsquashfs.o -lz -o unsquashfs
 
# 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 92:
 
# mkdir livecd-root
 
# mkdir livecd-root
  
# for f in bin etc lib root sbin usr var; do \
+
# unsquashfs ovz-livecd/base/bin.mo
    unsquashfs ovz-livecd/base/$f.mo; \
+
# mv squashfs-root/bin/ livecd-root/
    mv squashfs-root/$f/ livecd-root; \
+
# rm -rf squashfs-root
    rm -rf squashfs-root; \
+
 
  done
+
# unsquashfs ovz-livecd/base/etc.mo
</pre>
+
# 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
  
Be patient, this will take a few minutes.
+
# 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>
# cd livecd-root
+
# mkdir root/dev
# mkdir 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
 
# cd -
 
 
</pre>
 
</pre>
  
That's it. We have '''bootstrapped''' LiveCD root filesystem in <tt>livecd-root</tt> directory.
+
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 232: Line 239:
 
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. But some important differences in building
+
below are based on <tt>028stab035</tt> kernel, that has been just build above.
kernel of version other then 2.6.18 one is summarized below.
 
==== Peculiarities of building 2.6.9-rhel4 ====
 
* You should also include this patch (http://git.openvz.org/?p=linux-2.6.18-openvz;a=commit;h=681d0b65dedd54d8c716cef56418ac1a478f94da)
 
in building process. Hopefully will be fixed in <tt>2.6.9-044stab044.8</tt> kernel.
 
* Use <tt>unionfs 1.0.14</tt>, but not <tt>unionfs 1.1.5</tt>, as offered at its official site!
 
* Small problems while building <tt>unionfs</tt>: arguments of <tt>vfs_permissions()</tt>. Just add <tt>NULL</tt>
 
to appropriate places.
 
 
 
==== Peculiarities of building 2.6.18-rhel5 ====
 
* Note, <tt>squashfs</tt> patch is already there, but you should use <tt>3.2</tt>! :)
 
* While building <tt>unionfs</tt> some small fixes: <tt>i_blksize</tt> field is missing in <tt>inode</tt> structure, <tt>ino_t</tt> should be changed to <tt>u64</tt> in some functions.
 
 
 
==== Peculiarities of building 2.6.20 ====
 
* Only <tt>unionfs</tt> <tt>2.0</tt> is available for 2.6.20 kernel and it is distributed as a patch. Consequently modify <tt>spec</tt>-file and configs while building the kernel
 
* <tt>unionfs</tt> <tt>2.0</tt> doesn't support unionctl. Consequently you have to modify <tt>liblinuxlive</tt> file on <tt>initrd</tt> image to mount all branches at once, but don't add them by ioctls.
 
  
 
=== Unionfs kernel module ===
 
=== Unionfs kernel module ===
Line 346: Line 338:
 
<tt>tetex</tt>, <tt>latex</tt>, <tt>k3b</tt> and printing related packages:
 
<tt>tetex</tt>, <tt>latex</tt>, <tt>k3b</tt> and printing related packages:
 
<pre>
 
<pre>
# cp -r to_booted_livecd/ livecd-root/tmp/
+
# cp -r to_booted_livecd/ root/tmp/
# chroot livecd-root/
+
# chroot root/
  
 
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386
 
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386
Line 387: Line 379:
 
Clean it:
 
Clean it:
 
<pre>
 
<pre>
# rm livecd-root/root/.bash_history
+
# rm root/root/.bash_history
 
</pre>
 
</pre>
 
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment
 
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment
Line 398: Line 390:
 
on this directory:
 
on this directory:
 
<pre>
 
<pre>
mkdir livecd-root/vz/private/
+
mkdir root/vz/private/
 
</pre>
 
</pre>
At the moment vzquota doesn't support <tt>tmpfs</tt> ([http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #558]).
 
We're working on this problem, but for now '''switching the disk quota off''' in <tt>/etc/vz/vz.conf</tt>: <tt>DISK_QUOTA=no</tt>.
 
But when disk quota is off <tt>vzmigrate</tt> fails! ;) This is the [http://bugzilla.openvz.org/show_bug.cgi?id=558  Bug #512].
 
So, don't forget to apply the patch attached to this bug report to <tt>vzmigrate</tt>.
 
 
 
'''Booted''' LiveCD filesystem is ready, congratulations!
 
'''Booted''' LiveCD filesystem is ready, congratulations!
  
Line 412: Line 399:
 
<pre>
 
<pre>
 
# rm -f ovz-livecd/base/*.mo
 
# rm -f ovz-livecd/base/*.mo
# for f in bin etc lib root sbin usr var vz; do \
+
# mksquashfs root/lib/ ovz-livecd/base/bin.mo -keep-as-directory
    mksquashfs livecd-root/$f ovz-livecd/base/$f.mo -keep-as-directory; \
+
# mksquashfs root/etc/ ovz-livecd/base/etc.mo -keep-as-directory
  done
+
# 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
 +
# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory
 
</pre>
 
</pre>
  
Line 422: Line 414:
 
than 8 characters) to kernel image, otherwise <tt>isolinux</tt> will not see it.
 
than 8 characters) to kernel image, otherwise <tt>isolinux</tt> will not see it.
 
<pre>
 
<pre>
# cp livecd-root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18
+
# cp root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18
 
</pre>
 
</pre>
 
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there
 
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there
and apply small patches to <tt>liblinuxlive</tt> file. Initrd image that goes with Centos 4.4 is
+
and apply small patch to <tt>liblinuxlive</tt> file.
of size 40Mb. OpenVZ LiveCD will contain several kernels, so initrd should have several sets of
+
Mount initrd:
kernel modules (for each kernel) and 40Mb isn't enough in this case. I created an initrd of size 100Mb.
 
Don't forget to update <tt>ramdisk_size</tt> in <tt>isolinux.cfg</tt> file later!
 
 
 
Creating "big" initrd with original content:
 
 
<pre>
 
<pre>
 
# mkdir initrd.d
 
# mkdir initrd.d
# cp ovz-livecd/boot/initrd.gz initrd.d/initrd-old.gz
+
# cp ovz-livecd/boot/initrd.gz initrd.d/
 
# cd initrd.d/
 
# cd initrd.d/
# mkdir mount-old
 
# gunzip initrd-old.gz
 
# mount -o loop initrd-old mount-old/
 
# dd if=/dev/zero of=initrd bs=1048576 count=100
 
# mke2fs initrd
 
initrd is not a block special device.
 
Proceed anyway? (y,n) y
 
...
 
 
# mkdir mount
 
# mkdir mount
 +
# gunzip initrd.gz
 
# mount -o loop initrd mount/
 
# mount -o loop initrd mount/
# cp -a mount-old/* mount/
 
# umount mount-old/
 
# rm -rf mount-old initrd-old
 
 
</pre>
 
</pre>
 
Copy modules to initrd:
 
Copy modules to initrd:
 
<pre>
 
<pre>
# cp -r ../livecd-root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/
+
# cp -r ../root/lib/modules/2.6.18-ovz028stab035.1-smp/ mount/lib/modules/
 
# 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
 
</pre>
 
</pre>
I also delete some not necessary kernel modules from initrd to free space.
 
They are stil on CD, so init sctipts will be able to load them later.
 
 
 
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.
 
initrd image, that goes with Centos 4.4 LiveCD doesn't load cdrom kernel modules.
 
It works well for CentOS kernel, because cdrom support is built-in there.
 
It works well for CentOS kernel, because cdrom support is built-in there.
Line 474: Line 449:
 
     modprobe_module isofs
 
     modprobe_module isofs
 
     echolog "starting squashfs support"
 
     echolog "starting squashfs support"
</pre>
 
As mentioned earlier we want to mount <tt>tmpfs</tt> on /vz/private automatically. Just apply this patch to
 
<tt>liblinuxlive</tt> file:
 
<pre>
 
--- liblinuxlive.orig-fstab    2007-07-02 17:50:34.000000000 +0400
 
+++ mount/liblinuxlive  2007-07-03 12:33:30.000000000 +0400
 
@@ -414,6 +414,7 @@ activate_fstab()
 
    echo "tmpfs            /                tmpfs      defaults        0  0" >$FSTAB
 
    echo "devpts          /dev/pts        devpts      gid=5,mode=620  0  0" >>$FSTAB
 
    echo "proc            /proc            proc        defaults        0  0" >>$FSTAB
 
+  echo "tmpfs            /vz/private      tmpfs      defaults        0  0" >>$FSTAB
 
 
    # now done by fstab-sync
 
    # list_cdrom_devices | while read DEVICE; do
 
 
</pre>
 
</pre>
 
Finishing actions with initrd:
 
Finishing actions with initrd:
Line 494: Line 455:
 
# 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>
Line 515: Line 476:
 
+label ovz18  
 
+label ovz18  
 
+kernel boot/ovz18
 
+kernel boot/ovz18
+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
+
+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
Line 521: Line 482:
  
 
</pre>
 
</pre>
 
Also '''don't forget''' to change <tt>ramdisk_size</tt> to 102400 for all kernels including Centos 4.4 default!
 
 
And I suggest to remove <tt>quiet</tt> parameter, to see what happens: it will help greatly if some problem will happen.
 
 
=== Embellishment ===
 
If you want to release LiveCD to other people some "embelishments" should be added.
 
 
First, edit <tt>splash.cfg</tt>, <tt>help1.txt</tt>, <tt>help2.txt</tt> and <tt>help3.txt</tt>
 
files (that are in <tt>~/workbench/ovz-livecd/boot/help</tt> directory) to contain appropriate information.
 
These messages appear on the LiveCD initial boot: they help to choose kernel and kernel options.
 
 
Also, you can note, that CentOS logo appears at this moment. This logo resides in <tt>ovz-livecd/boot/splash.lss</tt>
 
file. I added OpenVZ logo there. The following tools will help you: <tt>lss16toppm</tt>, <tt>ppmtolss16</tt> and
 
of course <tt>gimp</tt> :)
 
 
One more thing we change is default desktop background. It resides in <tt>usr/share/backgrounds/images/default.png</tt>.
 
I added OpenVZ logo there.
 
  
 
=== Creating ISO ===
 
=== Creating ISO ===
Centos 4.4 LiveCD creators were very gentle and have placed <tt>make_iso.sh</tt> script on CD.
+
Centos 4.4 LiveCD creators were very gentle and have placed make_iso.sh script on CD.
 
Using this script, it is very easy to create iso:
 
Using this script, it is very easy to create iso:
 
<pre>
 
<pre>
# cd ovz-livecd
+
./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso
# ./make_iso.sh ../CentOS-4.4-i386-OpenVZ-LiveCD.iso
 
 
</pre>
 
</pre>
  
Line 554: Line 496:
 
</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.
Also it can be useful to redirect kernel output to serial console:
 
<pre>
 
console=ttyS0,115200 console=tty
 
</pre>
 
 
See more at [[remote console setup]].
 
  
 
== External Links ==
 
== External Links ==
Line 567: Line 503:
 
* [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]
 
[[Category: HOWTO]]
 
[[Category: Live CD]]
 

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)