6,534
edits
Changes
m
# unsquashfs ovz-livecd/base/etcBe patient, this will take a few minutes.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>
This part contains detailed description of LiveCD creation. I've removed the output of some
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 ===
# cp mksquashfs /usr/bin/
# cd ~/workbench/-
# wget http://belnet.dl.sourceforge.net/sourceforge/squashfs/squashfs3.2-r2.tar.gz
# tar xzf squashfs3.2-r2.tar.gz
cc unsquashfs.o -lz -o unsquashfs
# cp unsquashfs /usr/bin/
# cd ~/workbench-
</pre>
Well, having the intruments in hand, why not extract the images? Create a directory, called <tt>livecd-root</tt>,
# mkdir livecd-root
# for f in bin etc lib root sbin usr var; do \ unsquashfs ovz-livecd/base/bin$f.mo ; \# mv squashfs-root/bin$f/ livecd-root/; \# rm -rf squashfs-root; \ done</pre>
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.
<pre>
# cd livecd-root# mkdir root/dev# cp -a /dev/* rootdev/dev# mkdir root/proc# mount -t proc proc root/proc/# mkdir root/sys# mount -t sysfs sysfs root/sys/# mkdir root/tmp# mkdir root/boot# cd -
</pre>
That's it. We have '''bootedbootstrapped''' 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
packages do we need?
kernel of version other then 2.6.18 one is summarized below.
==== Peculiarities of building 2.6.9-rhel4 ====
* You should also include this path 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>! :)
<tt>tetex</tt>, <tt>latex</tt>, <tt>k3b</tt> and printing related packages:
<pre>
# cp -r to_booted_livecd/ livecd-root/tmp/# chroot livecd-root/
# rpm -e lksctp-tools-1.0.2-6.4E.1.i386
Clean it:
<pre>
# rm livecd-root/root/.bash_history
</pre>
Here we have to make one step to workaround [[Checkpointing and live migration]] problem. The thing is that at the moment
on this directory:
<pre>
mkdir livecd-root/vz/private/
</pre>
At the moment vzquota doesn't support <tt>tmpfs</tt> ([http://bugzilla.openvz.org/show_bug.cgi?id=558 Bug #558]).
<pre>
# rm -f ovz-livecd/base/*.mo
# mksquashfs root/lib/ ovz-livecd/base/for f in 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-directoryusr var vz; do \# mksquashfs root/usr/ ovz-livecd/base/usr.mo -keep-as-directory # it can take long...# mksquashfs root/var/ $f ovz-livecd/base/var$f.mo -keep-as-directory; \# mksquashfs root/vz/ ovz-livecd/base/vz.mo -keep-as-directory done
</pre>
than 8 characters) to kernel image, otherwise <tt>isolinux</tt> will not see it.
<pre>
# cp livecd-root/boot/vmlinuz-2.6.18-ovz028stab035.1-smp ovz-livecd/boot/ovz18
</pre>
Modify initrd image. More precisely, we need to add OpenVZ kernel modules there
# 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
# mount -o loop initrd mount/
Copy modules to initrd:
<pre>
# cp -r ../livecd-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
</pre>
# umount mount/
# gzip initrd
# /bin/cp initrd.gz ../ovz-livecd/boot/initrd.gz
# cd ..
</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>quitequiet</tt> parameter, to see what happens: it will help greatly if some problem will happen.
=== Embellishment ===
console=ttyS0,115200 console=tty
</pre>
See more at [[remote console setup]].
== External Links ==
* [http://squashfs.sourceforge.net/ squashfs website]
* [http://www.filesystems.org/project-unionfs.html uninonfs official homepage]
[[Category: HOWTO]]
[[Category: Live CD]]