Page:
# KVM / Virt-Manager Setup on lainOS layer 02
No results
1
# KVM / Virt-Manager Setup on lainOS layer 02
Grayson Giles edited this page 2026-06-24 21:18:11 +02:00
Table of Contents
- KVM / Virt-Manager Setup on LainOS Layer 02
- 1. Install KVM packages
- 2. Create the libvirt-qemu user and group
- 3. Create the libvirt group and add your user
- 4. Create the libvirtd OpenRC init script
- 5. Configure libvirt for non-root user access
- 6. Enable and start libvirtd
- 7. Fix socket path
- 8. Fix socket permissions
- 9. Load the tun module (persistent)
- 10. Create the virtlogd OpenRC init script
- 11. Launch virt-manager
- Notes
KVM / Virt-Manager Setup on LainOS Layer 02
1. Install KVM packages
doas pacman -S qemu-full virt-manager virt-viewer dnsmasq bridge-utils openbsd-netcat dmidecode ebtables iptables libguestfs
2. Create the libvirt-qemu user and group
doas groupadd libvirt-qemu
doas useradd -r -d /var/lib/libvirt/qemu -s /sbin/nologin libvirt-qemu
3. Create the libvirt group and add your user
doas groupadd libvirt
doas usermod -a -G libvirt lain
newgrp libvirt
4. Create the libvirtd OpenRC init script
doas nano /etc/init.d/libvirtd
Paste this content:
#!/sbin/openrc-run
description="Libvirt virtualization daemon"
command="/usr/bin/libvirtd"
command_args="--daemon"
pidfile="/run/libvirtd.pid"
command_background="yes"
depend() {
need net
after dbus
}
Save and exit, then make it executable:
doas chmod 755 /etc/init.d/libvirtd
5. Configure libvirt for non-root user access
doas nano /etc/libvirt/libvirtd.conf
Find and uncomment these two lines:
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
Save and exit.
6. Enable and start libvirtd
doas rc-update add libvirtd default
doas rc-service libvirtd start
doas rc-service libvirtd status
Status should show started.
7. Fix socket path
On LainOS, /var/run is not a symlink to /run. Create the symlink manually:
doas ln -s /run/libvirt /var/run/libvirt
8. Fix socket permissions
doas chown root:libvirt /run/libvirt/libvirt-sock
doas chmod 0770 /run/libvirt/libvirt-sock
9. Load the tun module (persistent)
doas mkdir -p /etc/modules-load.d
echo "tun" | doas tee /etc/modules-load.d/tun.conf
doas modprobe tun
The modules service runs at boot and will load tun automatically on every subsequent boot.
10. Create the virtlogd OpenRC init script
doas nano /etc/init.d/virtlogd
Paste this content:
#!/sbin/openrc-run
description="Libvirt logging daemon"
command="/usr/bin/virtlogd"
command_args="--daemon"
pidfile="/run/virtlogd.pid"
command_background="yes"
depend() {
need libvirtd
}
Save and exit, then make it executable and enable it:
doas chmod 755 /etc/init.d/virtlogd
doas rc-update add virtlogd default
doas rc-service virtlogd start
11. Launch virt-manager
virt-manager --connect qemu:///system
virt-manager must be launched from a terminal on LainOS Layer 02.
Notes
- Always use
doasinstead ofsudoon LainOS Layer 02 systemctldoes not exist — userc-serviceandrc-update- libvirtd and virtlogd will autostart on every boot once added to the default runlevel
- The tun module will autoload on every boot via
/etc/modules-load.d/tun.conf