XEN guest // Bootstrapping Slackware

tested on Slackware 14.2

assuming the domU kernel has already been prepared

mkdir -p /data/guests/$guest/
cd /data/guests/$guest/

Guest configuration

cat > $guest <<EOF
kernel = "/data/kernels/vmlinuz"
root = "/dev/xvda1 ro console=hvc0 mitigations=off"
#extra = "init=/bin/bash"
name = "$guest"
memory = 1024
vcpus = 4
disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.ext4,xvda1,w']
#disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.reiser4,xvda1,w']
#disk = ['phy:/dev/vdisks/thin1,xvda1,w']
#disk = ['phy:/dev/drbd1,xvda1,w']
vif = [ 'bridge=xenbr0, vifname=$guest.0' ]

Virtual disks

either create a raw sparse file

dd if=/dev/zero of=$guest.ext4 bs=1024k count=0 seek=10240

or a QCOW2 sparse file


or a freaking drbd thin provisioned vdisk


then format and mount it

mkfs.ext4 $guest.ext4
mkdir lala/
mount $guest.ext4 lala/

#dd if=/dev/zero of=$guest.swap bs=1024k count=0 seek=2048
#mkswap $guest.swap

as for LVM thin provisioning

mkfs.reiser4 -y /dev/vdisks/thin1
fsck.reiser4 -y /dev/vdisks/thin1
mkdir lala/
mount /dev/vdisks/thin1 lala/

as for DRBD (possibly over LVM thin provisioning)

mkfs.reiser4 -y /dev/drbd1
fsck.reiser4 -y /dev/drbd1
mkdir lala/
mount /dev/drbd1 lala/

Install script

wget https://pub.nethence.com/bin/slack/slackinst.bash.txt
cp slackinst.bash.txt slackinst.bash
chmod +x slackinst.bash
#rm -rf lala/*
vi slackinst.bash


./slackinst.bash lala/

Install setup from XEN host

ls -ldF lala/dev/pts/ #exists
ls -ldF lala/dev/shm/ #exists
ls -lF lala/etc/fstab #noexist yet

cat > lala/etc/fstab <<-EOF
/dev/xvda1 / ext4 defaults 1 1
#/dev/xvda1 / reiser4 defaults 1 1
#/dev/xvda2 swap swap defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
vi lala/etc/fstab

if this is a REISER4 file-system, let the guest eventually fsck itself at boot time

installpkg --terse --root lala/ /data/libaal-1.0.7-x86_64-1_SBo.tgz
installpkg --terse --root lala/ /data/reiser4progs-1.2.1-x86_64-2_SBo.tgz

disabling useless shit from rc.d – tag ADD

ls -lF lala/etc/rc.d/rc.cpufreq
ls -lF lala/etc/rc.d/rc.loop
ls -lF lala/etc/rc.d/rc.modules
ls -lF lala/etc/rc.d/rc.modules.local
chmod -x lala/etc/rc.d/rc.cpufreq
chmod -x lala/etc/rc.d/rc.loop
chmod -x lala/etc/rc.d/rc.modules
chmod -x lala/etc/rc.d/rc.modules.local

disabling useless shit from rc.d – tag REC

ls -lF lala/etc/rc.d/rc.bluetooth
ls -lF lala/etc/rc.d/rc.cgmanager
ls -lF lala/etc/rc.d/rc.cgproxy
ls -lF lala/etc/rc.d/rc.inetd
chmod -x lala/etc/rc.d/rc.bluetooth
chmod -x lala/etc/rc.d/rc.cgmanager
chmod -x lala/etc/rc.d/rc.cgproxy
chmod -x lala/etc/rc.d/rc.inetd

ls -lF lala/etc/rc.d/rc.consolekit
ls -lF lala/etc/rc.d/rc.mcelog
#chmod -x lala/etc/rc.d/rc.consolekit
#chmod -x lala/etc/rc.d/rc.mcelog

checking overall enabled scripts

ls -lF lala/etc/rc.d/
ls -lF lala/etc/rc.d/rc.udev #already executable

fix the xen guest serial console

ls -lF lala/sbin/agetty lala/etc/termcap
cp -pi lala/etc/inittab lala/etc/inittab.dist
vi lala/etc/inittab

c1:12345:respawn:/sbin/agetty --noclear 115200,38400,9600 hvc0 linux

ls -lF lala/etc/securetty
echo hvc0 >> lala/etc/securetty

fix the timezone

ls -lF lala/etc/localtime-copied-from lala/etc/localtime
rm -f lala/etc/localtime-copied-from lala/etc/localtime
ln -s ../usr/share/zoneinfo/Europe/Moscow lala/etc/localtime
#ln -s ../usr/share/zoneinfo/Europe/Paris lala/etc/localtime

enable TMEM

ls -alF lala/lib/modules/
rm -rf lala/lib/modules/*
ls -lF /data/kernels/lib.modules.*
tar xzf /data/kernels/lib.modules.5.2.14.domureiser4.tar.gz -C lala/lib/modules/
echo '/sbin/modprobe tmem' >> lala/etc/rc.d/rc.modules.local
cat lala/etc/rc.d/rc.modules.local
ls -lF lala/etc/rc.d/rc.modules*
chmod +x lala/etc/rc.d/rc.modules*

avoid a boot time error on powersave

cp -pi lala/etc/rc.d/rc.M lala/etc/rc.d/rc.M.dist
chmod -x lala/etc/rc.d/rc.M.dist
vi lala/etc/rc.d/rc.M

#/bin/setterm -blank 15 -powersave powerdown -powerdown 60

eventually proceed with a brutal network setup

and finish up (minimal 1.3G / full 6.5G)

du -sh lala/
umount lala/

eventually make a guest template out of this and unless you want to proceed with a full postinstall

ls -lF lala/etc/ssh/ssh_host_*
rm -vf lala/etc/ssh/ssh_host_*

what a pleasure, a clean and minimal bsdish gnu/linux distro

xl create $guest -c

eats only 46 MB of RAM while idling for some time

root@darkstar:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            137          46          15           0          75          61
Swap:             0           0           0

Rescue mode

extra = "init=/bin/bash"

mount -o remount,rw /
export TERM=xterm
dmesg | grep hvc


mount -n -o remount,ro /
halt -p


setterm: cannot (un)set powersave mode: Inappropriate ioctl for device

==> disable that ACPI call from rc.M - see above

mount: mount point /dev/pts does not exist
mount: mount point /dev/shm does not exist

==> re-enable rc.udev

interesting shit happens when you install the l and n sets before a and ap, for the record,

installpkg --root lala slackware64/l/glibc-2.23-x86_64-1.txz...sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory

installpkg --root lala slackware64/l/polkit-0.113-x86_64-2.txz...grep: etc/passwd: No such file or directory
grep: etc/group: No such file or directory

installpkg --root lala slackware64/n/openssh-7.2p2-x86_64-1.txz...grep: etc/shadow: No such file or directory

Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml