DEV Community

sa3i0l
sa3i0l

Posted on

Install KVM on Linux

Install KVM packages

Installing all packages needed to run KVM:


sudo pacman -Syy
sudo pacman -S archlinux-keyring
sudo pacman -S qemu virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat
Enter fullscreen mode Exit fullscreen mode

Also install ebtables  and iptables packages:


sudo pacman -S ebtables iptables
Enter fullscreen mode Exit fullscreen mode

Step 2: Install libguestfs

sudo pacman -S libguestfs
Enter fullscreen mode Exit fullscreen mode

Step 3: Start KVM libvirt service

sudo systemctl enable libvirtd.service
sudo systemctl start libvirtd.service

//runing ?
systemctl status libvirtd.service
Enter fullscreen mode Exit fullscreen mode

Step 4: Enable normal user account to use KVM

sudo vim /etc/libvirt/libvirtd.conf
Enter fullscreen mode Exit fullscreen mode

Set the UNIX domain socket group ownership to libvirt, (around line 85)

unix_sock_group = "libvirt"
Enter fullscreen mode Exit fullscreen mode

Set the UNIX socket permissions for the R/W socket (around line 102)

unix_sock_rw_perms = "0770"
Enter fullscreen mode Exit fullscreen mode

Add your user account to libvirt group.

sudo usermod -a -G libvirt $(whoami)
newgrp libvirt
Enter fullscreen mode Exit fullscreen mode

Restart libvirt daemon.

sudo systemctl restart libvirtd.service
Enter fullscreen mode Exit fullscreen mode

Step 5: Enable Nested Virtualization (Optional)

Nested Virtualization feature enables you to run Virtual Machines inside a VM. Enable Nested virtualization for kvm_intel / kvm_amd by enabling kernel module as shown.

### Intel Processor ###
sudo modprobe -r kvm_intel
sudo modprobe kvm_intel nested=1

### AMD Processor ###
sudo modprobe -r kvm_amd
sudo modprobe kvm_amd nested=1
Enter fullscreen mode Exit fullscreen mode

To make this configuration persistent,run:

echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf
Enter fullscreen mode Exit fullscreen mode

Confirm that Nested Virtualization is set to Yes:

### Intel Processor ###
$ systool -m kvm_intel -v | grep nested
    nested              = "Y"
    nested_early_check  = "N"
$ cat /sys/module/kvm_intel/parameters/nested 
Y

### AMD Processor ###
$ systool -m kvm_amd -v | grep nested
    nested              = "Y"
    nested_early_check  = "N"
$ cat /sys/module/kvm_amd/parameters/nested 
Y
Enter fullscreen mode Exit fullscreen mode

Step 6:

Run "Virtual Machine Manager"

Top comments (0)