Fatdog64 User Mode Linux (UML) Environment

Introduction

According to User Mode Linux website, User Mode Linux (UML for short) is:

User-Mode Linux is a safe, secure way of running Linux versions and Linux processes. Run buggy software, experiment with new Linux kernels or distributions, and poke around in the internals of Linux, all without risking your main Linux setup.

User-Mode Linux gives you a virtual machine that may have more hardware and software virtual resources than your actual, physical computer. Disk storage for the virtual machine is entirely contained inside a single file on your physical machine. You can assign your virtual machine only the hardware access you want it to have. With properly limited access, nothing you do on the virtual machine can change or damage your real computer, or its software.

UML is one of the earliest attempt at Linux virtualisation (the other one being lguest, which is even lighter than UML but unfortunately only runs on 32-bit kernel). It has been largely superseded by more advanced technologies Kernel-mode Virtual Machine (KVM) and Linux Containers (lxc), and is probably considered to be of only academic interest these days, however it still has life left in it. For example it can be used to provide relatively easy and safe, secure sandboxing of untrusted applications.

Fatdog (since version 620) comes with User Mode Linux (UML) environment. All you need to do to use it, is to install linux_uml and uml_utilities packages, from the Package Manager.

Note for Fatdog64 700 users: if you are familiar with UML operation in Fatdog64 600 series, please read on. The way UML is configured has changed.

Usage

Starting up

To start using if, after installing the packages, all you need is open a Terminal (there is no GUI for this), and type start-uml.sh. This will start a "throwaway" UML VM (or UML "guest") with 256MB of RAM. A window will open with the UML desktop in it.

Shutting down

You can shutdown the UML VM by:

It is "throwaway" because as soon as you stop the UML VM, all the information in it is gone - there will be no traces left. In this way, UML is very useful for testing purposes.

Persistent UML

To run a persistent UML session (i.e., to be able to the states between UML shutdown and restart), do the following:

  1. Make an empty directory to contain the UML session. This directory must be large enough to contain UML's "savefile".
  2. Start UML like this: start-uml.sh /path/to/session/directory

Once UML has run for the first time in this way, it will create a "config" file in that session directory; which you can edit later. A 128MB savefile is also automatically created for you; if you need anything bigger, just delete that savefile and edit the config to specify a larger value - the savefile will be re-created when you restart UML next time. See below for the details of the config file.

Launching UML without graphical desktop

By default, UML will start with a graphical desktop. If you don't want the graphical desktop, start it like this:

The Xephyr window will still open (so that you can type "xwin" to launch a graphical desktop later). If you don't need it, just close it after it opens.

UML session config options

You can put a file named config in the session directory to configure UML's behaviour. This file is automatically created (with default values) if it doesn't exist, or you can create it yourself before you start UML for the first time.

The file contains configuration variables, as follows. Any of these settings can be "blanked" by not specifying the value, e.g. you can blank RAM_SIZE by putting RAM_SIZE= inside the config file.

Note: A few of the variables you define in the config file can be overridden by putting them into the command line when you start UML, for example when starting UML without graphical desktop as above.

Questions and Answers

Question: Why UML, why not KVM or even VirtualBox?
Answer: UML is much smaller, use less resources, makes use of your existing Fatdog installation (no need for separate ISO files), and easier to setup. You can run UML with only 32MB (for text-mode applications) - you can't do that with KVM or VirtualBox.


Question: Fatdog already has sandbox, so what is this UML for?
Answer: Fatdog's sandbox isn't meant for security. It was originally devised for testing foreign packages, so while it can be used for other purposes, there is information leakages to/from the sandbox; and this is intentional - otherwise you'll face problems when testing. For example sandbox and the host shares the same "/tmp" directory. Fatdog's UML however, doesn't suffer from such problem - host and UML guest is completely separate. E.g. If you choose "shutdown" from sandbox's desktop, you will shutdown your entire system (not only the sandbox). Not so with UML. Choosing "shutdown" from UML's desktop will just shutdown UML VM.


Question: What can the UML VM do?
Answer: Almost everything the host system can do. Browse internet, run network applications (servers), etc. Probably not good enough to watch videos, though - there is no video acceleration in UML.


Question: I understand that the UML is isolated, but is there a way to pass data to/from the the UML? Otherwise how can I ever do anything worthwhile with UML?
Answer: Of course there is. The point is, these data sharing is completely under your control.


Question: UML only loads Fatdog's base sfs. Is there a way to load additional SFS too?
Answer: Yes. Specify additional SFS like this (assuming you want to use a throwaway session):

start-uml.sh "" ubd1rc=/path/to/your/sfs ubd2rc=/path/to/your/sfs, etc

where udb1rc will show up as /dev/udbb inside the UML VM, udb2rc will show up as /dev/udbc, and so on.

Then to load these SFS, once you're inside the UML VM, open terminal and type:

load_sfs.sh /dev/udbb
load_sfs.sh /dev/udbc

and so on. If you're using persistence then replace "" with path to your session directory.


Question: Does running UML require root access?
Answer: No. You can run UML even if you're not root. Inside UML, however, you are root ☺


Question: How do I quit the UML properly?
Answer: Choose "Shutdown" from the desktop menu if you run UML with the desktop (default).  If you start UML without the desktop, terminate UML by running poweroff the console window.


Question: OK, now that I can use console only stuff, I need more consoles. How do I get that?
Answer: Run this: setsid getty 38400 tty1 inside the UML VM. An xterm window will be opened that represents your new "console".

Replace tty1 with tty2, tty3, etc as many as you need.

Warning: Once the xterm windows are opened, do not close them; closing them will cause UML to hang. These xterms will automatically be closed when you stop your UML session.


Question: UML is slow!
Answer: Unlike other virtualisation solutions, UML does not create demand on CPU - it will simply use whatever idle power which has been given. The default CPU frequency scaling governor in Fatdog is "ondemand", which means that the CPU power will be controlled by "demand" - if the CPU power is not needed then the frequency of the CPU will lowered to save power and lower down the temperature too. If it detects that there is a "demand" or need for it, it will then increase the frequency to make the CPU more powerful so that it can do its job faster.

UML does not create this demand (even though in reality it is running slow), so the "ondemand" governor does not think it necessary to make the CPU go faster. To fix this, temporarily change the default CPU frequency scaling governor from the default "ondemand" to "performance" (which means run the CPU at full power at all times) while running UML. There is a commented script of how to do so in /etc/rc.d/rc.local.

Alternatively, you can use NICE_CMD configuration options (or run renice if you have already started the UML session) so that the UML kernel will get more priority. This can only be done when you run UML as root.


Further information