Skip to main content

KVM

KVM (Kernel-based Virtual Machine) is a hypervisor built into the Linux kernel.

  1. Install libvirt Packages
    yay -S qemu libvirt edk2-ovmf virt-manager nfs-utils virtio-win
    
    # optional dependencies
    iptables-nft dnsmasq   # for default NAT/DHCP networking
    bridge-utils           # for bridged networking
    openbsd-netcat         # for remote management over SSH
    
  2. Add user to libvirt groups
    sudo usermod -aG libvirt $USER
    
  3. Start libvirtd daemon
    sudo systemctl enable --now libvirtd
    
  4. Create network bridge with nmcli
    nmcli connection add type bridge ifname br0 con-name "Netzwerkbrücke" stp no
    nmcli connection add type bridge-slave ifname enp39s0 con-name "Ethernet" master br0
    nmcli connection down "Kabelgebundene Verbindung 1"
    nmcli connection up "Netzwerkbrücke"
    
    • When using bonding of interfaces, disable IPv4 and IPv6 on the bridge
      nmcli con mod "Netzwerkbrücke" ipv4.method disabled ipv6.method ignore 
      
  5. Define bridge network XML file, e.g. as br0.xml
    <network>
      <name>br0</name>
      <forward mode='bridge'/>
      <bridge name='br0'/>
    </network>
    
  6. Add bridge network to virt-manager
    virsh -c qemu:///system net-define br0.xml
    virsh -c qemu:///system net-autostart br0
    
  7. Disable COW on Btrfs (optional, recommended)
    sudo chattr +C /var/lib/libvirt/images
    
  8. Define a remote storage pool (e.g. remote ISO images) remote-iso.xml
    <pool type="netfs">
      <name>iso</name>
      <source>
        <host name="dragonhoard"/>
        <dir path="/Download/Software/ISOs"/>
        <format type="auto"/>
      </source>
      <target>
        <path>/var/lib/libvirt/images/iso</path>
      </target>
    </pool>
    
  9. Add storage pool to virt-manager
    virsh -c qemu:///system pool-define remote-iso.xml
    virsh -c qemu:///system pool-autostart iso
    
  10. Create the storage pool mountpoint
    sudo mkdir -p /var/lib/libvirt/images/iso