Penguin
Note: You are viewing an old revision of this page. View the current version.

With all the recent activity happening with Linux being ported to things, people started running out of hardware to port linux to. So one smart cookie decided to port Linux to uh, Linux! And thus the User Mode Linux project was born.

User mode linux is basically a program that lets you run linux as a normal process under linux.

To get it running under debian sid I did
apt-get install user-mode-linux

you then want to add yourself to the uml-net group. I didn't find this documented anywhere, but if you don't do this, you'll get weird random messages when you try and use networking under user-mode-linux. People in this group can do nasty things to your network so only give it to people you trust yadda yadda yadda. Remember to logout/login again after making this change

Then, I created a 512 mb "hard disk"

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

and formatted it with ext2

mke2fs ./root_fs

then mounted it as a loop back device

mkdir x && mount -o loop ./root_fs uml

then built my disto on it

debootstrap woody uml /mirrors/debian

you can then boot uml

linux single rw devfs=mount eth0=tuntap,,,the-ip-of-your-host-machine

it'll boot up into single user mode so you can configure and finalise the installation

ifconfig eth0 the-ip-of-your-uml-machine netmask the-netmask route add -net 0 gw the-ip-of-your-gateway apt-get update apt-get upgrade

You don't need lilo, and it gets in the way, so lets get rid of it.

apt-get remove lilo

Now lets configure all the packages

dpkg-reconfigure -a tzconfig

now before we reboot we need to create some files that the installer usually creates

echo /dev/ubd/0 / ext2 defaults,errors=remount-ro 0 1 >/etc/fstab echo none /proc proc defautls 0 0 >>/etc/fstab

echo hostname-of-your-uml-machine >/etc/hostname

and lets set up networking on boot

echo 'auto lo' >/etc/network/interfaces echo 'iface lo inet loopback' >>/etc/network/interfaces echo 'auto eth0' >>/etc/network/interfaces echo 'iface eth0 inet static' >>/etc/network/interfaces echo ' address address-of-your-uml-box' >>/etc/network/interfaces echo ' netmask netmask >>/etc/network/interfaces echo ' network network >>/etc/network/interfaces echo ' broadcast broadcast >>/etc/network/interfaces echo ' gateway gateway >>/etc/network/interfaces

and setting the hardware clock will always fail in uml

rm /etc/rcS.d/hwclock

now, lets configure /etc/inittab correctly, replace tty1 with vc/0, tt1 with vc/1 in the file.

and now lets copy the modules over

mkdir -p /mnt/host mount none /mnt/host -o / -t hostfs mkdir -p /lib/modules/`uname -r`/kernel cp -r /mnt/host/usr/lib/uml/modules/`uname -r`/kernel/* /lib/modules/`uname -r`/kernel depmod -a

for me it complains about the scsi devices, since this is a virtual kernel, I figure i don't need them so I deleted them then rerun depmod

and now your box should be ready to boot again, so shutdown -h now the box then

linux devfs=mount eth0=tuntap,,,10.100.1.8 ro

voila, it should boot up, pop up some windows and ask you to login!


or you can do it the easy way. copy /etc/rootstrap/rootstrap.conf into the current working directory, edit the networking config (don't meddle with too many of the options, many of them don't work if you change them, for instance installing sid doesn't work...) and run (in the same directory)

./rootstrap root_fs

wait a significant time. you now have a uml image installed. you can start it with

./linux th0=tuntap,,,ip-of-your-host-machine ro

you're done.


Traps for young players

If you receive the following error when trying to start your uml process with networking:

Exec of 'uml_net' failed - errno = 2
tuntap_open_tramp failed - errno = 22
SIOCSIFFLAGS: Invalid argument

I tried EVERYTHING to get rid of this. Finally the solution was VERY simple. Run as a standard user, who is in the uml-net group, and not as root. Note: This is a "works for me". I still don't know why this solved the problem, only that it did. Also, another oddity is that AFTER I had run it as a user, I could then run it as root with no problems. This smacks of tap0 being created with incorrect permissions or some oddity. Anyway, it works now.