Linux Tutorials

How To Install KVM on Linux Operating Systems

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

Original content from computingforgeeks.com - post 2011
### 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:

Related Articles

Cloud TrueNAS and How to Upgrade from FreeNAS to TrueNAS Core Debian Use NetworkManager nmcli on Ubuntu and Debian Chef Install Chef Automation Server on Ubuntu 18.04 LTS CentOS Install Monaco Editor – Browser based Code Editor for Linux

2 thoughts on “How To Install KVM on Linux Operating Systems”

Leave a Comment

Press ESC to close