voidlinux virtualization

This recipe is for setting virtualization on a voidlinux desktop.

Use this setup script to set things up on void linux.

Connecting to libvirtd

Note that virsh and virt-manager commands connect to different libvirtd sessions by defauult.

virsh defaults to qemu:///session while virt-manager to qemu:///system.

It is better to use qemu:///system as qemu:///session does not seem to see all available resources.

To force virsh to connect to the right session you can use commands such as:

virsh --connect qemu:///system net-list
virsh --connect qemu:///system pool-list

Create network

Set-up a bridge for internal networking using NetworkManager. See this article for reference.

Go to NetworkManager menu and use the Edit network connections applet:

  • add new bridge connection
  • give a suitable name
  • disable IPv4 and IPv6
  • everything can be left as default.

Import images

This needs to be done on CLI (as the GUI doesn't seem to allow this)

virsh --connect qemu:///system vol-create-as $pool $vol 32k --format $format
virsh --connect qemu:///system vol-upload $vol $file

For format, use raw for iso, qcow2 for actual drives.

Setup VM

Just create VM as normal.

virt-manager create Vm wizard

  1. manual install
  2. alpine linux
  3. mem: depends
  4. Create storage (4GB is enough)
  5. name. Customize configuration. Network use NAT.
  6. Add CDROM, make readonly and shareable
  7. Add Network connected to internal bridge.
  8. Add boot device.
  9. Add shared filesystem:
  10. driver: virtio-9p
  11. source path: /var/lib/libvirt/filesystems/shared
  12. target path: /shared

Prepare system

  1. create filesystem
  2. mkfs.vfat /dev/vda
  3. apk add syslinux
  4. syslinux /dev/vda
  5. copy media
  6. mount -t vfat /dev/vda /mnt
  7. cp -av /media/cdrom/. /mnt
  8. edit /mnt/boot/syslinux/syslinux.cfg add: dom0_mem=1024M
  9. umount /mnt
  10. remove cdrom
  11. power off
  12. remove cdrom
  13. change boot options
  14. re-start system
  15. setup-alpine
  16. enter fqdn
  17. set interface eth0 to dhcp
  18. Mount shared fs:
  19. mount -t 9p -o trans=virtio /shared /shared
  20. fstab
  21. /sharepoint /share 9p trans=virtio,version=9p2000.L,rw 0 0

Thin provisioning

Create an overlay file like so:

qemu-img create -b ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img -F qcow2 -f qcow2 guest-1.qcow2