Difference between revisions of "User-mode Linux"

From ArchWiki
Jump to: navigation, search
(http -> https://aur.archlinux.org)
m (update to user-mode-linux 3.3.4, but still require modify to let it work)
Line 1: Line 1:
 
{{i18n|User-mode Linux}}
 
{{i18n|User-mode Linux}}
{{out of date}}
 
 
[[Category:Virtualization]]
 
[[Category:Virtualization]]
 
==== What is user-mode-linux?====
 
==== What is user-mode-linux?====
Line 28: Line 27:
 
4.) Now the installation of the basic system may start:
 
4.) Now the installation of the basic system may start:
 
  mkdir -p /mnt/var/lib/pacman
 
  mkdir -p /mnt/var/lib/pacman
  pacman -S base -r /mnt
+
  pacman -Sy base -r /mnt
 +
cd /mnt/dev
 +
mknod --mode=660 ubd0 b 98 0
 +
chown root:disk ubd0
  
 
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 {{ic|/mnt/etc/fstab}}:
 
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 {{ic|/mnt/etc/fstab}}:
Line 34: Line 36:
  
 
To avoid long boot time you are advised to disabled hotplugin in {{ic|/mnt/etc/rc.conf}}:
 
To avoid long boot time you are advised to disabled hotplugin in {{ic|/mnt/etc/rc.conf}}:
  DAEMONS=(syslog-ng !hotplug !pcmcia network netfs crond)
+
  DAEMONS=(syslog-ng network crond)
  
 
6.) Now unmount the filesystem. <b>NOTE:</b> If you change ''anything'' inside your mounted filesystem (e.g. {{ic|/mnt}}) while it is ''running'' it may lead to significant filesystem corruption inside your virtual machine and ''kill'' it!
 
6.) Now unmount the filesystem. <b>NOTE:</b> If you change ''anything'' inside your mounted filesystem (e.g. {{ic|/mnt}}) while it is ''running'' it may lead to significant filesystem corruption inside your virtual machine and ''kill'' it!
Line 41: Line 43:
 
7.) Next step is to set up networking. Therefore you create a so called tun device (Please visit the [http://user-mode-linux.sourceforge.net/old/UserModeLinux-HOWTO.html uml howto] for further information about tun/tap), and give it an IP address. 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 address. For security you should consider to create a certain uml group with read permissions for the network device.
 
7.) Next step is to set up networking. Therefore you create a so called tun device (Please visit the [http://user-mode-linux.sourceforge.net/old/UserModeLinux-HOWTO.html uml howto] for further information about tun/tap), and give it an IP address. 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 address. For security you should consider to create a certain uml group with read permissions for the network device.
 
  modprobe tun
 
  modprobe tun
  tunctl -u users
+
  tunctl -g users
 
  chown root.users /dev/net/tun
 
  chown root.users /dev/net/tun
  ip addr add 192.168.0.100/24 dev tun0
+
  ip addr add 192.168.0.100/24 dev tap0
  
 
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!)
 
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=rootfs eth0=tuntap,,,192.168.0.100
+
  vmlinux ubd0=rootfs eth0=tuntap,,,192.168.0.100
  
 
The ",,," mean:
 
The ",,," mean:
Line 52: Line 54:
  
 
Example:
 
Example:
  eth0=tuntap,tap0,3f:2a:bb:00:00:00,192.168.3.23
+
  eth0=tuntap,tap0,3f:2a:bb:00:00:00,192.168.0.100
  
 
Have fun playing with uml.
 
Have fun playing with uml.

Revision as of 08:52, 2 May 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

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 wrong inside the testing instance, it does not interfere with the host linux or the productive instance.

HOWTO

Prerequisites:

  • User-mode-linux kernel (user-mode-linux)
  • uml_utilities, especially the tunctl programm (installed automatically with the uml kernel)

Let us start

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

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

2.) After the build process you have to format the root filesystem image:

mke2fs -F rootfs

3.) After formatting the file you have to mount it. Executing the following command as root does the job (you have also to load the loop module with modprobe):

mount -o loop rootfs /mnt

4.) Now the installation of the basic system may start:

mkdir -p /mnt/var/lib/pacman
pacman -Sy base -r /mnt
cd /mnt/dev
mknod --mode=660 ubd0 b 98 0
chown root:disk ubd0

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 network 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 filesystem corruption inside your virtual machine and kill it!

umount /mnt

7.) Next step is to set up 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 address. 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 address. For security you should consider to create a certain uml group with read permissions for the network device.

modprobe tun
tunctl -g users
chown root.users /dev/net/tun
ip addr add 192.168.0.100/24 dev tap0

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!)

vmlinux ubd0=rootfs eth0=tuntap,,,192.168.0.100

The ",,," mean:

eth0=transport,tuntap device,MAC address,ip

Example:

eth0=tuntap,tap0,3f:2a:bb:00:00:00,192.168.0.100

Have fun playing with uml.