Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
Last active December 10, 2022 21:32
Show Gist options
  • Save bnoordhuis/5b630317ac812e291b0b to your computer and use it in GitHub Desktop.
Save bnoordhuis/5b630317ac812e291b0b to your computer and use it in GitHub Desktop.
Setting up User Mode Linux on Fedora 20

user mode linux: build and run

Generate default .config.

$ make defconfig ARCH=um SUBARCH=x86_64

Build the linux ELF binary.

$ make -j8 linux ARCH=um SUBARCH=x86_64

Create the rootfs. Note the absolute path; supermin 5.1.9 fails with relative paths. --use-installed speeds up the --prepare step but skips files that are inaccessible to non-root users, like files in /usr/sbin.

$ supermin -v --prepare bash coreutils mount -o $PWD/rootfs.template
$ supermin -v --build --format chroot rootfs.template -o $PWD/rootfs

Create a bootstrapper shell script.

$ cat > rootfs/boot/boot.sh
#!/bin/bash
mount -t sysfs /sys /sys
mount -t proc /proc /proc
exec /bin/bash
^D
$ chmod +x rootfs/boot/boot.sh

Start the UML instance with the rootfs mounted read/write. Note again the absolute path.

$ ./linux rootfstype=hostfs rootflags=$PWD/rootfs rw init=/boot/boot.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment