XEN guest // Bootstrapping Slackware

tested on Slackware 14.2 and current

assuming the domU kernel has already been prepared

Virtual disks


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

either create a raw sparse file

dd if=/dev/zero of=$guest.reiser4 bs=1GB count=0 seek=8

RAM should be in GiB not GB

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

a QCOW2 sparse file


or a freaking drbd thin provisioned vdisk


then format and mount it

mkfs.reiser4 -fy $guest.reiser4
#fsck.reiser4 -y $guest.reiser4
mount $guest.reiser4 lala/

#mkswap $guest.swap

as for LVM thin provisioning over DRBD

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

as for DRBD (possibly over LVM thin provisioning)

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

Deploy and setup

from the XEN host directly

cd ../
wget https://pub.nethence.com/bin/slack/slackinst.bash.txt
mv -i slackinst.bash.txt slackinst.bash
chmod +x slackinst.bash
#this may loose _some_ sparse out of the file...
#rm -rf lala/*
vi slackstart.conf #newfile


wget https://pub.nethence.com/bin/slack/postxen.bash.txt
mv postxen.bash.txt postxen.bash
chmod +x postxen.bash

cd slack/
../slackinst.bash lala
mkdir ../slack-pkgs/
mv *.txz FILE_LIST tagfile ../slack-pkgs/

chroot lala/
cd /var/log/packages/
ls -1 kernel*
removepkg kernel-* >/dev/null && echo clean
removepkg floppy lilo reiserfsprogs smartmontools gpm ntp gptfdisk >/dev/null && echo clean
../postxen.bash $guest

Setup manually

this is otherwise automated using the postxen.bash script, see right above

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

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
cat lala/etc/fstab

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

wget https://slackware.uk/slackonly/14.2-x86_64/libraries/libaal/libaal-1.0.6-x86_64-1_slonly.txz
wget https://slackware.uk/slackonly/14.2-x86_64/system/reiser4progs/reiser4progs-1.1.0-x86_64-2_slonly.txz

installpkg --terse --root lala/ libaal-1.0.6-x86_64-1_slonly.txz
installpkg --terse --root lala/ reiser4progs-1.1.0-x86_64-2_slonly.txz

Get rid of a few packages unnecessary packages for XEN/PV

removepkgs="kernel-* floppy lilo reiserfsprogs smartmontools ntp"
for pkg in $removepkgs; do
            chroot lala ls -lF lala/var/log/packages/$pkg
            echo -n removing $pkg...
            chroot lala removepkg $pkg >/dev/null && echo done
    done; unset pkg

note that you might want to keep kernel headers for the guest to be able to build something


only root can log in

echo non-root login has been disabled > lala/etc/nologin

update CA certificates

chroot lala which c_rehash
chroot lala update-ca-certificates

disabling useless shit from rc.d – tag ADD

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

do not disable those

ls -lF \
lala/etc/rc.d/rc.modules \
#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 \
lala/etc/rc.d/rc.cgmanager \
lala/etc/rc.d/rc.cgproxy \
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 \
#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/etc/termcap #needed
ls -lF lala/sbin/agetty #needed

cp -pi lala/etc/inittab lala/etc/inittab.dist
vi lala/etc/inittab

# Local serial lines:
s1:12345:respawn:/sbin/agetty --noclear 115200,38400,9600 hvc0 xterm

echo hvc0 >> lala/etc/securetty
cat 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.*
file /data/kernels/vmlinuz

tar xzf /data/kernels/lib.modules.5.2.21.lightUreiser4.tar.gz -C lala/lib/modules/
ls -lF lala/etc/rc.d/rc.modules*

echo /sbin/modprobe tmem >> lala/etc/rc.d/rc.modules.local
cat lala/etc/rc.d/rc.modules.local

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

while on current, it became simplier

chmod -x lala/etc/rc.d/rc.setterm

eventually proceed with a brutal network setup – avoid ssh host keys generation for darkstar

beware of escapes in da place


cat lala/etc/HOSTNAME # noexist yet or darkstar.example.net
echo $short > lala/etc/HOSTNAME

mv lala/etc/hosts lala/etc/hosts.dist
cat > lala/etc/hosts <<-EOF   localhost
IP-ADDRESS      $short.localdomain $short
GW-ADDRESS      gw

mv -i lala/etc/rc.d/rc.inet1 lala/etc/rc.d/rc.inet1.dist
chmod -x lala/etc/rc.d/rc.inet1.dist
cat > lala/etc/rc.d/rc.inet1 <<EOF

echo rc.inet1 PATH is \$PATH

if [[ \$1 = stop || \$1 = down ]]; then
    route delete default
    ifconfig eth0 down
    ifconfig lo down
    echo -n lo...
    ifconfig lo up && echo done

    echo -n eth0...
    ifconfig eth0 x.x.x.x/xx up && echo done

    echo -n default route...
    route add default gw x.x.x.x && echo done
chmod +x lala/etc/rc.d/rc.inet1

cat > lala/etc/resolv.conf <<-EOF
#search example.net

don’t forget to put your pubkeys over there

mkdir lala/root/.ssh/
vi lala/root/.ssh/authorized_keys


chmod 700 lala/root/.ssh/
chmod 600 lala/root/.ssh/authorized_keys

eventually a better SSHD

# REC but forcibly installed by slackinst/minimal
ls -lF lala/etc/rc.d/rc.sshd # already executable

we want to trust he right curve algo on first connection

mv -i lala/etc/ssh/sshd_config lala/etc/ssh/sshd_config.dist
grep -vE '^[[:space:]]*(#|$)' lala/etc/ssh/sshd_config.dist > lala/etc/ssh/sshd_config
echo 'HostKey /etc/ssh/ssh_host_ed25519_key' >> lala/etc/ssh/sshd_config
cat lala/etc/ssh/sshd_config

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

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


ls -ldF lala/installpkg-*/
#rm -rf lala/installpkg-*/
du -sh lala/
# Jun 06, 2020 -- minimal 494M

#mklost+found ...
umount lala/

eventually re-create lost+found

fsck.ext4 -fy $guest.ext4

Guest configuration

cat > $guest <<EOF
kernel = "/data/kernels/vmlinuz"
root = "/dev/xvda1 ro console=hvc0 mitigations=off"
#extra = "init=/bin/bash"
name = "$guest"
memory = 7168
vcpus = 16
#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' ]

Ready to go

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

xl create $guest -c

lsmod | grep tmem
watch free -m

eats only 46 MB of RAM after a while and total memory stripped down to 137 MB

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

clean-up and make a new template out of it

rm -f FILE_LIST tagfile *.txz
rmdir lala/
cd ../
newtemplate.bash $guest

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