Installing User Mode Linux

Michael McCabe - COSI

Demetrios Dimatos - COSI

Revision History
Revision 0.522 Jan 2006
Initial draft


This article will show you how to do a basic installation of usermode linux on a kernel.

Table of Contents

Download, configure and build
Creating your filesystem
Other Resources


Comments on this tutorial may be directed to Michael McCabe

Comments on this tutorial may be directed to Demetrios Dimatos


This document, Installing User Mode Linux is copyright (c) 2006 by the Clarkson Open Source Institute. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at


No liability for the contents of this document can be accepted. Use the concepts, examples and information at your own risk. There may be errors and inaccuracies, that could be damaging to your system. Proceed with caution, and although this is highly unlikely, the author(s) do not take any responsibility.

All copyrights are held by their by their respective owners, unless specifically noted otherwise. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements.


There are several tools and utilities that you will need to have installed in order to successfully build and run user-mode linux. Some of these tools are optional though, such as the ones that are required to have networking for your guests and some other ones are required for you to proceed. Here is a list of the tools that you must have installed.

  • GCC-This tutorial was completed with gcc4. The mileage that you may get with other versions of gcc may vary.

  • libstdc++ - in some distributions libstdc++ is GCC, but with Ubuntu it was needed to perform, sudo apt-get install libstdc++6-dev to obtain the needed stdc libs.

  • tar and bzip-Required for extracting the kernel source.

  • make-Used for the kernel build system.

  • ncurses-Ncurses and the development file is used to run the kernel configuration program menuconfig. To install on Ubuntu, sudo apt-get install libncurses5-dev

Here is a listing of some of the optional tools that you may need.

  • telnet-Can be used to connect to guests over there serial lines

  • uml-utilities-Is used to setup serial ports and setup networking on the various parts of the system.

  • debootstrap-Used to create debian or other debian based filesystem images.

  • yum-Can be used to create images of rpm based linux distributions.

Download, configure and build


Before we begin we will need to download the kernel source tree. There are several mirrors that have the kernel source code available for download. For this tutorial we are going with the version of the Linux kernel.

Example 1. Downloading the Kernel


If you download a version of the kernel that is earlier than 2.6.9 you will also need to download a seperate patch for the uml architecture.

At this point we can now extract the kernel source code. In this example we will be extracting it in the current user's home directory.

Example 2. Unpacking the package

		#cd ~/
		#tar -xvjf linux-


We are now ready to configure our kernel for building it. There are many different kernel options that you will need to select in order to build a fully functional kernel. We will also turn on kernel debugging support and debug symbols. The following command will launch the kernel configuration program menuconfig

Example 3. Kernel Configuration

	#cd linux-
	#make ARCH=um menuconfig

Here is a listing of options that you may need to disable or change in order to build a fully functioning kernel .

  • Loadable module support
    	->Enable loadable module support 	- Not Required
    	  Note:We can't debug these so having this option enabled would be a waste
  • UML Specific Options
    	-> Host Processor type features 
    		-> Generic x86 support - Disable this
    		-> Processor family (386) 
    			-> Choose your proccessor , I chose PIII that coresponded to my laptop.
  • Networking
    	-> Amateur Radio                     - Not Required
    	-> IRDA (infrared) Subsystem Support - Not Required
    	-> Blue tooth Subsytem Support       - Not Required
  • Character devices 
    	-> stderr console 	 - Enable 
    	-> virtual serial line 	 - Enable
    	-> port channel support  - Enable
    	-> pty channel support 	 - Enable 
    	-> tty channel support 	 - Enable
    	-> xterm channel support - Enable
  • Block Devices
    	-> Virtual block devices - Enable
  • UML Network Devices
    	- You may or may not want to turn on the different network options under 
    	  these settings. Consult the uml websitefor more information on these devices.
  • File systems
    	- To make my kernel build faster I only enabled the couple of filesystems
    	  that I knew that I would need (ext3 was one of them)
  • SCSI support
    	-> SCSI support	- Disable
  • Multi-device support (RAID and LVM)
    	-> Multiple devices driver support (RAID and LVM) - Disable
  • Memory Technology Devices (MID)
    	-> Memory Technology Device (MID) support - Disable
  • Kernel Hacking 
    	-> Show timing information on printks - Enable
    	-> Kernel debugging 		      - Enable
    	-> Compile the Kernel with Debug Info - Enable


