bootstrap slackware from another gnu/linux system

warning // lessons learnedwarning // 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.

requirementsrequirements

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=...

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 setupvdisk & 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

# hardcoded here
qemu-nbd --connect=/dev/nbd0 $guest.qcow2

# proceed further
device=/dev/nbd0

manual partitioning

cfdisk $device

(dos)
/dev/nbd0p1 bootable    Linux       24G
/dev/nbd0p2         Linux swap   1G

formatting

mkswap ${device}p2

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

proceed with the slackstart suiteproceed with the slackstart suite

setup slackstart suite

vi slackstart.conf

mirror=http://ftp.tu-chemnitz.de/pub/linux/slackware/slackware64-15.0/
tz=Europe/Moscow
fs=ext4
vpartition=/dev/vda1
serial=ttyS0
swap=1
boot=syslinux

system bootstrap

from the KVM host directly

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

since this is a kvm guest, make sure you include a kernel in the disk image

time bash ../slackstrap.bash lala kernel

boot-blocks & install-time setup

timezone, mount points and console

slackstrap is not enough for syslinux to be happy (probably fstab is required)

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

eventually proceed with a brutal network setup

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

ready to goready to go

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

^]

troubleshootingtroubleshooting

"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…)

resourcesresources

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 | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Licensed under MIT