Nethence Newdoc Olddoc Lab Your IP BBDock  

XEN FROM SCRATCH

No Budget!

How many cores?

Compilation was done on some enterprise-class IBM servers dating 2007 with 4x4 Xeon processors and 96 GB or RAM. For 16 cores in total and with 1 thread per core (lscpu), I obtained the fastest results with -j16 for xen versus -j24 for tools and stubdom. Anyway, tune the number of make jobs according to your hardware.

Overall requirements (xen + tools + stubdom)

for pkg in \
    bison \
    flex \
    gcc \
    git \
    glibc \
    make \
    openssl \
    patch \
    pciutils \
    texinfo \
    ; do
    echo -n $pkg:
    ls -1 /var/log/packages/ | grep ^$pkg-[[:digit:]]
done; unset pkg

Compiling XEN (the micro-kernel)

fetch the latest release e.g.,

cd ~/
wget https://downloads.xenproject.org/release/xen/4.10.0/xen-4.10.0.tar.gz
wget https://downloads.xenproject.org/release/xen/4.10.0/xen-4.10.0.tar.gz.sig
gpg xen-4.10.0.tar.gz.sig
gpg --recv-key 57E82BD9
gpg xen-4.10.0.tar.gz.sig
#
# Primary key fingerprint: 23E3 222C 145F 4475 FA80  60A7 83FE 14C9 57E8 2BD9
#

note. if you want current,

#git clone git://xenbits.xen.org/xen.git

compile,

tar xzf xen-4.10.0.tar.gz
cd xen-4.10.0/
#make clean-xen
time make -j16 xen > make.xen.log && echo done
#tail -F make.xen.log
time make install-xen > make.installxen.log && echo done
#tail -F make.installxen.log
ls -lhF /boot/xen.gz
ls -lhF /boot/xen-4.10.0.gz

Tools and Stubdom requirements

installing the latest ACPICA,

cd ~/
wget https://acpica.org/sites/acpica/files/acpica-unix-20171215.tar.gz
#wget https://acpica.org/sites/acpica/files/acpica-unix2-20171215.tar.gz
tar xzf acpica-unix-20171215.tar.gz
cd acpica-unix-20171215/
time make -j24 > make.acpica.log && echo done
make install
cd ../

installing pixman using Slackpkg,

slackpkg install pixman

installing yajl using sbopkg,

slackpkg search yajl
sbopkg -s yajl
sbopkg -i yajl

installing the corresponding multilib version of gcc and glibc (and installing compat32-tools),

cd ~/
mkdir -p 14.2/
cd 14.2/
lftp -c 'open http://slackware.com/~alien/multilib/ ; mget -c 14.2/*'
upgradepkg --reinstall --install-new *.t?z
ls -1 /var/log/packages/ | grep ^compat32-tools-[[:digit:]]
ls -1 /var/log/packages/ | grep ^glibc-[[:digit:]]
ls -1 /var/log/packages/ | grep ^gcc-[[:digit:]]

Compiling the Tools and Stubdom

(XEN fetched previously) – compile,

cd ~/xen-4.10.0/
which bcc-cpp
export PATH=$PATH:/usr/lib64/bcc
./configure

#make distclean
#time make -j24 world > make.world.log && echo done
#tail -F make.world.log

#make clean-tools
time make -j24 tools > make.tools.log && echo done
#tail -F make.tools.log

#slack3
#real   2m57.747s
#user   15m59.347s
#sys    4m27.916s

#make clean-stubdom
time make -j24 stubdom > make.stubdom.log && echo done
#tail -F make.stubdom.log

make install-tools
make install-stubdom

Compiling the Linux dom0 kernel

4.2 required, Slackware 14.2 has 4.4

building the dom0 capable kernel (this also makes it domU capable but we do not care!),

ls -lhF /usr/src/
cd /usr/src/linux/
make distclean
#make mrproper

cp -pi Makefile Makefile.dist
vi Makefile

EXTRAVERSION = .xen

ls -al .config
ls -al /boot/config
cp /boot/config .config
make xenconfig
time make -j24 > make.log && echo done
#tail -F make.log

#real   14m59.666s
#user   188m25.223s
#sys    39m3.343s

ls -al /lib/modules/
make modules_install

this does not harm even though we might switch to extlinux,

ls -l /boot/vmlinuz.old
mv /etc/lilo.conf /etc/lilo.conf.dist
sed '/^$/d; /^#/d' /etc/lilo.conf.dist > /etc/lilo.conf
cat >> /etc/lilo.conf <<-EOF
#image = /boot/vmlinuz-huge-4.4.88
image = /boot/vmlinuz.old
  root = /dev/sda1
  label = slack4488
  read-only
