bootstrap slackware from another gnu/linux system

descr

this guide applies to both kvm guest and bare-metal

warning // lessons learned

we cannot use LILO here as it would require the /dev/vda device to be available within the chroot. so instead, we go for SYSLINUX.

requirements

assuming the kvm hypervisor is up and running already – also ssuming you got virbr0 bridge

# not necessarily using virsh
#virsh net-start default
#virsh net-list

brctl show

slackware

which installpkg
mirror=`grep -vE '^#|^$' /etc/slackpkg/mirrors`

debian

we need pkgtools so we’re able to brutally install slackware from a debian/ubuntu kvm host – however it overrides the sbin -> usr/sbin symlink so we’re extracting the package elsewhere

#mirror=http://ftp.tu-chemnitz.de/pub/linux/slackware/slackware64-current
mirror=http://mirror.rol.ru/slackware/slackware64-current

lftp -c "open $mirror/slackware64/a/; mget pkgtools-*.txz"

mkdir /var/tmp/pkgtools/
tar xaf pkgtools-*.txz -C /var/tmp/pkgtools/
mv -fv /var/tmp/pkgtools/sbin/* /usr/local/sbin/
rm -rf /var/tmp/pkgtools/

grep :21: /etc/group
groupdel fax
groupadd -g 21 slocate

vdisk & filesystem setup

KVM requires a boot-loader hence a full virtual disk – also we need QCOW2 not a self-made sparse file for GNS3 guest template not to copy the entire thing…

as root

guest=slack150

mkdir -p /data/guests/$guest/lala/
cd /data/guests/$guest/
qemu-img create -f qcow2 $guest.qcow2 25G
modprobe nbd max_part=8

device=/dev/nbd0

qemu-nbd --connect=$device $guest.qcow2

manual partitioning

cfdisk $device

(dos)
${device}p1     bootable        Linux           24G
${device}p2                     Linux swap      1G

formatting

    mkfs.ext4 ${device}p1
    mount ${device}p1 lala/

    mkswap ${device}p2

deploy slackware userland

vi slackstart.conf

#mirror=http://ftp6.gwdg.de/pub/linux/slackware/slackware64-15.0/
#mirror=http://ftp.tu-chemnitz.de/pub/linux/slackware/slackware64-15.0/
mirror=http://mirror.rol.ru/slackware/slackware64-15.0/

and proceed

# https://pub.nethence.com/bin/slackstart/slackstrap.bash
time ./slackstrap.bash 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

deploy linux kernel

since this is either bare-metal or a kvm guest, make sure you include a kernel in the disk image

# https://pub.nethence.com/bin/slackstart/slackstrap.bash
time ./slackstrap.bash lala kernel

post-install

timezone, mount points and console

slackstrap is not enough for syslinux to be happy (probably fstab is required) – so the syslinux part comes within that script

vi slackstart.conf

#
# slackprep
#

tz=Europe/Moscow

fs=ext4
#fs=reiser4
#fs=btrfs
#fs=f2fs

# xen
#boot_partition=/dev/xvda1

# kvm
#boot_partition=/dev/vda1
#swap_partition=/dev/vda2

# bare-metal memstick e.g. (CHANGE ACCORDINGLY)
boot_partition=/dev/sdb1
swap_partition=/dev/sdb2

# default serial port COM1
#serial=ttyS0

# ilo vsp serial port COM2
#serial=ttyS1

swap=1
boot=syslinux

proceed

# https://pub.nethence.com/bin/slackstart/slackprep.bash
./slackprep.bash lala

eventually 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

network setup

eventually proceed with a brutal network setup

vi slackstart.conf

host= 
cidr=
gw=
dns=

# https://pub.nethence.com/bin/slackstart/slacknet.bash
./slacknet.bash $guest lala

serial console

fix the kvm guest serial console, see syslinux

ready to go

du -sh lala/
sync
umount -R lala/
rmdir lala/

qemu-nbd --disconnect $device

ls -lhF $guest.qcow2 # 2.0G
du -sh $guest.qcow2  # 2.0G

choose a decent machine type (q35 is newer and supposedly better/simplier)

qemu-system-x86_64 -machine help | grep PC

pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-6.2)
q35                  Standard PC (Q35 + ICH9, 2009) (alias of pc-q35-6.2)

new UUID and MAC address will be generated on the fly

cat > $guest.xml <<EOF
<domain type='kvm'>
  <name>$guest</name>
  <memory unit='MiB'>512</memory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='q35'>hvm</type>
    <boot dev='hd'/>
  </os>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/data/guests/$guest/$guest.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='bridge'>
      <source bridge='virbr0'/>
      <model type='virtio'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
    <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
  </devices>
</domain>
EOF
virsh create /data/guests/$guest/$guest.xml --console

TAB --> to get the chance to see the syslinux prompt

(login)
ping -c1 opendns.com

^]

troubleshooting

"Error: AppArmor parser not found"

ERROR: Can't find apparmor_parser at /sbin/apparmor_parser

==> /sbin is a symlink since focal, did you mess it up by installing pkgtools?…

while attempting to boot the guest

(nothing shows up on console output)

==> make sure you’ve deployed the syslinux boot-blocks on the right disk (nbd0 not ndb0…)

resources

QemuKVMMigration https://wiki.ubuntu.com/QemuKVMMigration

QEMU Unsupported Machine Type ‘pc-q35-3.1’ https://forum.level1techs.com/t/qemu-unsupported-machine-type-pc-q35-3-1/140084

How can I change Qemu KVM machine architecture from 440fx to q35 with virsh edit or virt-manager https://serverfault.com/questions/637917/how-can-i-change-qemu-kvm-machine-architecture-from-440fx-to-q35-with-virsh-edit

HOME | GUIDES | PLAYBOOKS | LECTURES | LAB | CONTACT | HTML | CSS
Licensed as MIT