Categories: Ubuntu

How to Install KVM on Ubuntu 22.04?

“Kernel-based Virtual Machine is a virtualization module in the Linux kernel that allows the kernel to work as a hypervisor.

To learn more about KVM, check this out:

https://www.linux-kvm.org/page/Main_Page

Today, we will explore how to install KVM on an ubuntu machine. We will use Ubuntu’s latest version, 22.04. The installation will take place using the command line. We will run basic Linux commands to install KVM and its necessary dependencies. By the end of this tutorial, you will know how easy it is to install KVM on your system.”

Without any further ado, let’s begin!

Installation Guide

Following are the steps involved in installing KVM on Ubuntu 22.04:

Step
Sponsored
1: Update and Upgrade Your Ubuntu 22.04 System

Before installing KVM on your system, update and upgrade the system.

Use the following command for updating the system:

sudo apt update

Next, use the following command for upgrading the system:

sudo apt upgrade

Step 2: Check KVM Compatibility With Your System

Before installing KVM, make sure that KVM is compatible with your system. Otherwise, you will keep running into errors, and KVM won’t install properly.

To check the compatibility between the two, run this command:

egrep -c ‘(vmx|svm)’ /proc/cpuinfo

If the output you get is greater than 0, that means KVM is compatible with the system and can be installed.

Step 3: Install Necessary Packages for KVM

Now that we have confirmed the compatibility, let’s begin with installing essential KVM dependencies using the following command:

Sponsored
sudo apt install qemu-kvm libvirt-daemon-system virtinst libvirt-clients bridge-utils

Step 4: Enable Essential Services to Virtualize and Check Their Status

After successfully installing essential dependencies, let’s enable the services that are needed to virtualize. Enable livirtd using the following command:

sudo systemctl enable libvirtd

Now start libvirtd by issuing the following command:

sudo systemctl start libvirtd

Let’s verify the status of libvirtd using the command mentioned below. If it is running fine, you will see ‘active’ in the output.

sudo systemctl status libvirtd

Step 5: Add Your User to the KVM and Libvirt Group

Now add your user to KVM and libvirt group to get up KVM and avoid running into issues. The user can be added to the KVM group using this command:

sudo usermod -aG kvm $USER

Now add the user to the libvirt group by using this command:

sudo usermod -aG libvirt $USER

Step 6: Make a Bridge Network for the VMs (Virtual Machines)

In this step, we will create a bridge network. This can be done by creating a netplan configuration file like this:

sudo nano /etc/netplan/01-netcfg.yaml

Now add the following configuration in the 01-netcfg.yaml file:

network:

ethernets
:

eth0
:

dhcp4
: false

dhcp6
: false

bridges
:

br0
:

interfaces
: [eth0]

dhcp4
: false

addresses
: [10.254.152.27/24]

macaddress
: 01:26:3b:4b:1d:43

routes
:

– to
: default

via
: 10.254.152.1

metric
: 100

nameservers
:

addresses
: [8.8.8.8]

parameters
:

stp
: false

dhcp6
: false

version
: 2

Once you have pasted the configuration in the file, save it and exit.

Step 7: Apply Changes Using Netplan and Review the Changes

To apply the configurations, run the following command:

sudo netplan apply

You can also review the chnages using the ip addr command like this:

ip addr show

Conclusion

In today’s tutorial, we saw in detail how to install KVM on Ubuntu 22.04. Before installing, we tested the compatibility between kvm and our Ubuntu system. After that, we installed the necessary KVM packages and then installed KVM. Then we also showed you how to create a configuration file to enable a bridged network. In the end, we learned how to verify changes using an easy-to-follow command.

We hope you liked the tutorial.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago