(Last Updated On: November 23, 2018)

This guide will cover the full installation of KVM hypervisor and its management tools on CentOS 7, Ubuntu 16.04, Debian 9, SUSE Linux Enterprise Server 12 and Arch Linux. This list of Linux systems should cover mostly used Linux servers in an enterprise setup.

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V).

It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. It has received huge adoption on enterprise over the last few years.

Install KVM on CentOS 7

We’ll install KVM and QEMU plus some tools like libguestfs-tools and virt-top which comes in handy when administering KVM. Install them as below:

sudo yum -y install epel-release 
sudo yum -y install libvirt qemu-kvm virt-install virt-top libguestfs-tools bridge-utils

Confirm that the kernel modules are loaded:

$ sudo lsmod | grep kvm 
kvm_intel 147785 0
kvm 464964 1 kvm_intel

Start and enable libvirtd service:

sudo systemctl start libvirtd
sudo systemctl enable libvirtd

Install KVM on Ubuntu 16.04

For Ubuntu 16.04, all packages required to run KVM are available on official upstream repositories. Install them using the commands:

sudo  apt-get -y install qemu-kvm libvirt-bin virt-top  libguestfs-tools virtinst bridge-utils

Load and enable the modulevhost-net.

sudo modprobe vhost_net 
sudo lsmod | grep vhost 
echo "vhost_net" | sudo tee -a /etc/modules

Install KVM on Debian 9

Install libvirt daemon, qemu and other KVM related tools using the commands.

sudo apt -y install libvirt-daemon libosinfo-bin  libguestfs-tools libvirt-daemon-system qemu-kvm virtinst bridge-utils virt-top

Load KVM kernel module

$ sudo modprobe vhost_net 
$ sudo smod | grep vhost 
vhost_net 20480 0
tun 28672 1 vhost_net
vhost 45056 1 vhost_net
macvtap 24576 1 vhost_net
echo "vhost_net" | sudo tee -a /etc/modules

Install KVM on Arch Linux / Manjaro

For Arch Linux and its derivatives, I already wrote an article which is available on the link below.

Complete Installation of KVM,QEMU and Virt Manager on Arch Linux and Manjaro

Install KVM on SUSE Linux Enterprise Server

The CPU on the system you’re using should have Intel VT or AMD-V function. The install required packages using:

sudo zypper -n install qemu-kvm guestfs-tools virt-top libvirt virt-install libguestfs0 bridge-utils

Ensure the kernel module required to virtualize is on:

$ sudo lsmod | grep kvm 
kvm_intel 147785 0
kvm 464964 1 kvm_intel

Start and enable kvm service:

sudo systemctl start libvirtd  && sudo systemctl enable libvirtd

Basic KVM Operations

Now that you have KVM installed with basic tools you need to get started, so what next?. I have a virsh cheat sheet which you can start with:

virsh commands cheatsheet to manage KVM guest virtual machines

Bridge configuration on Linux is also a crucial part when working on KVM, an article for this is also available.

How to Create and Configure Bridge Networking For KVM in Linux