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
- manual install
- alpine linux
- mem: depends
- Create storage (4GB is enough)
- name. Customize configuration. Network use NAT.
- Add CDROM, make readonly and shareable
- Add Network connected to internal bridge.
- Add boot device.
- Add shared filesystem:
- driver: virtio-9p
- source path:
/var/lib/libvirt/filesystems/shared
- target path:
/shared
Prepare system
- create filesystem
- mkfs.vfat /dev/vda
- apk add syslinux
- syslinux /dev/vda
- copy media
- mount -t vfat /dev/vda /mnt
- cp -av /media/cdrom/. /mnt
- edit /mnt/boot/syslinux/syslinux.cfg add: dom0_mem=1024M
- umount /mnt
- remove cdrom
- power off
- remove cdrom
- change boot options
- re-start system
- setup-alpine
- enter fqdn
- set interface eth0 to dhcp
- Mount shared fs:
- mount -t 9p -o trans=virtio /shared /shared
- fstab
- /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