Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

grantm (164)

grantm
  (email not shown publicly)
http://www.mclean.net.nz/

Just a simple [cpan.org] guy, hacking Perl for fun and profit since way back in the last millenium. You may find me hanging around in the monestary [perlmonks.org].

What am I working on right now? Probably the Sprog project [sourceforge.net].

GnuPG key Fingerprint:
6CA8 2022 5006 70E9 2D66
AE3F 1AF1 A20A 4CC0 0851

Journal of grantm (164)

Tuesday December 21, 2004
10:22 PM

UML under Debian Sarge

[ #22411 ]

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 up

You'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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.