HOWTO UML

From Gentoo Linux Wiki

Jump to: navigation, search
This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

This page is a candidate for deletion 
Reason given: Stub; Incomplete and lacking content compared to HOWTO User Mode Linux; Duplicate of HOWTO User Mode Linux
If you disagree with its deletion, please explain why on its discussion page.
If you intend to fix it, please remove this notice, but do not remove this notice from articles that you have created yourself.
Make sure no other pages link here and check the page's history before deleting.

Contents

[edit] Introduction

User-Mode Linux is also called UML.

The official documentation is outdated and targeted at developers, so we will install User-Mode Linux differently.


[edit] Installation

First you need to choose a kernel.

I don't know the differences between vanilla and user-mode very well...

A file inside the usermode tree says to check the changelog here

[edit] Kernel

[edit] UML package

unmask the testing package and install it

echo "sys-kernel/usermode-sources" >> /etc/portage/package.keywords
emerge usermode-sources

then configure and compile the kernel

cd /usr/src/linux-2.6.15-usermode/
make xconfig ARCH=um
make ARCH=um

[edit] Any other kernel(gentoo-sources example)

install the kernel

emerge gentoo-sources

configure and compile the kernel

cd /usr/src/linux-2.6.15-gentoo-r1
make xconfig ARCH=um
make ARCH=um

[edit] rest of the installation

<add modules compilation procedure here>

then we will install usermode-utilities

emerge usermode-utilities

[edit] root image

We will need to use a loop image as the default configuration (others options are possible)

The following is for a 1000MB loop, you can change the 1000 value to watever you want

dd if=/dev/zero of=root_fs seek=1000 count=1 bs=1M

then you'll need to apply a filesystem (I used reiserfs but you can use other filesystems, even squashfs if you used gentoo kernel or patched your kernel with the squashfs patch (there is even a usermode-linux filesystem developed in order to have a read-only image and write changes to another image [very useful if you have a lot of uml instances,you can use the same base and write changes to another file...])

mkreiserfs -f root_fs

then i made a stage3 install

mkdir /mnt/loop
mount root_fs /mnt/loop/ -o loop
wget http://gentoo.osuosl.org/releases/x86/2005.1-r1/stages/pentium3/stage3-pentium3-2005.1-r1.tar.bz2.md5
wget http://gentoo.osuosl.org/releases/x86/2005.1-r1/stages/pentium3/stage3-pentium3-2005.1-r1.tar.bz2
md5sum -c stage3-pentium3-2005.1-r1.tar.bz2.md5
tar -xvjpf stage3-pentium3-2005.1-r1.tar.bz2 -C /mnt/loop
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2.md5sum
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2
md5sum -c portage-latest.tar.bz2.md5sum
tar -xvjpf portage-latest.tar.bz2 -C /mnt/loop/usr/

at this point the image installation is not finished...you still need to remove and add some services and uttilities

for exemple we need to emerge hotplug(so we will have udev(already there?)) and coldplug(?) (please tell me if it's useless)

cp /etc/resolve.conf /mnt/loop/etc/

then we will chroot,chrooting in a real tty is better than doing it with an x console

chroot /mnt/loop /bin/bash
emerge -F coldplug
emerge syslog-ng

Then you'll need your filesystem uttilities, in this case I used reiserfs (see gentoo handbook)

emerge reiserfsprogs
<insert apps here...see official gentoo doc>
rm /mnt/loop/etc/resolv.conf

before exiting we will need to modify /etc/fstab in the loop

nano /mnt/loop/etc/fstab

add this: (and # the necessary lines)

/dev/ubda        reiserfs        defaults  0 1

[edit] Booting the kernel and image

Be careful as you'll need the following things to sucessfully boot:

  • an unmounted root_fs
  • sufficient ram/swap for handling udev
  • sufficient permissions on root_fs
linux ubd0=root_fs mem=128M 

(I've 320MB of ram->try less ram-<minimum requirement)

[edit] Settings with usermode uttilities

[edit] Networking

you now have UML working... but you need networking: (i've put a soft link to my kernel executable and my rootfs is named root_fs)

./vmlinux eth0=tuntap,,,<your tuntap ip adress from your main computer>

exemple: the ip of the computer is 192.168.1.107

./vmlinux eth0=tuntap,,,192.168.1.108

then in uml:

ifconfig eth0 up
ifcongig eth0 192.168.1.109 netmask 255.255.255.0

and then you can ping and ssh into the uml from your host computer

[edit] Limitation

  • mabe in x86 the amount of ram that can use a single process is limited
  • limited to 2.6 kernels because UML is integrated into the 2.6 series and there is no 2.4 kernel that is patched in portage
  • see ports on others architectures and os...
  • performances???(the comparison with xen was done with 2.4 kernels...need a new comparison)

[edit] Advantages

  • doesn't need recompilation of the apps,and the patch is included in most of the 2.6 kernels (so you only need to recompile the kernel of the linux distrib that you want to run,after having configuring it with some uml options)
  • you can run multiple uml instances on one filesystem (the changes are written in a separate file)
  • you can configure it in order to behave exactly as a normal kernel(see honypot aplications in the uml homepage)

[edit] Others programs

[edit] Troubleshooting

[edit] could not find any device /dev/loop

If you get

mount root_fs /mnt/loop/ -o loop
mount: could not find any device /dev/loop#

Then make sure you have Loopback device support enabled in the kernel. If you're using a 2.6 kernel:

Linux Kernel Configuration: Loopback device support
 Device drivers --->
 Block devices --->
 Loopback device support

In my case, I just had to modprobe it (loop).

Personal tools