Spring 2010 CS380L
User-Mode Linux
This document is about how to setup the environment for UML
programming
assignments on UTCS machines. It worked for me when this document
was written but you might encounter problems when doing yourself. The
links provided
at the end of this document might help.
Diskspace
5GB disk space quota allowed to graduate students(or 1GB for
undergrads) on CS machines
might not be sufficient for programming assignments. You can use local
disk partition at
/var/local/ on CS machines instead. This partition typically has 30+
GB and also is not
part of NFS system which would be faster.
* If you have your CS desktop at your cubicle, ask gripe@cs to create a
directory at /var/local.
You can use /var/local partition space exclusively. Note
that /var/local is NOT part of NFS system
and thus you always need to logon to your desktop.
* If you do not have your CS desktop, you can create your directory at
/var/local on any CS public
machines. However you need to share disk space at
/var/local partition with others in this case.
Compiling UML
Download kernel from kernel.org and apply patches if available.
2.6.33-rc5 version with patches applied was used when this document
was written.
* Download, unzip, and go to the directory.
* Type 'make ARCH=um menuconfig' to enter the configuration.
* For now, compile things that you want statically(marked *) instead
of as modules(marked M).
* Default setting worked for me but make sure that tty support is
enabled.
* Then save, and exit.
* Compile the kernel by 'make ARCH=um linux'. This might take a while.
* When it's complete, you will get a binary file 'linux'.
Tools you need to run UML
To run UML and enable network you need some binary files. Get them
from
here.
You need to decompress them and add the path to the PATH environment
when running UML.
Root Filesystem
Currently we could not find a way to build one's own root filesystem
without root privilege on
CS machines. There are a lot of root filesystem images available
on-line so you can download
one and use it. I used images downloaded from
here and
here.
All images I tested worked OK.
Booting UML
Now you're ready to boot UML. Remember to add the path to uml
utilities downloaded above
to PATH environment(or at least let UML to be able to find the files).
Then run,
linux ubd0=PATH_TO_ROOT_FS_FILE eth0=slirp,,slirp
mem=128M
Or you can run this if you don't want to touch the original filesystem
image and use a COW file.
In this case all changes will be recorded to COW_FILE
and you can revert to the original filesystem
by deleting COW_FILE at any time.
linux ubd0=COW_FILE,PATH_TO_ROOT_FS_FILE eth0=slirp,,slirp
mem=128M
Network
To enable network, after UML is booted, do the following in UML.
* Open /etc/resolv.conf and add correct addresses of name servers.
The best way is to open /etc/resolv.conf of the host
machine and copy the addresses.
* Open /etc/network/interfaces and modify the 'eth0' entry as follow.
Here, pick your own xx, yy,
and zz value. 10.xx.yy.zz must not be used
by someone else.
auto eth0
iface eth0 inet static
address 10.xx.yy.zz
netmask 255.0.0.0
gateway 10.xx.yy.zz
* Run "ifdown eth0 && ifup eth0".
Now you should be able to access the internet.
Mounting the host filesystem in UML
You can run this command.
mount none PATH_IN_UML -t hostfs -o PATH_IN_HOST_FILESYSTEM
This lets you easily copy files between UML and the host machine.
Modifying filesystem images on host machine
Currently we are looking for a way to do this on CS machine without
root privilege.
Useful Links
UML Wiki
Old UML document (still has many usefil links)
About UML (mostly from Jeff Dikes book "User Mode Linux")