User Mode Linux (UML)

User Mode Linux (UML) is one of the earliest virtualisation solutions for Linux (the other one is lguest, which is only available for 32-bit kernel).

It has been largely superseded by KVM and of only academic interest these days, but it still has life left in it. For example it can be used to provide relatively easy and safe, secure sandboxing of untrusted applications.

Since 620beta1, Fatdog comes with UML support, all you need to do is install "linux_uml" and "uml_utilities" packages from the repositories and you're good to go. Open terminal, and type "start-uml.sh" and off you go: the script will automatically create a "throwaway" VM with 256M of memory. Shut the VM down by shutting it down from the desktop, or just close the Xephyr window. It is "throwaway" in the sense that as soon as you stopped the session, all is gone - no traces of it is ever saved in your machine, at all.

If you want to be able to save your UML session, create a blank directory somewhere to save your "savefile". Then start UML like this: "start-uml.sh /path/to/your/session/directory". It is important to note that this directory must already exist, otherwise it is ignored and you'll end up with a throwaway session again.
Once UML has run for the first time in this way, it will create a "config" file in that your 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 options in the config file should be self-explanatory but in case it is not, you can look at /usr/lib64/uml/start-uml.sh --- the top of that file contains default settings of these config options as well as their explanation.

Mini-FAQ

1. Q: Why UML, why not KVM or even VirtualBox?
A: UML uses your existing Fatdog setup - no need for separate ISO etc. UML consumes lesser resources (memory and CPU) than a full virtualisation system like KVM or VirtualBox, and I believe it is much easier to setup.

2. Q: Fatdog already has sandbox, so what is this UML for?
A: 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.

3. Q: What can the UML VM do?
A: 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.

4. Q: 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?
A: Of course there is. The point is, these data sharing is completely under your control.

A1. You can setup a "savefile", which can be opened while the VM is offline; from there you can copy data to/from it.

A2. You can copy data using the network (e.g. using samba rox app / yassm, netcat, ssh, rsync, etc).

A3. You can create additional disk images which can be mounted both by the host and by the UML (using ubdxxx parameter - see below). You can open these disk images from host when they are not mounted from UML VM; and when done you can mount them and access the data from the inside the VM.

5. Q: UML only loads Fatdog's base sfs. Is there a way to load additional SFS too?
A: 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. "udb1rc" will show up as "/dev/udbb", "udb2rc" will show up as "/dev/udbc", and so on.
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.

6. Q: UML desktop doesn't show any drive icons.
A: Yes, on purpose. Drive icons needs "udev daemon" and daemons takes up additional resources, so they are not run unless they are absolutely necessary. If you need drive icons do this from terminal; type this in terminal inside the UML VM:
udevd --daemon; udevadm trigger --action=add 


7. Q: Does running UML require root access?
A: No. You can run UML even if you're not root. Inside UML, you're still root :)

8. Q: The UML VM starts with a desktop. I don't need no stinking desktop, give me the console!
A: If you use saved session, edit your config file and empty out the START_CMD option. If you use throwaway session, do it like this:
start-uml.sh "" START_CMD=
You still still get an empty Xephyr window (so that you can type "xwin" later and start a desktop if you wish), if you don't need it just close that Xephyr window.

9. Q: OK, now that I can use console only stuff, I need more consoles. How do I get that?
A: Many ways. The easiest way would be to run:
getty 38400 tty1 &
Replace "tty1" with tty2, tty3 etc as many as you need. A bit of warning: Do not close the xterm windows that are opened automatically, otherwise your UML VM may hang. They will be closed automatically when you close the UML VM.

10. Q: UML is slow!
A: Unlike other virtualisation solutions, UML does not create demand to your CPU - it will simply use whatever idle power which is give to it. The default CPU frequency scaling governor in Fatdog is "ondemand", which means that the CPU power will be raised only when it detects that there is a "demand" / need for it. UML does not create this demand (even though in reality it is running slow), so the 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) while running UML. There is a commented script of how to do so in /etc/rc.d/rc.local.

11. Q: Why this information is not in Fatdog's FAQ?
A: It will, sooner or later. Be patient

12: Q: I need further information!
A1: Visit UML's web page here: http://user-mode-linux.sourceforge.net/old/

A2: See what kernel options are available by opening terminal and running this (from host!):
/usr/lib64/uml/vmlinux --help

A3: See what other script options and how Fatdog's UML works by looking at the scripts in /usr/lib64/uml



Posted on 17 Apr 2013, 6:47 - Categories: Fatdog64
Edit - Delete


Comments:

Posted on 17 Apr 2013, 22:38 by jamesbond
"UML info is now on Fatdog FAQ"
The information is now available in Fatdog's FAQ, here: http://distro.ibiblio.org/fatdog/web/faqs/uml.html.

It is basically a re-hash of this post, with some additional information on the configuration details.

Delete



Add Comment

Title
Author
 
Content
Show Smilies
Security Code 4683115
Mascot of Fatdog64
Password (to protect your identity)