Friday, September 2, 2011

User Mode Linux - Compiling The kernel

In order to successfully build and run user-mode Linux we need to download and install the following tools and utilities:
  • GCC
  • libstdc++ (In Debian/ Ubuntu: libstdc++6-dev)
  • make
  • ncurses (In Debian/ Ubuntu: libncurses5-dev)
  • uml-utilities
  • debootstrap


After installing the above tools, we need to download the kernel source tree from www.kernel.org. For this guide we are going with the latest stable Linux kernel which is version 3.0. We can download and extract a Linux kernel source tree with the following commands:

host$ mkdir /home/giorgos/uml
host$ mkdir /home/giorgos/uml/linux-src
host$ cd /home/giorgos/uml/linux-src
host$ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
host$ tar xvf linux-3.0.tar.gz

We are now ready to configure our new kernel. We start with the UML default configuration, noting that it is important to define the kernel architecture as ‘um’ (user-mode Linux):


host$ cd linux-3.0
host$ make mrproper ARCH=um
host$ make defconfig ARCH=um


Now, we can select additional kernel options by running:

host$ make menuconfig ARCH=um


Below, is a list of options needed by UML guest in order to work properly. Of course, you can adjust the kernel configuration to your own needs. It’s important to mention that we have selected all the options below as build in, not as modules.

UML-specific options →
         Host processor type and features →
                   Processor family → [choose your processor family]
                   Generic x86 support – disabled

Block devices →
         Virtual block device – enabled
         Loopback device support – enabled
         Network block device support – enabled

Character devices
         stderr console – enabled
         virtual serial line – enabled
         port channel support – enabled
         pty channel support – enabled
         tty channel support – enabled
         xterm channel support – enabled
         (xterm) default console channel initialization
         (pts) defaults serial line channel initialization

Networking support →
         UML Network devices →
                   TUN/TAP transport – enabled

Network device support →
         Universal TAN/TUP device driver support – enabled



It’s time to build our brand new kernel by running:

host$ make ARCH=um
host$ cp linux /home/giorgos/uml/.


During the build we will be asked to specify some additional options for the UML kernel. In this guide we choose the default values, but you can adjust the kernel configuration to your own needs.
When the build finishes, we will have a UML binary called “linux” which we eventually copy in the ‘/home/giorgos/uml’ directory. UML is both a Linux kernel and a Linux process. As a Linux process, it can be run just like any other executable on the system. 


------

No comments:

Post a Comment