ElementaryOS 0.4: Install KVM for virtualization

This article will describe installing KVM.

1 Install qemu-kvm and libvirt

Install qemu-kvm package and some packages for virtual machine operation.

$ sudo apt install -y qemu-kvm libvirt0 libvirt-bin virt-manager bridge-utils

Register libvirt-bin to systemd.

$ sudo systemctl enable libvirt-bin

2 Create bridge

The bridge interface is needed for accessing virtual machine via network from other machine. Change ens3 to your network interface name. Reboot system after setting.

$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto br0
iface br0 inet dhcp
      bridge_ports ens3
      bridge_stp off
      bridge_maxwait 0
$ sudo reboot

3 libvirtd group

The user in libvirtd group can run libvirt command without sudo.

$ sudo gpasswd libvirtd -a ${USER}
$ sudo reboot