assuming the kvm hypervisor and host system are up and running already
boostrapping slackware on a full-blown vdisk (not just a partition image for once)
we need pkgtools
so we’re able to brutally install slackware it 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 -f /var/tmp/pkgtools/sbin/* /usr/local/sbin/ grep 21 /etc/group groupdel fax groupadd -g 21 slocate grep ^slocate /etc/group
also if evern you proceed manually, be careful to always run installpkg
with a chroot defined
installpkg --terse --root lala/ SOME-PACKAGE.txz
we use SYSLINUX / EXTLINUX against the guest virtual disk from the host
apt install syslinux
assuming you got virbr0
bridge up and running
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 qemu-nbd --connect=/dev/nbd0 $guest.qcow2 fdisk /dev/nbd0 n p ENTER ENTER ENTER a w mkfs.ext4 /dev/nbd0p1 mount /dev/nbd0p1 lala/
from the KVM host directly
make sure you include a kernel in the image (more details)
# https://pub.nethence.com/bin/slack/slackstrap.bash ../slackstrap.bash lala/ $mirror ../slackstrap.bash lala/ $mirror kernel
this is not enough for syslinux to be happy (probably fstab is required)
# https://pub.nethence.com/bin/slack/slackpost.bash ../slackpost.bash $guest $mirror lala/
and eventually proceed with a brutal network setup
# https://pub.nethence.com/bin/slack/slackbrutal.bash.txt ../slackbrutal.bash 192.168.122.9/24 192.168.122.1 $guest ~USER/.ssh/id_ed25519.pub
setup the kvm guest boot-loader and kernel-time serial console
dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/ndb0 mkdir lala/boot/syslinux/ extlinux --install lala/boot/syslinux/ --device /dev/nbd0p1 cp -f /usr/lib/syslinux/modules/bios/mboot.c32 lala/boot/syslinux/ cp -f /usr/lib/syslinux/modules/bios/libcom32.c32 lala/boot/syslinux/ vi lala/boot/syslinux/syslinux.cfg serial 0 115200 console 1 nohalt 1 default linux prompt 1 timeout 30 label linux linux /boot/vmlinuz append root=/dev/vda1 ro console=ttyS0,115200n8 mitigations=off
umount lala/ rmdir lala/ #dumpe2fs -i /dev/nbd0p1 #dumpe2fs -h /dev/nbd0p1 #fsck.ext4 -f /dev/nbd0p1
qemu-nbd --disconnect /dev/nbd0 ls -lhF $guest.qcow2 # 2.0G dh -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'>2</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 ^]
clone the machine already
poweroff cd ../ cp -R --sparse=always slack/ slack-clone/ vi slack-clone/slack.xml <name>slack-clone</name> <source file='/data/guests/slack-clone/slack.img'/> du -sh slack*/
and proceed
virsh create slack-clone/slack.xml virsh console slack-clone vi /etc/HOSTNAME vi /etc/hosts vi /etc/rc.d/rc.inet1 (change static ip) reboot ping -c1 opendns.com ^]
virsh list # should NOT run losetup -a # already mapped? losetup --find --partscan --show $guest.img fsck /dev/loop3p1 mount /dev/loop3p1 lala/
... umount -R lala/ losetup --detach /dev/loop3
"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?…
(nothing shows up on console output)
==> do not forget to run slackpost after slackstrap – probably fstab was missing
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