Operating Systems

DM510, Spring 2015

Daniel Merkle

User-mode Linux at IMADA

In the following we describe how to install and use User-mode Linux (UML) for DM510 at IMADA.

Everything was tested on the IMADA pool machines that run Ubuntu 14.04 (Trusty Tahr) and we strongly recommend to use such a system. You can of course login to these machines via the ssh command.

Please note that the Weekly notes for week 08 give additional infomation on how to run UML on the IMADA terminal room machines.

How to install User-mode Linux at IMADA

Login at any IMADA machine and write

mkdir dm510
cd dm510

Next, get the source code for the Linux kernel 3.7.8 and unpack it

wget http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.18.2.tar.gz 
gunzip linux-3.18.2.tar.gz
tar -xvf linux-3.18.2.tar
rm linux-3.7.8.tar

Enter the directory containing the kernel source files:

cd linux-3.18.2

To make this a working copy of UML you also need a root filesystem, that you can copy to your directory. The filesystem is based on a Debian 7.0 system. Note, that the root filesystem has a size of approx. 300MB, and that the uncompressed compiled kernel use approx.

cp /home/daniel/DM510-2015/root_fs  . 

You are now ready to start compling the kernel and using UML.

How to compile User-mode Linux

We need a configuration file fore compling the linux kernel. Create it with

make defconfig ARCH=um 

Now we're ready to compile the kernel. Do it with

 make ARCH=um linux

and have a cup of coffee or tea, because this will take a while (if you want to use several cores for compilation you can add the option "-j 4"). When the compilation is finished, you will find a file called linux in your directory. Everything is set to start UML.

How to run User-mode Linux

User mode linux is started with

./linux

or

./linux con1=xterm con2=xterm

(see FAQ below).

When running UML, you can login using the user name root with no password. If you want to access data from your home directory inside UML, you have to mount the corresponding directory. This is done with

mkdir /mnt/tmp
mount none /mnt/tmp -t hostfs -o /home/your_imada_login/dm510

Of course your_imada_login has to be replaced by your IMADA login. The corresponding directory will be mounted as a subdirectory of /mnt/tmp inside UML. To stop the UML system you can run the command halt. After starting UML you two new windows will appear, your desktop should approx. look like the following:

The UML virtual console

UML Frequently asked questions (FAQ)

  • My kernel panics, if I start User Mode Linux. What is the reason?
  • There can be many reasons for that. But if you stopped UML by just closing the window where UML was running in, there will be still two processes named linux left, and UML will start with a kernel panic next time. You have to kill these processes, for example with killall -9 linux. After that, UML should start again. It is a good idea to stop UML always with the command halt.

  • Where can I get more information on UML?
  • The User-mode Linux Kernel Home Page can be found here.

  • How was the root file system created?
  • The root file system was created with a small script, you usually need to have root access to a machine to be able to create a root filesystem. If you are really interested take a look here.

  • How do I get another window for login to this UML?
  • UML supports two virtual consoles that you can login (in addition to the main console). First you need to find out the device names at your host machine for these two UML virtual consoles. To do that you can login to UML as root and run dmesg. Find the strings like Virtual console N assigned device '/dev/pts/X'. Then, in your host machine, run screen /dev/pts/X to be connected to the virtual console. You can also do that with a new xterm as: xterm -e screen /dev/pts/X
    Alternatively you can add a command line option when you boot the linux kernel: ./linux con1=xterm con2=xterm will open two windows where you can find a console in.

  • My linux kernel does not start anymore! Help!
  • In case you messed up the attached file system, this might just happen. It is always good to have a copy of that, i.e., the file root_fs. Furthermore, sometimes it helps to kill all hanging kernels with killall -9 linux and/or to remove the directory where UML stores temporary data with rm -Rf ~/.uml/. Very often it also a memory issue, and your virtual linux does not have enough main memory. You can for example assign 128M main memory to your virtual system by starting the kernel with ./linux mem=128M

    .
  • Everything is so slow! Help!
  • Your home directory on the IMADA terminal room machines is "mounted", i.e., the hard disk where the data is stored is not the machine that you are working with. However, if you work in a subdirectory of the directory /tmp, then the data IS stored on the local hard disk. This makes things much faster (compilation of the kernel, unpacking the kernel, running UML, ...). However, please note, that a reboot of the machine will remove any data in /tmp. Therefore, do not forget to copy anything you did.

Design by 1234.info | Modified by Daniel Merkle | CSS 2.0