Sachin Patil

Sachin

Free software developer & Emacser

UML

UML is a port of linux to linux as referred by Jeff Dike, the man behind UML. It is a virtual machine which runs on linux and used to debug new kernel builds and kernel modules. In this post, I will show how to compile, and run UML

Compile

Download latest kernel source from kernel.org, as of this writing, the kernel version was 3.14.2

wget -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.2.tar.xz

Un-compress and visit the directory

tar -xvJf linux-3.14.2.tar.xz
cd linux-3.14.2

Clean previous configs, blobs using

make mrproper; make mrproper ARCH=um; make clean

Load default host config

make defconfig ARCH=um

If you don’t start with a defconfig, then the kernel build will be that of the host(it will find a config file in /boot), which is not appropriate for UML and will produce a UML that lacks vital drivers and won’t boot.

make menuconfig ARCH=um

Select host processor type and features

Linux kernel menuconfig
Figure 1: Linux kernel menuconfig

Save and exit menuconfig window.

Finally, compile the kernel

make linux ARCH=um

The result will be 2 binaries, vmlinuz & linux

Run

Boot your newly compiled kernel using

./linux

This should die with a message something like

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(98,0)
UML kernel panic
Figure 2: UML kernel panic
  • Boot with rootfs
    • Now that the kernel was unable to find roofs, you can download rootfs from http://fs.devloop.org.uk/
    • Add a parameter ubda followed by your rootfs path. Optionally, you may also add a mem parameter to specify amount of RAM your UML should use.

      ./linux ubda=/path/to/rootFS mem=128M
      
UML: Boot with rootfs
Figure 3: UML: Boot with rootfs
UML: login prompt
Figure 4: UML: login prompt