I recently needed a clean install of Debian stable (to extract some shared library files) and didn't have a spare machine, so I did my first ever installation of User-mode Linux (UML). I found this article which helped a bit but wasn't Debian specific enough. There were a few gotcha's but I got there in the end. Here are my notes for posterity ...
The 'user-mode-linux' package is not stable enough to be in Sarge, so apt-get user-mode-linux wouldn't find it. Strangely, the companion package 'uml-utilities' is available. Anyway, I downloaded the .deb from here and installed it with dpkg --install.
Next I needed a root filesystem image, which I got from here. I created a directory 'uml' in which I put the bunzip'ped filesystem (renamed to root_fs) and a symlink to /usr/bin/linux. Then I booted it up with this command:
./linux
It did boot, but failed with this error when trying to fsck the root filesystem:
fsck.ext2: No such file or directory while trying to open /dev/ubd/0
This turned out to be because UML assumes devfs and the Debian root filesystem image didn't contain it. The solution was grab the 'devfsd' package from here and then create my own modified root filesystem with this package installed in it:
mv root_fs root_fs-dist dd if=/dev/zero of=root_fs count=1 bs=1k seek=$[4*1024*1024] mkfs -t ext3 root_fs mkdir /mnt/m1 mkdir /mnt/m2 mount -o loop -t ext2 /home/grant/uml/root_fs-dist /mnt/m1 mount -o loop -t ext3 /home/grant/uml/root_fs /mnt/m2 cp -a /mnt/m1/* /mnt/m2 rm -r /mnt/m2/lib/modules/* cp -a /usr/lib/uml/modules/* /mnt/m2/lib/modules/ cp devfsd_1.3.25-1_i386.deb /mnt/m2/ umount /mnt/m1 umount /mnt/m2 ./linux mount -n -o remount,rw / dpkg --install /devfsd_1.3.25-1_i386.deb halt
Now I was able to succesfully boot with one extra parameter on the kernel command line:
./linux devfs=mount
I then created a swap file:
dd if=/dev/zero of=swapfs bs=1k count=1 seek=$[512*1024] mkswap swapfs
and added it into the /etc/fstab in root_fs
/dev/ubd/1 none swap sw 0 0
So now the command to boot up UML is:
./linux devfs=mount ubd1=swapfs
That gave me a working system that enabled me to identify and extract the shared library files that I originally needed, so at this point I was done. I did dabble with networking enough to get it functioning here's how I did it (there are many options)...
The host kernel needed the 'tun' module loaded (modprobe tun) and I adjusted the permissions on /usr/lib/uml/uml_net to: -rwsr-x--x (4751?). Then when I booted up the UML instance I gave it my workstation's IP address as a tunnel end-point:
./linux devfs=mount ubd1=swapfs eth0=tuntap,,,192.168.2.77
Then I needed to bring up the interface in the virtual machine (with it's own IP address):
ifconfig eth0 192.168.2.222 upYou'd probably want to set up name servers in /etc/resolv.conf and a default router too. As I say, I didn't play with this much as I'd achieved my objective.