Compiling and Booting the Linux Executable
Just by installing the Debian package user-mode-linux
, I already had a compiled UML kernel ready to boot in user space. (I suggest compiling the kernel by yourself to better understand some concepts of UML.) However, I had to install the uml-utilities
packages for UML administration and configuration. Under the home
directory of a normal user, I got and extracted the last available kernel as follows:
wget –c http://kernel.org/pub/linux/kernel/v2.6/linux-184.108.40.206.tar.bz2
tar –xvjf linux-220.127.116.11.tar.bz2
If you are familiar with Linux kernel compiling, you will recognize all the commands in the remainder of the article, with the exception of the variable setting ARCH=um. This is an important setting that tells the compiler how to build the kernel for the special user-mode architecture. In other words, instead of compiling the kernel for the x86 or ARM CPU architecture, I obtained a kernel running for the user-mode virtual architecture (Jeff Dike, the UML creator, defines it as a port of Linux to Linux) with this command:
make ARCH=um defconfig
I then had a standard configuration of UML that I changed only a little with this command :
make ARCH=um menuconfig
At that point, I completed the following steps to create my Linux executable file:
- Have no modules (otherwise I would have to install the compiled modules in the right place under UML root filesystem):
[ ] Enable loadable module support --->
- Set the right processor in:
Host processor type and features --->
- Don't include all other network support except TUN/TAP:
UML Network Devices --->
[*] Virtual network device
[ ] Ethertap transport
[*] TUN/TAP transport
[ ] SLIP transport
[ ] Daemon transport
[ ] VDE transport
[ ] Multicast transport
[ ] pcap transport
[ ] SLiRP transport
- Disable the support for PPP:
[*] Network device support --->
[ ] PPP (point-to-point protocol) support
- Check whatever option under section:
Kernel hacking --->
|Author's Note: For the sake of completeness, I'll mention the SKAS (Separate Kernel Address Space) kernel patch, which solves some security and performance issues of UML. The standard way is called TT (Tracing Thread) mode.|
- Then finally:
make ARCH=um linux
At the end of the compilation, I had a file called linux that was the executable file to run.
As I already explained, in the command line I can configure the hardware platform upon which I want to run UML. For the first UML, I set these switch variables:
- ubd0=/path/to/file/uml1-rootThis sets the block device from which the system mounts the root filesystem.
- con=pty con0=null,fd:2 con1=fd:0,fd:1These settings deal with the configuration of console terminals.
- eth0=tuntap,the_uml_conn1This is the association of the UML eth0 network interface with the host TAP network interface. A random and fictitious MAC address will be assigned to eth0.
- mem=512MWith this variable you can set the physical RAM memory that the UML will have, regardless to the actual existing one in the host machine.
- umid=uml1-umidThis is a unique identification label for the first UML machine used by some host UML utilities and also by the debugger.
There are a lot of other variables to set; you can read about them on the man pages.
Now I was ready to boot, launching the command:
con=pty con0=null,fd:2 \
See Listing 1 for the complete boot log of first UML.