Step 1 Cloning the Xen Ubuntu

Cloning the VM
cp ubuntu umlubuntu
cp ubuntu.img umlubuntu.img

Have to change a bit the domU configuration file, a new domain name, different VNC port (5902) and different MAC address for the VM. the configuration file for umlubuntu domU look like this

kernel = "hvmloader" #kernel to be used
builder='hvm' #
memory = 1024 # memory allocated, this will overwrite the default value in dom0
name = "umlubuntu" #name of the VM
acpi=1 # ACPI set to yes
apic=1 # APIC set to yes
vif = ['type=ioemu, bridge=eth2, mac=00:16:3E:00:00:03', 'type=ioemu, bridge=et$
disk = ['file:/home/vic/umlubuntu.img,hda,w','file:/home/vic/ubuntu-10.04.1-des$
device_model = '/usr/lib/xen/bin/qemu-dm' #define the device model
boot="cd" # boot sequence, c = disk, d = cd
vnc=1 #enable VNC on VM using the default port 5900
vncdisplay=2
 
on_poweroff = 'destroy' #on VM power off behaviour
on_reboot   = 'restart' #on VM reboot behaviour
on_crash    = 'restart' #on VM crash behaviour
usbdevice='tablet'
Change the configuration of dhcp server

I add the following code to the dhcp ip assigning scheme to give my new umlubuntu domU a constant IP address.

host umlubuntu {
  hardware ethernet 00:16:3E:00:00:03;
  fixed-address 145.100.106.84;
  option routers 145.100.106.81;
}
SSH to the new UMLUbuntu (with X)

As I installed already the SSH server in the previous ubuntu domU, so it is directly available. I can just ssh to it and start the installation of UML.

ssh vic@145.100.106.84

And we have to make the X environment remotely. So we can run X program from our workstation.

ssh -X vic@145.100.106.84

with the -X option. the remote X gedit works. If it is not working, it is mostly because the X11forwarding is not set to yes in the /etc/ssh/sshd_config

Step 2 Install UML

As instructed in the assignment, I install the UML package by using the following command.

sudo apt-get install user-mode-linux

I then ran the linux.uml to check if it works. It is installed but like stated in the assignment without a proper filesystem it will not work.

vic@vicubuntu:~$ linux.uml 
Locating the bottom of the address space ... 0x10000
Locating the top of the address space ... 0xc0000000
Core dump limits :
	soft - 0
	hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Adding 32485376 bytes to physical memory to account for exec-shield gap
Initializing cgroup subsys cpuset
Linux version 2.6.32.15+drm33.5 (root@palmer) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #2 Tue Aug 17 06:09:58 UTC 2010 ()
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 15997
Kernel command line: root=98:0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
allocated 322460 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
Memory: 26700k available
SLUB: Genslabs=13, HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:15
Calibrating delay loop... 1477.83 BogoMIPS (lpj=7389184)
Mount-cache hash table entries: 512
Initializing cgroup subsys ns
Initializing cgroup subsys cpuacct
Initializing cgroup subsys memory
Initializing cgroup subsys devices
Initializing cgroup subsys freezer
Checking for host processor cmov support...Yes
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
Using 2.6 host AIO
NET: Registered protocol family 16
bio: create slab <bio-0> at 0
Switching to clocksource itimer
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
IRQ 9/mconsole: IRQF_DISABLED is not guaranteed on shared IRQs
mconsole (version 2) initialized on /home/vic/.uml/jrYIfH/mconsole
Checking host MADV_REMOVE support...OK
Mapper v0.1
mmapper_init - find_iomem failed
UML Watchdog Timer
Host TLS support detected
Detected host type: i386 (GDT indexes 6 to 9)
VFS: Disk quotas dquot_6.5.2
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFS: nTxBlock = 209, nTxLock = 1672
SGI XFS with ACLs, security attributes, realtime, large block/inode numbers, no debug enabled
SGI XFS Quota Management subsystem
Btrfs loaded
msgmni has been set to 52
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
SoftDog: cannot register miscdev on minor=130 (err=-16)
TCP cubic registered
NET: Registered protocol family 17
Initialized stdio console driver
Console initialized on /dev/tty0
console [tty0] enabled
Initializing software serial port version 1
console [mc-1] enabled
Couldn't stat "root_fs" : err = 2
Failed to initialize ubd device 0 :Couldn't determine size of device's file
registered taskstats version 1
VFS: Cannot open root device "98:0" or unknown-block(98,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(98,0)
0b86bf08:  [<083cb1c9>] panic+0x4d/0xfc
0b86bf24:  [<08049a36>] mount_block_root+0x200/0x293
0b86bf68:  [<081139c7>] sys_mknod+0x27/0x30
0b86bf7c:  [<08049b24>] mount_root+0x5b/0x60
0b86bf90:  [<08049c6e>] prepare_namespace+0x145/0x181
0b86bfa8:  [<080491b0>] kernel_init+0xe9/0xf5
0b86bfbc:  [<080898d0>] run_kernel_thread+0x30/0x50
0b86bfd8:  [<080898bf>] run_kernel_thread+0x1f/0x50
0b86bfe4:  [<0805ff9f>] new_thread_handler+0x6f/0xa0
0b86bfe8:  [<080490c7>] kernel_init+0x0/0xf5
 
 
EIP: 0073:[<00b81422>] CPU: 0 Not tainted ESP: 007b:bfb46bc8 EFLAGS: 00000246
    Not tainted
EAX: 00000000 EBX: 00000753 ECX: 00000013 EDX: 00000753
ESI: 0000074f EDI: bfb46c48 EBP: 0000002d DS: 007b ES: 007b
0b86bee4:  [<080b5bf1>] notifier_call_chain+0x41/0x60
0b86bf08:  [<083cb1e5>] panic+0x69/0xfc
0b86bf24:  [<08049a36>] mount_block_root+0x200/0x293
0b86bf68:  [<081139c7>] sys_mknod+0x27/0x30
0b86bf7c:  [<08049b24>] mount_root+0x5b/0x60
0b86bf90:  [<08049c6e>] prepare_namespace+0x145/0x181
0b86bfa8:  [<080491b0>] kernel_init+0xe9/0xf5
0b86bfbc:  [<080898d0>] run_kernel_thread+0x30/0x50
0b86bfd8:  [<080898bf>] run_kernel_thread+0x1f/0x50
0b86bfe4:  [<0805ff9f>] new_thread_handler+0x6f/0xa0
0b86bfe8:  [<080490c7>] kernel_init+0x0/0xf5
 
Segmentation fault

Step 3 Setup UML instance

Compile Busybox 1.18.2

I downloaded busybox source from the official website and install the necessary compiler and library and built it.

sudo apt-get install build-essentials libncurses-dev
cd /home/vic/Downloads/busybox-1.18.2/
make menuconfig
make
 
## To verify the compiled object: busybox ##
vic@vicubuntu:~/Downloads/busybox-1.18.2$ ldd busybox
	linux-gate.so.1 =>  (0x00876000)
	libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x003ae000)
	libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00638000)
	/lib/ld-linux.so.2 (0x00932000)

Copy busybox to the bin folder of root folder prepared for the UML instance and create the symbol link

./busybox --help | grep 'Currently defined functions:' -A30 | grep '^\s.*,' | tr , '\n' | xargs -n1 -i{} ln -s busybox {}

This get what the busybox can do from the help function of busybox and recursively add all of them as symbol links to busybox.

Error

I got kernal panic because of the error below

uml /bin/init: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory

The dynamic loaded module is missing for the busybox I previously complied. Got hint from Cosmin that a static build will solve the problem as no module lookup is needed. so I recompiled the busybox with static option selected during the make menuconfig . Afterward, I can start UML without problem.

make the file system for UML

I created under /home/vic a folder named uml to be used as the root of the UML instance. Here is my folder structure under uml folder

vic@vicubuntu:~/uml$ ls -R
.:
bin  dev  etc  lib  mnt  proc  sbin  usr  var
 
./bin:
busybox
 
./dev:
 
./etc:
fstab  init.d  inittab
 
./etc/init.d:
rcS
 
./lib:
 
./mnt:
 
./proc:
 
./sbin:
 
./usr:
 
./var:
log
 
./var/log:

This will copy all the device from the host (Xen ubuntu) to the UML instance.

cp -vdpR /dev/* /home/vic/uml/dev/

The create fstab and inittab

vic@vicubuntu:~$ cat ./uml/etc/fstab 
proc /proc proc defaults 0 0 
 
vic@vicubuntu:~/uml/etc$ cat inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh

The inittab will execute the rcS during the initialization and the rcS should try to mount everything in the fstab. The rcS should be +x

vic@vicubuntu:~/uml/etc/init.d$ cat rcS 
#!/bin/sh
 
mount -a
 
vic@vicubuntu:~/uml/etc/init.d$ chmod +x rcS

Step 4 Run the UML instance

vic@vicubuntu:~/uml/bin$ linux.uml rootfstype=hostfs rootflags=/home/vic/uml/ rw
 
/ # 
/ # ls
bin   dev   etc   lib   mnt   proc  sbin  usr   var
/ # 

I am finally in the UML instance (single mode) next step, make it multiple mode

Error

The eth0 is missing from the UML instance. I got the error number = 13. Check a lot on google found that it is “permission denied” on accessing the switch file /home/vic/umlubuntu/sw1.ctl .

Obviously, in order to start the switch in daemon mode (-daemon option) , I have to “sudo” the uml_switch. So the connector owner is root, and I start the UML instance use my own account, that is why I cannot connect to the switch hence the eth0 will not appear. When I change to sudo the uml instance, the eth0 showed up.

/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr A2:F4:38:6A:8A:89
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:5

lo        Link encap:Local Loopback
          LOOPBACK  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Step 5 Simple network

I start the UMLA and UMLB

#start UMLA
sudo linux.uml umlid=umla rootfstype=hostfs rootflags=/home/vic/uml/ rw eth0=daemon,,unix,/home/vic/umlswitch/sw1.ctl
 
#start UMLB
sudo linux.uml umlid=umlb rootfstype=hostfs rootflags=/home/vic/uml/ rw eth0=daemon,,unix,/home/vic/umlswitch/sw1.ctl

Configuration on UMLA

/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr 16:03:7F:2D:F8:74
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:5
 
lo        Link encap:Local Loopback
          LOOPBACK  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
 
/ # ifconfig eth0 10.0.0.1/8 up
/ # ifconfig lo up

Configuration on UMLB

/ # ifconfig eth0 10.0.0.2/8 up
/ # ifconfig lo up
/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr 52:8F:EC:4D:51:7B
          inet addr:10.0.0.2  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:5
 
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Now the simple network is fully functional

ping from UMLA to UMLB

/ # ping 10.0.0.2
PING 10.0.0.2 (10.0.0.2): 56 data bytes
64 bytes from 10.0.0.2: seq=0 ttl=64 time=12.136 ms
64 bytes from 10.0.0.2: seq=1 ttl=64 time=0.172 ms
64 bytes from 10.0.0.2: seq=2 ttl=64 time=0.173 ms
64 bytes from 10.0.0.2: seq=3 ttl=64 time=0.167 ms
^C
--- 10.0.0.2 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.167/3.162/12.136 ms

ping from UMLB to UMLA

/ # ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: seq=0 ttl=64 time=0.236 ms
64 bytes from 10.0.0.1: seq=1 ttl=64 time=0.169 ms
64 bytes from 10.0.0.1: seq=2 ttl=64 time=0.170 ms
64 bytes from 10.0.0.1: seq=3 ttl=64 time=0.165 ms
^C
--- 10.0.0.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.165/0.185/0.236 ms