Running ReSoA in a Slackware UML

Table Of Contents

1 About This Document
2 Host System Setup
2.1 Important Note
2.2 Host Kernel
2.3 tmpfs
2.4 UML Networking Support
3 File Systems
4 User-Mode Linux Kernel
5 Slackware
5.1 Package Installation
5.2 Configuration
5.3 Booting
5.4 First Boot Configuration
6 Example Slackware Package List
7 Running ReSoA
8 References

1 About This Document

This file is part of the CD distribution of my Studienarbeit about the

Design and Implementation of the Remote Socket Architecture (ReSoA) for Linux 2.4 .

It contains basic information about how to create and use the User-mode Linux image based on Slackware provided on the CD.

2003/05/14 Tobias Poschwatta <>

2 Host System Setup

2.1 Important Note

You should make sure, that both host system and UML use the same gcc compiler version. You will encounter serious problems, i.e. crashes, if you mix gcc versions 2 and 3.

Slackware 9.0, used in this README, is based on gcc 3.2.2. If you want to compile your UML kernel with gcc 2, you can use packages from Slackware 8.1.

2.2 Host Kernel

If you want your UMLs to run fast, you should consider recompiling your host kernel using the SKAS patch available at the User-mode Linux site.More information about SKAS can be found here:

2.3 tmpfs

UMLs will create a temporary memory file with the size of the UML's memory ( mem option) in the directory denoted by $TMPDIR . It is recommended to use a tmpfs file system for $TMPDIR as it reduces system load significantly and thus improves overall performance.

To set up a tmpfs directory, create a directory and mount it as type tmpfs . The start script shown later in this document will set the TMPDIR environment variable before booting the kernel. Note, that it is not a good idea to use /tmp with tmpfs as this might break some applications.

You must be root to mount the tmpfs directory. Adjust the size option as needed (Should be as large as the sum of memory assigned to UMLs).

# mkdir umltmpfs
# mount -t tmpfs -o mode=1777,size=512M none umltmpfs/

It is also possible to add the tmpfs directory to the host's fstab to mount it during host system boot.

none       /.../umltmpfs  tmpfs  mode=1777,size=512M     0  0

2.4 UML Networking Support

There are several different approaches to allow UMLs to access the network. A description of the possibilites can be found at .

The UML start script provided later in this file uses TUN/TAP devices and bridging to attach the UMLs to the real network.

The following script creates the br0 bridge and five tap devices (tap0..tap4). Each UML is assigned a separate tap device (see start script later in this file). The bridge is created so that it replaces an existing eth0 device.

Creating the tap devices requires the UML utilities package to be installed ( tunctl program). Also, as Slackware does not include the bridge utilities, you probably have to install them, too.

The tap devices are assigned to UID 1000. Make sure /dev/net/tun is readable and writeable by this user, e.g. do chmod 666 /dev/net/tun .



IP=$(/sbin/ifconfig eth0 | awk '/inet addr:/ {print substr($2, 6)}')
BCAST=$(/sbin/ifconfig eth0 | awk '/inet addr:/ {print substr($3, 7)}')
NETMASK=$(/sbin/ifconfig eth0 | awk '/inet addr:/ {print substr($4, 6)}')
DEFGW=$(/sbin/route -n | awk '/^0\.0\.0\.0/ {print $2}')


    /sbin/ifconfig $TAP 1>/dev/null 2>/dev/null
    if [ $? -ne 0 ]; then
        echo "Creating device $TAP..."
        TAP=$(tunctl -b -t $TAP -u $USER)
	/sbin/ifconfig $TAP promisc up

/sbin/modprobe tun
/sbin/modprobe bridge

echo "Setting up bridge br0..."
brctl addbr br0
/sbin/ifconfig eth0 promisc up
/sbin/ifconfig br0 $IP netmask $NETMASK broadcast $BCAST up
brctl stp br0 off
brctl setfd br0 1
brctl sethello br0 1
brctl addif br0 eth0

for i in 0 1 2 3 4; do
start_tap $i
brctl addif br0 tap$i

/sbin/route add default gw $DEFGW

3 File Systems

First, create the file systems for use by the UMLs. The following commands will create a 2G ext3 root file system and a 128M swap partition. This does not require root privileges.

$ dd if=/dev/zero of=root_fs bs=1M count=1 seek=2000
$ /sbin/mke2fs -F -j root_fs

$ dd if=/dev/zero of=swap_fs bs=1M count=1 seek=127
$ /sbin/mkswap swap_fs

Note, that the resulting files are so-called sparse files, i.e. they take up less space than ls reports (Try du instead). If you want to copy these files using rsync , use the -S ( --sparse ) option.

4 User-Mode Linux Kernel

More detailed info about compiling the kernel can be found on the User-mode Linux homepage.

First, unpack the kernel and apply the UML-patch. Then configure the kernel and compile the linux binary and the modules. Do not forget the ARCH=um!

$ tar xjvf /path/to/linux-2.4.20.tar.bz2
$ cd linux-2.4.20
$ bzcat /path/to/uml-patch-2.4.20-2.bz2 | patch -p1

$ make menuconfig ARCH=um
$ make linux modules ARCH=um

Module installation requires root privileges and the root_fs to be mounted. This step should be done later, after the package installation is completed.

# make modules_install INSTALL_MOD_PATH=/path/to/uml/mnt ARCH=um 

Alternatively, you can run the following command inside the UML, if you configured hostfs or NFS access to your UML kernel sources (requires make and findutils to be installed in your UML):

# make modules_install ARCH=um

5 Slackware

5.1 Package Installation

This section will use standard Slackware package management tools, therefore this will only work on systems running Slackware Linux. Mounting and installing packages into the root_fs file usually requires root privileges.

To mount the root file system, create the mount point and use the loopback device:

# mkdir mnt
# mount -o loop root_fs mnt/

Packages are installed using the standard pkgtools installpkg program. The command line argument -root /path/to/uml/mnt will install files into the mounted root file system.

The -ask and -menu options provide an easy way to select only desired packages. Note, that you do not need to (and should not) install any of the kernels.

Change to the slackware directoy (the one that contains the disksets a/, ap/, d/, ...) and install packages. The following installpkg command is only an example, you can add packages from more disksets if you want. An example list of packages is shown at the end of this section.

