host kernel version: 3.16.36-1+deb8u2
target kernel version: 4.9-rc5
Install build environment:
apt-get install build-essential libtool automake libncurses5-dev kernel-packageDownload kernel source code:
wget -O- https://cdn.kernel.org/pub/linux/kernel/v4.x/testing/linux-4.9-rc5.tar.xz | tar -xJ
cd linux-4.9-rc5
default config:
make defconfig ARCH=umchange the config as you like:
make menuconfig ARCH=umbuild:
make linux ARCH=uminstall debootstrap:
apt-get install debootstrapCreate a file used as root partition:
fallocate -l 4G rootfsFormat with ext4:
mkfs.ext4 rootfsMount to a tmp location:
mkdir mnt
mount rootfs mntBootstrap a basic Debian system:
debootstrap jessie mnt http://ftp.cn.debian.org/debianchange password:
chroot mnt /bin/bash
# run `passwd` under chroot environment
passwd root
# exit chroot environment
exitchange fstab:
echo "/dev/ubda / ext4 defaults 0 0" > mnt/etc/fstabumount rootfs:
umount mntinstall uml-utilities and screen:
apt-get install uml-utilities screenrun UML:
./linux ubda=rootfs eth0=tuntap,,,192.168.80.254 mem=512M
attach to tty:
screen /dev/pts/1assign address:
# run in UML
ifconfig eth0 192.168.80.1 upadd default gateway:
# run in UML
ip route add default via 192.168.80.254 dev eth0if you want UML get access to extranet, run the fowllowing command in host server:
iptables -t nat -A POSTROUTING -s 192.168.80.0/24 -j MASQUERADE
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.