assuming the domU kernel has already been prepared
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
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 mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/drbd/by-res/$guest/0
from the XEN host directly
mount $guest.btrfs lala/ mount $guest.reiser4 lala/ mount /dev/thin/$guest lala/ mount /dev/drbd/by-res/$guest/0 lala/ mount -o compress_algorithm=lz4,compress_chksum,atgc,gc_merge,lazytime /dev/drbd/by-res/$guest/0 lala/
cd /data/guests/ wget https://pub.nethence.com/bin/slack/slackstrap.bash.txt mv -i slackstrap.bash.txt slackstrap.bash chmod +x slackstrap.bash vi /root/mirror.conf mirror=YOUR-CLOSEST-MIRROR/slackware64-15.0/ cd /data/guests/$guest/ ../slackstrap.bash lala/ #../slackstrap.bash lala/ full #../slackstrap.bash lala/ hardware # kvm-only ../slackstrap.bash lala/ kernel # f2fs source /root/mirror.conf wget $mirror/slackware64/a/f2fs-tools-1.14.0-x86_64-3.txz installpkg --terse --root lala/ f2fs-tools-*.txz
move the packages around for later use
mkdir ../slackpkgs/ mv -f *.txz ../slackpkgs/ rm -f FILE_LIST tagfile du -sh lala/ # 358M btrfs@ocfs2 # 313M f2fs
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 installpkg --terse --root lala/ /root/slackpkgs/libaal-*_SBo.tgz installpkg --terse --root lala/ /root/slackpkgs/reiser4progs-*_SBo.tgz
proceed manually –or–
this is otherwise automated with the slackpost.bash
script
cd /data/guests/ wget https://pub.nethence.com/bin/slack/slackpost.bash.txt mv slackpost.bash.txt slackpost.bash chmod +x slackpost.bash
define/tune accordingly
vi /root/mirror.conf mirror=YOUR-CLOSEST-MIRROR/slackware64-15.0/ zone=Europe/Moscow # FILE-SYSTEM #fs=reiser4 #fs=btrfs fs=f2fs # VMM vpartition=/dev/xvda1 serial=hvc0 #vpartition=/dev/vda1 #serial=ttyS0
and proceed
cd /data/guests/$guest/ ../slackpost.bash $guest lala/
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*
update package cache
echo $dns1 echo $dns2 ls -lF lala/etc/resolv.conf # no exist cat > lala/etc/resolv.conf <<-EOF nameserver $dns1 nameserver $dns2 EOF 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
fix the xen guest serial console, see syslinux
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
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 ... umount -R lala/ rmdir lala/
then either proceed with a brutal network setup
eventually proceed with a brutal network setup – avoid ssh host keys generation for darkstar
beware of escapes in da place
short=SHORT-HOSTNAME # kvm/libvirt ip=192.168.122.99/24 gw=192.168.122.1 dns1=192.168.122.1 cat lala/etc/HOSTNAME # darkstar.example.net echo $short > lala/etc/HOSTNAME mv lala/etc/hosts lala/etc/hosts.dist echo -e "127.0.0.1\t\tlocalhost.localdomain localhost" > lala/etc/hosts echo -e "::1\t\t\tlocalhost.localdomain localhost" >> lala/etc/hosts echo -e "${ip%/*}\t\t$short.localdomain $short" >> lala/etc/hosts [[ -n $gw ]] && echo -e "$gw\t\tgw" >> lala/etc/hosts for dns in dns1 dns2 dns3; do [[ -n ${!dns} ]] && echo -e "${!dns}\t\t$dns" >> lala/etc/hosts done; unset dns ls -lF lala/etc/rc.d/rc.inet1 # no exist #mv -i lala/etc/rc.d/rc.inet1 lala/etc/rc.d/rc.inet1.dist #chmod -x lala/etc/rc.d/rc.inet1.dist # WARNING ESCAPES ARE IN THERE cat > lala/etc/rc.d/rc.inet1 <<EOF #!/bin/bash echo rc.inet1 PATH is \$PATH if [[ \$1 = stop || \$1 = down ]]; then route delete default ifconfig eth0 down ifconfig lo down else echo -n lo ... ifconfig lo up && echo done echo -n eth0 ... ifconfig eth0 $ip up && echo done echo -n default route ... route add default gw $gw && echo done fi EOF chmod +x lala/etc/rc.d/rc.inet1 ls -lF lala/etc/resolv.conf # no exist #mv -i lala/etc/resolv.conf lala/etc/resolv.conf.dist for dns in dns1 dns2 dns3; do [[ -n ${!dns} ]] && echo -e "nameserver ${!dns}" >> lala/etc/resolv.conf done; unset dns
don’t forget to put your pubkeys over there
mkdir lala/root/.ssh/ vi lala/root/.ssh/authorized_keys PASTE PUBKEYS chmod 600 lala/root/.ssh/authorized_keys chmod 700 lala/root/.ssh/
–or– see tpl
cat > $guest <<EOF # requires f2fs kernel feature kernel = "/data/kernels/vmlinuz" root = "/dev/xvda1 ro console=hvc0 mitigations=off" #extra = "init=/bin/bash" name = "$guest" memory = 1024 vcpus = 2 #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 #memory = 7168 #vcpus = 16
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
extra = "init=/bin/bash" mount -o remount,rw / export TERM=xterm dmesg | grep hvc ... sync 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 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
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
https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html