User-Mode Linux is awesome, especially if you are a file systems developer. But getting it running was a little tricky, partly because there is so much documentation! Here are the things I learned about running UML.
There is a summary of how to get, compile, and run UML at the end of this page, but I strongly suggest you read the whole thing first. It will save you a lot of time later.
$ make menuconfig ARCH=um $ make linux ARCH=um $ make clean ARCH=umIf you accidentally run a command without ARCH=um, this will build a .config or the kernel or set up the headers for the wrong ARCH. To fix this, you'll have to do a:
$ make mrproperIf you get tired of forgetting this, you can edit the ARCH= line in the Makefile, but that produces unsightly extra bits when you make patches.
$ ./linux ubd0=/path/to/unzipped/root_fsHowever, you will find yourself continually mistyping this by transposing the 'b' and the 'd' in the "ubd" part. UML helpfully prints out a little message saying that you have probably mistyped this, which promptly scrolls up and off the screen, leaving you to wonder why your root file system can't be mounted. If you say "UML Block Device" out loud several times, you will remember which way to type this. (I would prefer UML just recognized both forms).
$ pkill -9 '^linux$'Be careful if you are running any other process on the system named linux; this command will kill that process too.
$ sudo mount -o loop /path/to/unzipped/root_fs /mnt [edit files] $ sudo umount /mnt
set args ubd0=/path/to/unzipped/root_fs handle SIGSEGV nostop noprint handle SIGUSR1 nopass stop printAbout the gdb signal handler "handle" lines above: UML uses SIGSEGV for internal communication. Without the above instruction to "nostop noprint", gdb will automatically drop into the debugger every time UML sends itself a SIGSEGV. SIGUSR1 is what we will use to stop UML and drop it into the debugger intentionally. Older versions of UML used different signals for different purposes and these may change in the future.
Run gdb as follows:
$ gdb -x ../gdb_commands ./linux [wait for prompt, then type "run"]If you want to drop into the debugger, send it SIGUSR1 (which we have configured gdb to catch in the gdb_commands file above):
$ pkill -SIGUSR1 -o linux
$ make oldconfig ARCH=um $ make linux ARCH=um $ ./linux ubd0=/path/to/unzipped/root_fs [wait for prompt, then login as "root", no password]