At this point we can now begin building the linux kernel.

Example 4. Building the kernel

	#make ARCH=um linux	

When this step is completed you will have a fully functioning user mode linux kernel. This step will take a while, depending on the speed of your machine.

Creating your filesystem

Debian is suprisingly simple to install inside of user mode linux. To begin you must initialize the files using dd. This example assumes that your image files are /opt/uml/debian-root.

Example 5. Creating your filesystem

	#dd if=/dev/zero of=/opt/uml/debian-root bs=1024K count=1000

Now we will initialize the filesystems inside of each of these files. We will be using ext3 as our root filesystem.

Example 6. Initializing the filesystems

	#mkfs.ext3 /opt/uml/debian-root

Now we will need to mount the root filesystem before we run debootstrap.

Example 7. Mounting root

	#mkdir /mnt/debian
	#mount -o loop /opt/uml/debian-root /mnt/debian

Now we will install debootstrap and bootstrap a base Debian installation. This is a barebones installation that is less than 200 megs.

Example 8. Debian Installation

	#apt-get install debootstrap
	#debootstrap --arch i386 sarge /mnt/debian
	or you may want to use the breezy installation.
	#debootstrap --arch i386 breezy /mnt/debian

At this point your system is an unconfigured base system. You will need to edit the following files in order to have your system in a valid configuration.

  • /etc/fstab

  • /etc/hostname

  • /etc/hosts

  • /etc/network/interfaces

  • /etc/apt/sources.list

  • /etc/securetty

  • /etc/inittab

Example 9. FSTAB configuration

	/dev/ubd0	/	ext3	defaults	0 1
	proc		/proc	proc	defaults	0 0

Example 10. Host configuration

You will need to make sure that /etc/hostname contains the following line or your nameing preference.


You will need to make sure that /etc/hosts contains the following line. localhost

At this point you will need to setup your network interface configuration. This is done by editing the file /etc/network/interfaces. This guest will have a loopback network device. More information on configuring network devices under Debian can be found in the Debian Reference.

Example 11. The loopback network interface

	auto lo
	iface lo inet loopback

The above should be in the file /etc/network/interfaces. You'll also need to add a mirror or cdrom image to /etc/apt/sources.list

Example 12. /etc/securetty Configuration

	#echo "tty0" >> /etc/securetty
	#echo "ttys/0" >> /etc/securetty

Example 13. /mnt/debian/dev

In the breezy debootstrap example no node was created for me to mount the file system too, you can check this by,

	#cd /mnt/debian/dev
	#ls ubd*
	If this does not return ubd0 then,
	#mknod --mode=660 ubd0 b 98 0
	#chown root:disk ubd0

Example 14. Edit /etc/inittab

This will allow you to login immediately after the boot messages

	Comment out the following lines:
	  2:23:respawn:/sbin/getty 38400 tty2 
	  3:23:respawn:/sbin/getty 38400 tty3
	  4:23:respawn:/sbin/getty 38400 tty4
	  5:23:respawn:/sbin/getty 38400 tty5
	  6:23:respawn:/sbin/getty 38400 tty6
	Now modify tty1 to say tty0, the result should look like this:
	  1:2345:respawn:/sbin/getty 38400 tty0
	  #2:23:respawn:/sbin/getty 38400 tty2
	  #3:23:respawn:/sbin/getty 38400 tty3
	  #4:23:respawn:/sbin/getty 38400 tty4
	  #5:23:respawn:/sbin/getty 38400 tty5
	  #6:23:respawn:/sbin/getty 38400 tty6

Example 15. Add user to the file system

Before you can log into the file system you must add a user to be ablet logi in with.

	#chroot /mnt/debian
	#adduser uml
	Aswer the following questions about the new user or press enter followed by a yes at the end

Example 16. Run the kernel with UML

	#sudo umount /mnt/debian
	#sudo ./linux ubd0=/opt/uml/debian-root

Other Resources