This guide will cover the how to install KVM on Linux systems. We will install KVM and its management tools on CentOS, Ubuntu, Debian, SLES, Rocky, AlmaLinux, and Arch-based systems. 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.

📥 Master Linux KVM virtualization from anywhere. Read or download the ultimate eBook today. Get a copy now

kvm ebook promo 03

Before installing KVM, it is important to validate whether your CPU supports hardware virtualization.

### For Intel-based processors ###
grep -E --color 'vmx' /proc/cpuinfo

### For AMD-based processors ###
grep -E --color 'svm' /proc/cpuinfo

If the output contains “vmx” or “svm,” it means your CPU supports hardware virtualization.

Install KVM on CentOS Stream / Rocky / Alma 8+

Run the following commands to install KVM hypervisor on these systems.

sudo dnf install -y libvirt qemu-kvm virt-install virt-top libguestfs-tools 
sudo dnf -y install epel-release && sudo dnf -y install bridge-utils
sudo dnf -y install virt-viewer virt-manager

Start and enable the service.

sudo systemctl enable --now libvirtd

Install KVM on CentOS 7 / RHEL 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 gcc libvirt libvirt-devel 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 Fedora

For KVM check out the guide below:

Install KVM on Ubuntu

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

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

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

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

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

Load KVM kernel module

$ sudo modprobe vhost_net
$ sudo lsmod | 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.

Install KVM on SLES / openSUSE

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

Install KVM on RHEL 8 / RHEL 9

Ensure your system is registered:

sudo subscription-manager register --auto-attach

Install KVM and all required tools.

sudo dnf install -y libvirt qemu-kvm virt-install \
virt-top libguestfs-tools

If you are on a Desktop Environment, install virt-manager

sudo dnf -y install virt-manager virt-viewer

For bridge-utils utility installation run the commands below.

# RHEL 9
sudo subscription-manager repos \
 --enable codeready-builder-for-rhel-9-$(arch)-rpms

sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sudo dnf -y install bridge-utils

# RHEL 8
sudo subscription-manager repos \
 --enable codeready-builder-for-rhel-8-$(arch)-rpms
sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install bridge-utils

How To Manage KVM hypervisor

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:

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

If you want to generate KVM VM templates, refer to:

To Automate deployment of VMs on KVM, check:

Further reading:

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here