EOF
make install
ls -l /boot/config
mv /boot/config /boot/config.old
cp .config /boot/config

note. assuming lba32 and timeout = 100 (10 seconds) have already been set up.

(optional) – eventually try to boot this xen-enabled kernel w/o xen as hypervisor,

#sync
#shutdown -r now

Booting with mbootpack

slackpkg search mbootpack
sbopkg -s mbootpack
sbopkg -i mbootpack
cd /boot/
zcat xen-4.10.0.gz > xen-4.10.0
mkinitrd -c -o initrd.gz -k 4.4.88 -r /dev/sda1
zcat initrd.gz > initrd
mbootpack -o xenvmlinuz -m vmlinuz -m initrd xen-4.10.0
vi /etc/lilo.conf

default = xen4488
#default = slack4488

image = /boot/xenvmlinuz
  root = /dev/sda1
  label = xen4488
  read-only

lilo
sync
shutdown -r now

notes.

refs.

Booting with SYSLINUX/EXTLINUX

THIS SECTION IS A DRAFT — XEN kernel is not booting because of wrong initrd params

I used XFS instead of EXT4 as root partition (I do not seperate /boot). Slackware 14.2 has extlinux v4.07 and XFS support is only available since v5.01.

Make sure the needed partition has the bootable flag (assuming good old MBR table) — yes, the SYSLINUX boot code is looking for it,

fdisk -l /dev/sda

Fetch, compile and install the latest SYSLINUX,

wget https://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/6.04/syslinux-6.04-pre1.tar.gz
wget https://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/6.04/sha256sums.asc
tar xzf syslinux-6.04-pre1.tar.gz 
cd syslinux-6.04-pre1
time make > make.log && echo done
make install

extlinux -v
mkdir -p /boot/extlinux
extlinux --install /boot/extlinux
cp /usr/share/syslinux/*.c32 /boot/extlinux/

vi /boot/extlinux/extlinux.conf

ui menu.c32
prompt 0
menu title SYS
timeout 100
default XEN

label Linux
        kernel /boot/vmlinuz
        append root=/dev/sda1 ro

label Previous
        kernel /boot/vmlinuz.old
        append root=/dev/sda1 ro

label XEN
        kernel mboot.c32
        append /xen.gz dom0_mem=1024M --- /boot/vmlinuz root=/dev/sda1 ro --- /boot/initrd.gz

The XEN-enabled kernel needs an initrd to avoid kernel panic (attempted to kill init!),

mkinitrd -c -o /boot/initrd.gz -k 4.4.14 -r /dev/sda1

ls -lF /usr/share/syslinux/mbr.bin
cat /usr/share/syslinux/mbr.bin > /dev/sda
sync
shutdown -r now

refs.

Networking

See XEN // Networking.

Ready to go

cat /sys/hypervisor/properties/capabilities

cp -pi /etc/ld.so.conf /etc/ld.so.conf.dist
cat >> /etc/ld.so.conf <<-EOF
/usr/local/lib
EOF
cat /etc/ld.so.conf
ldconfig
xl info

/etc/rc.d/init.d/xencommons start
cat >> /etc/rc.d/rc.local <<-EOF
#self verbose
/etc/rc.d/init.d/xencommons start
EOF
cat /proc/xen/capabilities
xl li

cat /sys/class/net/bond0/bonding/miimon
cat /sys/class/net/bond0/bonding/mode 
cat /sys/class/net/bond0/bonding/lacp_rate
brctl show

libvirt capable (optional)

slackpkg install libpciaccess
sbopkg -i libvirt
sbopkg -i libvirt-python
sbopkg -i virt-manager
sbopkg -i virt-viewer

cat /etc/sysctl.d/60-libvirtd.conf
sysctl fs.aio-max-nr=1048576

/usr/sbin/libvirtd -d
cat >> /etc/rc.local <<-EOF

echo -n starting libvirt...
/usr/sbin/libvirtd -d && echo done
EOF

virsh list

References

OBSOLETE

installing latest YAJL,

#cd ~/
#git clone git://github.com/lloyd/yajl
#./configure
#make -j24
#make install

mbootpack from source,

#cd ~/
#git clone https://github.com/timdeegan/mbootpack.git
#cd mbootpack/
#make
#cp mbootpack /usr/local/bin/

install,

#cp xen/xen.gz /xen4100.gz
#ls -lhF /xen.gz
#ln -sf xen4100.gz /xen.gz

mounted by xencommons,

cat >> /etc/fstab <<-EOF
xenfs /proc/xen xenfs defaults 0 0
EOF
mount /proc/xen/

Home | GitHub | Docker Hub | Donate | Contact