Building XEN dom0 and domU Linux kernels

Introduction

You need at least Linux v4.2 for the XEN dom0/U code to be available.

Slackware 14.2 has v4.4 so that’s fine – you could just recompile the sources provided from the K set.

Slackware current always tracks the latest longterm tagged kernel so that’s VERY fine also.

But let us get things staight with the very latest stable version. Oh, and we are also applying the latest available REISER4 patch to it (check it first to see what 5.x release it matches against).

As for domU, latest available TMEM kernel was 5.2.21.

Scripts

This guide has been replaced and implemented as scripts already.

Quick & dirty for a minimal working XEN environemnt

Full-blown kernel with many things incl. Docker and REISER4 support

Requirements

Slackware

slackpkg search elfutils
slackpkg search bc

Preparing

cd /usr/src/
screen -S kernel-build

grab the latest stable kernel source tarball and verify

cd /usr/src/
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.9.12.tar.gz
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.9.12.tar.sign
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.21.tar.gz
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.2.21.tar.sign

gunzip linux-5.9.12.tar.gz
gunzip linux-5.2.21.tar.gz
#unxz

#gpg2 --recv-keys 0x6092693E --keyserver wwwkeys.pgp.net
#TODO gpg --receive-keys 0x6092693E
gpg --verify linux-5.9.12.tar.sign
gpg --verify linux-5.2.21.tar.sign

Primary key fingerprint: 647F 2865 4894 E3BD 4571  99BE 38DB BDC8 6092 693E

or xen testing

#git clone git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git
#cd tip/
#git reset --hard
#git checkout -b xen-next origin/linux-next
#git pull

eventually grab the latest REISER4 patch

lynx -dump https://sourceforge.net/projects/reiser4/files/reiser4-for-linux-5.x/README.txt

# dom0
wget https://sourceforge.net/projects/reiser4/files/reiser4-for-linux-5.x/reiser4-for-5.9.2.patch.gz

# domU
wget https://sourceforge.net/projects/reiser4/files/reiser4-for-linux-5.x/reiser4-for-5.2.0.patch.gz

if so, also make sure you’ve installed REISER4PROGS onto your system

lynx -dump https://sourceforge.net/projects/reiser4/files/reiser4-utils/libaal/README.txt
wget https://sourceforge.net/projects/reiser4/files/reiser4-utils/libaal/libaal-1.0.7.tar.gz
tar xzf libaal-1.0.7.tar.gz
cd libaal-1.0.7/
./configure
echo $MAKEFLAGS
nice make
nice make install

lynx -dump https://sourceforge.net/projects/reiser4/files/reiser4-utils/reiser4progs/README.txt
wget https://sourceforge.net/projects/reiser4/files/reiser4-utils/reiser4progs/reiser4progs-1.2.2.tar.gz
tar xzf reiser4progs-1.2.2.tar.gz
cd reiser4progs-1.2.2/
./configure
echo $MAKEFLAGS
nice make
nice make install

you are now ready to run the kernel building scripts

#./build0.bash # 14m24.761s for slackcurrent on ryzen5 laptop
./buildom0.ksh 
./buildomU.ksh 

Dom0 clean-up

headers

eventually get rid of older and unused kernels (slackware 142)

#removepkg /var/log/packages/kernel-*4.4.*  

however if you get rid of kernel headers too early you get

kernel "fatal error: linux/errno.h: No such file or directory"

TODO try this once again once you’ve build the new kernel and rebooted

header symlinks

also make sure those are in place

ls -lF /lib/modules/`uname -r`/build
ls -lF /lib/modules/`uname -r`/source

==> should symlink against /usr/src/KERNEL

DomU modules

as XEM_TMEM module keeps being a module, we need to deliver it to the guests to use TMEM

guest=GUEST

cd /data/guests/$guest/
fsck.ext4 $guest.ext4
mkdir lala/
mount -o loop,rw $guest.ext4 lala/

mkdir -p lala/lib/modules/
ls -alkF lala/lib/modules/
rm -rf lala/lib/modules/*
#for ball in `ls -1 /data/kernels/lib.modules.*.tar.gz`; do
#        echo -n $ball...
#        tar xzf $ball -C lala/lib/modules/ && echo done
#done; unset ball
tar xzf /data/kernels/lib.modules.$version.tar.gz -C lala/lib/modules/
ls -alkF lala/lib/modules/

cat lala/etc/modules
echo tmem >> lala/etc/modules

umount lala/
rmdir lala/
xl create $guest -c

and verify that everything works as expected onto a new guest, including TMEM and Docker,

zcat /proc/config.gz | grep TMEM
zcat /proc/config.gz | grep CLEANCACHE
lsmod | grep tmem
watch free -m

zcat /proc/config.gz | grep OVERLAY
docker ps -a

Dom0-only – enable at boot-time

You’re now good to handle booting with your boot-loader of choice

Resources

xen

Xen https://wiki.gentoo.org/wiki/Xen

Mainline Linux Kernel Configs https://wiki.xenproject.org/wiki/Mainline_Linux_Kernel_Configs

kernel config

Kernel/Traditional compilation https://wiki.archlinux.org/index.php/Kernels/Traditional_compilation

Complete Handbook/Building the Linux kernel https://wiki.gentoo.org/wiki/Complete_Handbook/Building_the_Linux_kernel

What exactly does Linux kernel’s make defconfig do? https://stackoverflow.com/questions/41885015/what-exactly-does-linux-kernels-make-defconfig-do

CONFIG_IKCONFIG: Kernel .config support https://cateee.net/lkddb/web-lkddb/IKCONFIG.html

Kernel/IKCONFIG Support https://wiki.gentoo.org/wiki/Kernel/IKCONFIG_Support

Chapter 8. Customizing a Kernel https://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ch08s02.html

tools/make-kernel-config https://github.com/juergh/tools/blob/master/make-kernel-config

Kernel/Configuration https://wiki.gentoo.org/wiki/Kernel/Configuration

Universal TUN/TAP device driver. https://www.kernel.org/doc/Documentation/networking/tuntap.txt

Obtain kernel config from currently running Linux system? https://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system

docker

Use the OverlayFS storage driver https://docs.docker.com/storage/storagedriver/overlayfs-driver/

Verify your Linux Kernel for Container Compatibility https://blog.hypriot.com/post/verify-kernel-container-compatibility/


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH