Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
User Mode Linux on Debian Jessie

User Mode Linux on Debian Jessie

host kernel version: 3.16.36-1+deb8u2

target kernel version: 4.9-rc5

Build UML kernel


Install build environment:

apt-get install build-essential libtool automake libncurses5-dev kernel-package

Download kernel source code:

wget -O- | tar -xJ
cd linux-4.9-rc5


default config:

make defconfig ARCH=um

change the config as you like:

make menuconfig ARCH=um


make linux ARCH=um

Create a Debian Jessie rootfs


install debootstrap:

apt-get install debootstrap

Create rootfs

Create a file used as root partition:

fallocate -l 4G rootfs

Format with ext4:

mkfs.ext4 rootfs

Mount to a tmp location:

mkdir mnt
mount rootfs mnt

Bootstrap a basic Debian system:

debootstrap jessie mnt

Config rootfs

change password:

chroot mnt /bin/bash

# run `passwd` under chroot environment
passwd root

# exit chroot environment

change fstab:

echo "/dev/ubda / ext4 defaults 0 0" > mnt/etc/fstab

umount rootfs:

umount mnt


install uml-utilities and screen:

apt-get install uml-utilities screen

run UML:

./linux ubda=rootfs eth0=tuntap,,, mem=512M

attach to tty:

screen /dev/pts/1

assign address:

# run in UML
ifconfig eth0 up

add default gateway:

# run in UML
ip route add default via dev eth0

if you want UML get access to extranet, run the fowllowing command in host server:

iptables -t nat -A POSTROUTING -s -j MASQUERADE

This comment has been minimized.

Copy link

zoobab commented May 11, 2017

BTW User-mode-linux is already available as a binary on Jessie, just apt-get install user-mode-linux. It is a 3.16 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.