UML
From EECS
[edit]
Some notes on UML setup on fruit
We have been using kernel version 2.6.11.6-skas3-v8 for the host. The guests used kernel versions 2.6.11.11 or 2.4.27.
The guest UMls were chroot-ed and chuid-ed to make the setup more secure. The conosole of a UML guest was put into a (detached) screen session. This could then be easily re-attached if one needed access the UM console (i.e. in case network broke down).
The init.d script to start/stop uml looked as follows:
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
UML="kiwi"
DESC="uml $UML"
NAME="uml-$UML"
#DAEMON=/usr/bin/linux
#DAEMON=/usr/bin/linux-2.4.27
DAEMON=/linux
#DAEMON=/usr/bin/linux-2.6.10
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CHROOT=/uml/$UML
#DAEMON=$CHROOT/linux
# Gracefully exit if the package has been removed.
#test -x $DAEMON || exit 0
#test -x $CHROOT/$DAEMON || exit 0
# Read config file if it is present.
if [ -r /etc/default/$NAME ]
then
. /etc/default/$NAME
fi
# using uml_switch daemon
#OPTIONS="umid=$UML eth0=daemon,,unix,/var/run/uml-utilities/uml_switch.ctl con0=tty:$TTY ubd0=/uml/$UML/root_fs uml_dir=/tmp/uml"
OPTIONS="umid=$UML uml_dir=/tmp eth0=daemon,,unix,/var/uml_switch.ctl ubd0=/root.ext2 mem=32M"
# using tap0 directly
#OPTIONS="umid=peach eth0=tuntap,tap0 con0=tty:$TTY ubd0=/uml/$UML/root_fs"
#
# Function that starts the daemon/service.
#
d_start() {
mount -o bind /proc/mm $CHROOT/proc/mm
mount --bind /var/run/uml-utilities/ $CHROOT/var/
mkdir -p /tmp/uml
chmod 770 /tmp/uml
chown root:uml /tmp/uml
screen -d -m -S $UML \
compartment --user $UML --group uml \
--chroot $CHROOT \
$DAEMON $OPTIONS
}
#
# Function that stops the daemon/service.
#
d_stop() {
# start-stop-daemon --stop --quiet --pidfile $PIDFILE \
# --name $NAME
# compartment --user orange --group uml \
# --chroot $CHROOT \
uml_mconsole /uml/$UML/tmp/$UML/mconsole cad
echo -n " waiting for uml to halt..."
sleep 15
umount $CHROOT/proc/mm
umount $CHROOT/var/
}
#
# Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--name $NAME --signal 1
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
single)
echo -n "Starting $DESC: $NAME (single user)"
OPTIONS="$OPTIONS single"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
#reload)
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this an "exit 0".
#
# echo -n "Reloading $DESC configuration..."
# d_reload
# echo "done."
#;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
# echo "Usage: $SCRIPTNAME {start|stop|single|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|single|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
The networking was done by bridging eth0 with tap0, to which the UMls were attching. /etc/network/interfaces:
# The loopback network interface
auto lo
iface lo inet loopback
# tun/tap device for umls
auto tap0
iface tap0 inet static
address 192.168.0.1
netmask 255.255.255.0
tunctl_user uml-net
# bridge for UMLs
auto br0
iface br0 inet static
address 212.201.49.185
netmask 255.255.254.0
gateway 212.201.49.250
bridge_ports eth0 tap0
iface br0 inet6 static
address 2001:638:709:4::2
netmask 64
auto eth1
iface eth1 inet static
address 192.168.1.67
netmask 255.255.255.0
The following files/devices are needed in a UML chroot
uml-skeleton/ uml-skeleton/linux uml-skeleton/proc/ uml-skeleton/proc/mm - I think this was a copy of the real file uml-skeleton/proc/cpuinfo - this was a copy of the real file or a link (symlink) to the real /proc file uml-skeleton/tmp/ uml-skeleton/dev/ uml-skeleton/dev/net/ uml-skeleton/dev/net/tun - character device with major 10, minor 200 uml-skeleton/var/ uml-skeleton/root.ext2
