Create-rootfs
Contents
How to create a VNUML-compatible root filesystem from scratch using debootstrap
Introduction
Virtual machines created by VNUML need a root filesystem (root_fs) to work. The VNUML root_fs are basicly UML filesystem, slightly tunned to work with the tool (for example, special mount point has to be created). That modifications/requirements are described in one section in the User Manual.
Until know the VNUML Project has provided a root_fs_tutorial filesystem for download (current version at time of writting this is 0.4.1). However, mantaining the root_fs_tutorial is costly because there are a lot of details to check when a new version is released. In addition, the bunch of packages included in root_fs_tutorial hardly satisfy all the user needs (some won't find the particular packages they want and many others will have a lot of unnecessary stuff they don't need).
Therefore, a more practical approach is to provide simple and easy-to-implement procedure that allow user to produce it's own VNUML-compatible filesystems, with the size and software package they want. This goal is addressed by the present document.
The procedure described in this document has been developed by Michael Monreal, with minor additions and fixes by Fermín Galán.
Procedure
The procedure will create a Debian-based VNUML-compatible root_fs. We asume you are using Debian (or maybe other Debian-based distribution) to generate the root_fs. Before starting ask yourself:
- The size of the desired root_fs (we'll consider 800Mb here)
- Which Debian packages you want to include (we'll use here a list based on the contents of root_fs_tutorial).
Note that the base filesystem created by debootstrap seems to take around 200MB. Take it into account when deciding the root_fs size and the packages that you will install.
Let's go (I'll asume you are logged as root; otherwise execute privileged commands using sudo):
- Create an ext3 filesystem (800MB). Change the destination directory (/usr/share/vnuml/filesystems) if it is not suitable for you.
- Mount and use debootstrap to install the latest "etch" release. The last command can take a while, depending of the speed of your Internet connection (as a figure I have a high speed connection and I has taken around 11 minutes). You could use a mirror of the Debian package repository close to your geographical location (like ftp.es.debian.org) if you want.
- Change root to the new system
- Edit /etc/apt/sources.list with some like that:
- Refresh package cache
- Install the desired packages (it's up to you! :). Here were are using an arbitrary list, based on the old root_fs_tutorial, around 151MB after unpacking. It is highly recommendable to install at least openssh-server (for the sshd daemon).
- (Optional) If you want to free space of the downloaded packages (around 42MB): # apt-get clean
- Set timezone (use the proper one for you, I'm using Europe/Madrid because it corresponds where I live :)
- Edit /etc/hosts (no existing at the begining)
- (Optional) Edit /etc/hostname and set a name different from the one of the host where you executed debootstrap (actually, VNUML will set the host name properly based on the name of the virtual machine so this step is optional but recommendable anyway).
- Edit /etc/network/interfaces (empty at the beginging):
- Edit /etc/fstab (empty at the beginging):
- (Optional) Set root password (if you skip this step the root password won't be prompted, you are warned! :)
- Some VNUML stuff:
- Exit of the chroot enviroment. The latest steps will be performed in the mount /mnt/debian.
- Create the /dev/ubda, /dev/ubdb, etc. devices. The recommended way is to use the makeUSBdev.sh script (http://www.theshore.net/~caker/uml/makeUBDdev.sh).
- Install modules corresponding to your UML kernel. For example, in the case of the linux-2.6.16.27-bs2-xt-1m kernel (http://prdownloads.sourceforge.net/vnuml/linux-2.6.16.27-bs2-xt-1m.tar.bz2?download), considering the linux-2.6.16.27-bs2-xt-1m.tar.bz2 has been downloaded in /tmp:
- Umount filesystem:
$ dd if=/dev/zero of=/usr/share/vnuml/filesystems/debian.ext3 bs=1024k seek=800 count=0 $ mkfs.ext3 /usr/share/vnuml/filesystems/debian.ext3 $ tune2fs -c 0 -i 0 /usr/share/vnuml/filesystems/debian.ext3
$ mkdir /mnt/debian $ mount -o loop /usr/share/vnuml/filesystems/debian.ext3 /mnt/debian $ debootstrap etch /mnt/debian/ ftp://ftp.debian.org/debian/
$ mount -t proc none /mnt/debian/proc $ chroot /mnt/debian # env -update
deb http://ftp.debian.org/debian etch main contrib non-free
# apt-get update
# apt-get install apache2.2-common apache2-mpm-prefork apache2-utils \ bzip2 dnsutils ethereal-common fdutils file fileutils finger ftp ftpd \ iproute ipsec-tools iputils-tracepath ipv6calc ipvsadm less lpr lsof \ lynx modutils ncurses-term nfs-common openssh-client openssh-server \ openssl perl perl-modules pidentd portmap ppp procmail python \ python-central python-newt quagga racoon radvd setserial sharutils \ shellutils squid squid-common ssh ssl-cert strace syslinux tcpdump \ tcsh telnet tethereal textutils time tshark ucf vlan whois \ wireshark-common sudo vim iptables
# ln -sf /usr/share/zoneinfo/Europe/Madrid /etc/localtime
127.0.0.1 localhost ::1 localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
iface lo inet loopback auto lo
proc /proc proc defaults 0 0 devpts /dev/pts devpts mode=0622 0 0 /dev/ubda / ext3 defaults 0 1 /dev/ubdb /mnt/vnuml iso9660 defaults 0 0
# passwd
# mkdir /mnt/vnuml # ln -s /mnt/vnuml/umlboot /etc/rc2.d/S11umlboot
# exit
$ cd /mnt/debian/dev $ wget http://www.theshore.net/~caker/uml/makeUBDdev.sh $ chmod a+x makeUBDdev.sh $ ./makeUBDdev.sh $ rm makeUBDdev.sh
$ cd /tmp $ tar xfvj linux-2.6.16.27-bs2-xt-1m.tar.bz2 $ mv linux-2.6.16.27-bs2-xt-1m/modules-2.6.16.27-bs2-xt-1m.tar /mnt/debian/lib/modules/ $ cd /mnt/debian/lib/modules/ $ tar xfv modules-2.6.16.27-bs2-xt-1m.tar $ rm -f modules-2.6.16.27-bs2-xt-1m.tar $ rm -rf /tmp/linux-2.6.16.27-bs2-xt-1m
$ cd / $ umount /mnt/debian/proc/ $ fuser -k /mnt/debian $ umount /mnt/debian
The filesystem is ready to be used! You can perform a quick test editing simple.xml and changing the filesystem tag to:
<filesystem type="cow">/usr/share/vnuml/filesystem/debian.ext3</filesystem>
Then (the -P is only needed if you have to purge some pre-existing scenario based on simple.xml):
vnumlparser.pl -P simple.xml -v vnumlparser.pl -t simple.xml -v
and you should see the usual xterm poping-up.
NOTE: you could want to edit /etc/inittab in the root_fs, but it is not actually required, because the VNUML-ization step performed by vnumlparser.pl during -t mode will properly configure the file (execpt if you are skipping VNUML-ization for some reason with -Z; in that case you have to edit /etc/inittab to allow the use of tty0).
makeUSBdev.sh
As reference:
#!/bin/bash device=ubd major=98 minor=0 for u in a b c d e f g h do dev=$device$u mknod $dev b $major $minor chmod 660 $dev chgrp disk $dev for i in $(seq 1 15) do mknod $dev$i b $major $(($minor + $i)) chmod 660 $dev$i chgrp disk $dev$i done minor=$(($minor + 16)) done