# cd /path/to/slackware/
# installpkg -root /path/to/uml/mnt -ask -menu \
    a/*.tgz ap/*.tgz d/*.tgz e/*.tgz n/*.tgz

# cd /path/to/uml
# chroot mnt /sbin/ldconfig

5.2 Configuration

After package installation, you need to do some basic configuration before the first start. Note, that all file paths given here are relative to the mounted uml root file system!

First, create the initial etc/fstab:

none  /dev/pts  devpts  gid=5,mode=620  0  0
none  /proc     proc    defaults        0  0

/dev/ubd/disc0/disc  /     ext3  defaults  0  0
/dev/ubd/disc1/disc  swap  swap  defaults  0  0

If you want to mount directories on the host file system in the UML, you can add entries like the following to fstab. You must have compiled hostfs support into your UML kernel.

none /mnt/shared hostfs defaults,/path/on/host/uml/shared 0 0

Now edit etc/rc.d/rc.S and remove the blocks dealing with fsck, this won't work from inside the UML:

#  if [ ! -r /etc/fastboot ]; then
#    echo "Checking root filesystem:"
#    /sbin/fsck $FORCEFSCK -C -a /
#    RETVAL=$?
#  fi
#  # An error code of 2 or higher will require a reboot.
#  if [ $RETVAL -ge 2 ]; then
#    ...
#    reboot -f
#  fi
# Check all the non-root filesystems:
#if [ ! -r /etc/fastboot ]; then
#  echo "Checking non-root filesystems:"
#  /sbin/fsck $FORCEFSCK -C -R -A -a

UMLs also do not have access to the hardware clock, so remove the hwclock block from etc/rc.d/rc.6 :

# Save the system time to the hardware clock using hwclock --systohc.
# Detect SGI Visual Workstation, since hwclock will make those freeze up:
#if fgrep -l Cobalt-APIC /proc/interrupts 1> /dev/null 2> /dev/null ; then
#  echo "SGI Visual Workstation detected.  Not running hwclock."
#elif [ -x /sbin/hwclock ]; then
#  if grep "^UTC" /etc/hardwareclock 1> /dev/null 2> /dev/null ; then
#    echo "Saving system time to the hardware clock (UTC)."
#    /sbin/hwclock --utc --systohc
#  else
#    echo "Saving system time to the hardware clock (localtime)."
#    /sbin/hwclock --localtime --systohc
#  fi

Next, edit etc/inittab, remove all tty terminals and add the c0 console:

# These are the standard console login getties in multiuser mode:
c0:1235:respawn:/sbin/agetty 38400 console linux
#c1:1235:respawn:/sbin/agetty 38400 tty1 linux
#c2:1235:respawn:/sbin/agetty 38400 tty2 linux
#c3:1235:respawn:/sbin/agetty 38400 tty3 linux
#c4:1235:respawn:/sbin/agetty 38400 tty4 linux
#c5:1235:respawn:/sbin/agetty 38400 tty5 linux
#c6:12345:respawn:/sbin/agetty 38400 tty6 linux

If you installed emacs, but not X, you need to create a symlink for the emacs binary, that is not linked against X libraries:

# cd usr/bin
# ln -snf emacs-21.2-no-x11 emacs

Remember to unmount the root file system:

# umount mnt

5.3 Booting

The root file system is now prepared for the first boot. If you intend to create multiple UMLs, you can simply create copies of the root_fs as it is now.

Below is an example script to start the UML. The script requires the root_fs and swap_fs files as well as the linux kernel binary or a link to it in the current directory.



# change this path to point to correct tmpfs dir
export TMPDIR=/.../umltmpfs

echo "Checking root file system..."
/sbin/e2fsck -C -p root_fs
if [ $? -gt 1 ]; then
    echo "*** An error occured during the root filesystem check. ***"
    exit 1

/sbin/ifconfig $tap
if [ $? -ne 0 ]; then
    exit 1

echo "Starting kernel..."
./linux \
    ubd0=root_fs ubd1=swap_fs \
    con=pty con0=fd:0,fd:1 \
    mem=$mem \
    eth0=tuntap,$tap \

5.4 First Boot Configuration

After you booted your UML the first time, proceed with the final configuration steps:

  1. Setting a root password
  2. Setting the host name
  3. Timezone configuration
  4. Network setup

Log in as root (no password) and set the hostname and a root password:

# echo "testuml.local" > /etc/HOSTNAME
# /bin/hostname `cat /etc/HOSTNAME | cut -f1 -d .`

# passwd

Run timeconfig to chose your time zone and netconfig to setup your network interface. After the next reboot, you should be able to access the network (or run /etc/rc.d/rc.inet1 to setup eth0 immediately)

Finally, customize your installation as usual, e.g.:

# cd /etc/rc.d
# chmod a-x rc.nfsd rc.serial rc.font.sample

6 Example Slackware Package List

This is an example set of packages from Slackware Linux 9.0.


7 Running ReSoA

To start ReSoA inside a UML, you must recompile the ReSoA sources with LINUXPATH in src/Config.make pointing to your UML kernel sources:

$ cd resoa/src
$ make clean all

An easy way to gain access to the ReSoA sources and modules from inside a UML is to mount the ReSoA source directory using the hostfs feature of User-mode Linux. E.g, add a line like the following to the UML's fstab . Replace /path/on/host/uml/shared with the path where you have copied the ReSoA sources to.

none /mnt/shared hostfs defaults,/path/on/host/uml/shared 0 0

You can then mount the shared directory on both UMLs (client and server) and start ReSoA as usual.


# mount /mnt/shared
# cd /mnt/shared/resoa/src
# ./rc.iplhp start
# ./rc.kresoad start


# mount /mnt/shared
# cd /mnt/shared/resoa/src
# ./rc.iplhp start
# ./rc.resoa start <server IP address>

If the ReSoA client successfully connected, you should see a CONNECTED message in /var/log/debug . After you have installed the ReSoA client utility, you can use ReSoA and invoke programs (e.g. resoa ncftp ).

# cd /mnt/shared/resoa/src/tools/resoa
# make install

In case, you get unresolved symbols (e.g. ip_queue_xmit ) when loading the modules, you can either modify linux/net/netsyms.c to explicitly export these functions, or you can activate IPv6 or kHTTPd in the kernel config. Note that ReSoA does not depend upon IPv6 or kHTTPd, but enabling one of these options will export the functions, that ReSoA needs.

If you have set up UML networking as described above using a bridge, you can monitor the complete network traffic on the host computer. The CD contains a customized version of tcpdump that prints ReSoA messages in a human-readable format.

8 References

  1. The User-mode Linux Kernel Home Page:
  2. The Slackware Linux Project:
  3. Linux ethernet bridging:
  4. User-mode Linux: skas mode
  5. User-mode Linux: Setting up the network
  6. UML-based pseudo-dedicated hosting service
2003.05.14 18:12 CEST,