Skip to content

Instantly share code, notes, and snippets.

@helloimalemur
Forked from tatumroaquin/archlinux-qemu-kvm.md
Last active May 26, 2024 22:58
Show Gist options
  • Save helloimalemur/0b8b5faaee10cc8c8a0cb37a0ca7d1a7 to your computer and use it in GitHub Desktop.
Save helloimalemur/0b8b5faaee10cc8c8a0cb37a0ca7d1a7 to your computer and use it in GitHub Desktop.
KVM Installation for Arch Linux

Arch Linux KVM

install all necessary packages

pacman -S virt-manager virt-viewer qemu

enable libvirt daemon

systemctl enable libvirtd.service
systemctl start libvirtd.service

create bridge interface

nano br10.xml

<network>
  <name>br10</name>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='br10' stp='on' delay='0'/>
  <ip address='192.168.30.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.30.50' end='192.168.30.200'/>
    </dhcp>
  </ip>
</network>

define and autostart network bridge

virsh net-define br10.xml
virsh net-start br10
virsh net-autostart br10

enable normal user account to use KVM

nano /etc/libvirt/libvirtd.conf

unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"

add current user to kvm and libvirt groups

sudo usermod -a -G kvm $(whoami)
sudo usermod -a -G libvirt $(whoami)
newgrp libvirt

enable nested virtulization (optional)

## intel
modprobe -r kvm_intel
modprobe kvm_intel nested=1
echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf

## amd
modprobe -r kvm_amd
modprobe kvm_amd nested=1
echo "options kvm-amd nested=1" | sudo tee /etc/modprobe.d/kvm-amd.conf

verify nested virtualization

## intel
systool -m kvm_intel -v | grep nested
cat /sys/module/kvm_intel/parameters/nested

## amd
systool -m kvm_amd -v | grep nested
cat /sys/module/kvm_amd/parameters/nested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment