User-mode Linux

From ArchWiki
Revision as of 01:25, 24 July 2005 by Iphitus (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What is user-mode-linux?

User-mode-linux (UML) is a method to run linux inside linux as a normal process. Please check [1] for in detail information what uml is and how it works.
This wiki article is a summary of [[| this]] posting. If you have any ideas or suggestions please post them there.

Why use UML?

Running UML is a safe way to run multiple instances of (arch-)linux at the same time. The single processes are seperated from each other, which makes it secure to run for example a testing instance and a productive one on the same machine. If something goes wron inside the testing instance, it does not interfere with the host linux or the productive instance.



Let's start

1.) First you have to create a single, big file into which you will install arch. This command creates a single 1GB file, only conatining zeros - should be enough for a basic arch installation.

dd if=/dev/zero of=archRootFs bs=1MB count=1000

2.) After the build process you have to format the root filesystem image. This command will complain about archRootFs not being a block device. You can safely ignore this or surpress the message by adding -F to mke2fs.

mke2fs archRootFS

3.) After formatting the file you have to mount it. Executing the following command as root does the job:

mount -o loop archRootFs /mnt

4.) Now the installation of the basic system may start. For this you can use the archbootstrap script, which mainly does the same thing as the installation cd but for a certain directory. It is a real basic installation - thus it may take a while!

sh archbootstrap /mnt/ ftp://archlinux-mirror

5.) Before the system can be booted with user-mode-linux, some files inside the arch basic system have to be customised. Add this line to /mnt/etc/fstab:

/dev/ubd0 / ext2 defaults 0 0

To avoid long boot time you are advised to disabled hotplugin in /mnt/etc/rc.conf:

DAEMONS=(syslog-ng !hotplug !pcmcia network netfs crond)

6.) Now unmount the filesystem. NOTE: If you change anything inside your mounted filesystem (e.g. /mnt) while it is running it may lead to significant fs corruption inside your virtual machine and kill it!

umount /mnt

7.) Next step is to setup networking. Therefore you create a so called tun device (Please visit the [uml howto] for further information about tun/tap), and give it an IP adress. The following lines load the necessary tun module, create a tun/tap device that is readable by the users group and set it up with the given ip adress. For security you should consider to create a certain uml group with read permissions for the network device.

modprobe tun
tunctl -u users
chown root.users /dev/net/tun
ifconfig tun0 up

8.) Now you can boot the image. To use the network you have to announce the proper device to the uml kernel. (Mind that the user running the uml command needs enough rights to access the tun device!)

linux ubd0=archRootFs eth0=tuntap,,,

The ",,," mean:

eth0=transport,tuntap device,MAC adress,ip



Have fun playing with uml.