XEN guest // Bootstrapping Slackware

assuming the domU kernel has already been prepared

Virtual disks

guest=slack

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

either create a raw sparse file

# disk/partition in M not MiB
    dd if=/dev/zero of=$guest.btrfs bs=1M count=0 seek=8191
    dd if=/dev/zero of=$guest.reiser4 bs=1M count=0 seek=8191

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

–or– a freaking thin provisioned LVM volume

–or– a DRBD volume on top of it

File-systems

then format and mount it

mkfs.btrfs $guest.btrfs
mkfs.reiser4 -dfy $guest.reiser4

#mkswap $guest.swap

as for LVM/THIN provisioning alone

ls -lF /dev/thin/$guest
mkfs.btrfs /dev/thin/$guest
mkfs.reiser4 -dy /dev/thin/$guest

as for DRBD/THIN

drbdadm status $guest

mkfs.btrfs /dev/drbd/by-res/$guest/0
mkfs.reiser4 -dy /dev/drbd/by-res/$guest/0

Deploy and setup

from the XEN host directly

# sparse file
mount $guest.btrfs lala/
mount $guest.reiser4 lala/

# lvm
mount /dev/thin/$guest lala/

# drbd
mount /dev/drbd/by-res/$guest/0 lala/

deploy

    cd /data/guests/
    wget https://pub.nethence.com/bin/slack/slackstrap.bash
    chmod +x slackstrap.bash

    mirror=...

    cd /data/guests/$guest/
    ../slackstrap.bash lala/ $mirror
    #../slackstrap.bash lala/ $mirror full
    #../slackstrap.bash lala/ $mirror hardware

    # kvm-only
    ../slackstrap.bash lala/ $mirror kernel

move the packages around for later use

    mkdir ../slackpkgs/
    mv -f *.txz ../slackpkgs/
    rm -f FILE_LIST tagfile
    du -sh lala/

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

    wget https://lab.nethence.com/slackpkgs/libaal-1.0.7-x86_64-2_SBo.tgz
    wget https://lab.nethence.com/slackpkgs/reiser4progs-1.2.2-x86_64-2_SBo.tgz

    ls -lF /root/slackpkgs/libaal-*_SBo.tgz
    ls -lF /root/slackpkgs/reiser4progs-*_SBo.tgz

    installpkg --terse --root lala/ /root/slackpkgs/libaal-*_SBo.tgz
    installpkg --terse --root lala/ /root/slackpkgs/reiser4progs-*_SBo.tgz

Setup manually

proceed manually –or– this is otherwise automated with the following script

    cd /data/guests/
    wget https://pub.nethence.com/bin/slack/slackpost.bash
    chmod +x slackpost.bash

define/tune accordingly

    vi /root/slackpost.conf

    zone=Europe/Moscow

    # FILE-SYSTEM
    #fs=ext4
    fs=reiser4
    #fs=btrfs
    #fs=f2fs

    # VMM
    vpartition=/dev/xvda1
    serial=hvc0
    #vpartition=/dev/vda1
    #serial=ttyS0

and proceed

    cd /data/guests/$guest/
    echo $mirror
    ../slackpost.bash $guest $mirror lala/
    chroot lala/ bash -l

    perl -e exit

    ^D

beware to start this one from rc.inet1 or install and enable rc.inet2

    ls -lF lala/etc/rc.d/rc.inet2 # no exist unless you did full install

    # REC but forcibly installed by slackstrap/minimal
    ls -lF lala/etc/rc.d/rc.sshd # already enabled
    grep sshd lala/etc/rc.d/rc.inet1
    grep sshd lala/etc/rc.d/rc.local

no kernel what-so-ever for XEN

    ls -lF lala/var/log/packages/kernel*

dirty-fix chroot network

    echo $dns1
    echo $dns2

    ls -lF lala/etc/resolv.conf # no exist
    cat > lala/etc/resolv.conf <<-EOF
    nameserver $dns1
    nameserver $dns2
    EOF

and update the package repository cache

    mount -o bind /dev lala/dev
    mount -o bind /dev/pts lala/dev/pts
    mount -o bind /proc lala/proc
    mount -o bind /sys lala/sys
    chroot lala/ bash

    ping -c1 opendns.com
    cat /etc/slackpkg/mirrors
    slackpkg update
    history -c
    ^D

    rm -f lala/root/.bash_history

kvm-only

fix the xen guest serial console, see syslinux

xen-only

deploy and enable TMEM

    mkdir lala/lib/modules/
    tar xzf /data/kernels/5.2.21.domureiser4.modules.tar.gz -C lala/lib/modules/
    echo /sbin/modprobe tmem >> lala/etc/rc.d/rc.modules.local
    ls -lF lala/etc/rc.d/rc.modules.local # enabled already

shared

finish-up — be it for a template or not (see below)

    ls -ldF lala/installpkg-*/ # no exist
    #rm -rf lala/installpkg-*/

    du -sh lala/

    # mklost+found ...

Template-ready vs. guest deployment

now is a good time to make a template out of this image (it doesn’t have network setup yet, just dns pointers)

    umount -R lala/
    rmdir lala/

and proceed with whatever method is yours for template mgmt

–or– proceed with brutal network setup right away – you can get the script from there

../slackbrutal.bash x.x.x.9/24 x.x.x.254 $guest

Guest skeleton

cat > $guest <<EOF
kernel = "/data/kernels/5.2.21.domureiser4.vmlinuz"
root = "/dev/xvda1 ro console=hvc0 mitigations=off"
#extra = "init=/bin/bash"
name = "$guest"
memory = 7168
vcpus = 3
#disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.reiser4,xvda1,w']
#disk = ['phy:/dev/thin/$guest,xvda1,w']
disk = ['phy:/dev/drbd/by-res/$guest/0,xvda1,w']
vif = [ 'bridge=guestbr0, vifname=$guest' ]
type = "pvh"
EOF

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

...

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

Troubleshooting

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
done

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
done

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

Resources

How to clone LVM thin provisioning volume? https://serverfault.com/questions/458949/how-to-clone-lvm-thin-provisioning-volume

5.4.17. CONTROLLING LOGICAL VOLUME ACTIVATION https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/lv_activate

CHAPTER 14. LOGICAL VOLUME ACTIVATION https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_logical_volumes/assembly_lvm-activation-configuring-and-managing-logical-volumes

guest config options

https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun