0
  Login

HowTo: Install XEN Dom0 on Debian Stretch from source

xen logo
This article assumes you have a clean install of Debian and have root level access to the server. Note this was performed on a minimal install with no desktop.

Prereqs

To be able to perform a successful kernel build, you will need to install the following packages:

apt-get install bc bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig texinfo texlive-latex-base gcc-multilib texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial libncurses5-dev patch libvncserver-dev libsdl-dev gettext libaio1 libaio-dev libssl-dev iasl libbz2-dev git-core uuid-dev python python-dev python-twisted build-essential make gcc libc6-dev zlib1g-dev texlive-latex-recommended e2fslibs-dev libyajl-dev libpixman-1-dev liblzma-dev

XEN Compile and install

Now lets get the XEN tarball and make XEN

cd /usr/src

wget https://downloads.xenproject.org/release/xen/4.9.0/xen-4.9.0.tar.gz

tar xvf xen-4.9.0.tar.gz

cd xen-4.9.0

./configure –enable-githttp –libdir=/usr/lib

make -j 5 xen

make -j 5 tools

make -j 5 stubdom

cd dist/install

cp -R * /

vi /etc/default/xendomains and comment out #XENDOMAINS_SAVE=/var/lib/xen/save

These tweeks should make XEN start at system startup and also create the bridge we need for the DomUs. Please note that rc3.d could be rc2.d depending on your runlevel, check with the command runlevel at the prompt.

ln -s /etc/init.d/xendomains /etc/rc0.d/S10xendomains

ln -s /etc/init.d/xendomains /etc/rc6.d/S10xendomains

ln -s /etc/init.d/xencommons /etc/rc3.d/S98xencommons

ln -s /etc/init.d/xendomains /etc/rc3.d/S98xendomains

ln -s /root/xendom0caps /etc/rc3.d/S98xendom0caps

ln -s /root/iptables-enable /etc/rc3.d/S99iptables-enable (not required)

vi /root/xendom0caps (add xl sched-credit -d Domain-0 -w 512)

chmod +x /root/xendom0caps

vi /etc/rc.local (add /usr/bin/setterm -powersave off -blank 0

vi /etc/xen/xend-config.sxp

find line (network-script network-bridge) and comment out

#network-script network-bridge

vi /etc/xen/xl.conf (disable autoballon)

autoballon=0

Interfaces

As newer versions of XEN can use the system bridge rather than its own script we need to edit the network configuration to invoke our new bridge. Firstly create our new bridge interface. Replace the IP values with your settings.

vi /etc/network/interfaces

auto xenbr0
iface xenbr0 inet static
bridge_ports eth0
address 172.20.45.1
netmask 255.255.0.0
network 172.20.0.0
broadcast 172.20.255.255
gateway 172.20.0.1

Once done reboot to ensure the config applies successfully.

Kernel Compile

Now XEN is complete we need to get our kernel for Dom0. Replace the kernel number with the version you want to use.

cd /usr/src

(Please note the kernel version maybe significantly newer than detailed here)

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.3.tar.xz

tar xvf linux-4.12.3.tar.gz

cd linux-4.12.3

make menuconfig

Go into Processor type and features

pic1

Statically enable all XEN features

pic21

Go back to the main menu and enter Device Drivers menu, then enter block devices menu

pic3

Statically enable the 2 XEN options

pic4

Go back to the Device Drivers menu and go down to XEN driver support

pic5

Statically enable all features

pic7

Go back to Device Drivers, go into Network device support and statically enable the 2 XEN options at the bottom

pic8

Exit out and save.

Note to make sure all options are selected run

cat /usr/src/linux-4.12.3/.config | grep XEN

You should see the same as

CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
CONFIG_XEN_PRIVCMD=y
CONFIG_XEN_ACPI_PROCESSOR=y

If it looks good then continue otherwise please correct before hand.

make -j 5 bzImage

make -j 5 modules

make -j 5 INSTALL_MOD_STRIP=1 modules_install

cp -a arch/x86/boot/bzImage /boot/vmlinuz-4.12.3

cp -a System.map /boot/System.map-4.12.3

cp -a .config /boot/config-4.12.3

depmod –a

mkinitramfs -o /boot/initrd.img-4.12.3 4.12.3

Modify GRUB2 to boot in XEN mode

cd /etc/grub.d

mv 10_linux 50_linux

vi /etc/default/grub

add these lines under GRUB_CMDLINE_Linux””

GRUB_CMDLINE_XEN_DEFAULT=dom0_mem=1024M,max:1024M
GRUB_CMDLINE_XEN=

save and exit

now issue

update-grub

reboot once complete.

About the Author