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.
UML .config for fs development
This has, among other things, the setting to require synchronous I/O to the file containing the file system image. This is a requirement for doing file system development, otherwise it is like having a disk that lies continually about whether it has written your data.
$ make menuconfig ARCH=um $ make linux ARCH=um $ make clean ARCH=um
$ 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.
Download this file and unzip it. It is an image of an ext2 file system, mountable as a block device from UML.
$ ./linux ubd0=/path/to/unzipped/root_fs_valHowever, 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 losetup -f /path/to/unzipped/root_val_fs $ sudo fsck /dev/loop0 $ sudo losetup -d /dev/loop0
$ sudo mount -o loop /path/to/unzipped/root_val_fs /mnt [edit files] $ sudo umount /mnt
set args ubd0=/path/to/unzipped/root_fs_val handle SIGUSR1 nostop noprintThen run gdb as follows:
$ gdb -x ../gdb_commands ./linux [wait for prompt, then type "run"]
$ make oldconfig ARCH=um $ make linux ARCH=um $ ./linux ubd0=/path/to/unzipped/root_fs_val [wait for prompt, then login as "root", no password]