Professional Documents
Culture Documents
04 Step-by-Step
Menu
···
This blog post will show you how to install KVM on Ubuntu 22.04 step-by-step. At the tail
end of this post, we will demonstrate how you can create a virtual machine once the
installation of KVM is complete.
KVM allows users to create and run multiple guest machines which can be either Windows
or Linux. Each guest machine runs independently of other virtual machines and the
underlying OS ( host system ) and has its own computing resources such as CPU, RAM,
network interfaces, and storage to mention a few.
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 1/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Prerequisites
Pre Installed Ubuntu 22.04
2 vCPUs & 4 GB RAM
Stable Internet Connectivity
This is achieved by running the following command. if the output is greater than 0, then
virtualization is enabled. Otherwise, virtualization is disabled and you need to enable it.
From the above output, you can deduce that virtualization is enabled since the result
printed is greater than 0. If Virtualization is not enabled, be sure to enable the virtualization
feature in your system’s BIOS settings.
In addition, you can verify if KVM virtualization is enabled by running the following
command:
$ kvm-ok
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 2/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
For this to work, you need to have installed the cpu-checker package, otherwise, you will
bump into the error ‘Command ‘kvm-ok’ not found’.
Directly below, you will get instructions on how to resolve this issue, and that is to install
the cpu-checker package.
···
Then run the kvm-ok command, and if KVM virtualization is enabled, you should get the
following output.
$ kvm-ok
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 3/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 4/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
libvirt-clients – A set of client-side libraries and APIs for managing and controlling
virtual machines & hypervisors from the command line.
bridge-utils – A set of tools for creating and managing bridge devices.
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 5/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
In addition, you need to add the currently logged-in user to the kvm and libvirt groups so
that they can create and manage virtual machines.
The $USER environment variable points to the name of the currently logged-in user. To
apply this change, you need to log out and log back again.
···
5) Create Network Bridge (br0)
If you are planning to access KVM virtual machines outside from your Ubuntu 22.04 system,
then you must map VM’s interface to a network bridge. Though a virtual bridge named
virbr0, created automatically when KVM is installed but it is used for testing purposes.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 6/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
To create a network bridge, create the file ‘01-netcfg.yaml’ with following content under the
folder /etc/netplan.
$ sudo vi /etc/netplan/01-netcfg.yaml
network:
ethernets:
enp0s3:
dhcp4: false
dhcp6: false
# add configuration for bridge interface
bridges:
br0:
interfaces: [enp0s3]
dhcp4: false
addresses: [192.168.1.162/24]
macaddress: 08:00:27:4b:1d:45
routes:
- to: default
via: 192.168.1.1
metric: 100
nameservers:
addresses: [4.2.2.2]
parameters:
stp: false
dhcp6: false
version: 2
Note: These details as per my setup, so replace the IP address entries, interface name and
mac address as per your setup.
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 7/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
$ ip add show
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 8/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 9/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Click on “File” then select “New Virtual Machine”. Alternatively, you can click on the button
shown.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 10/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
This pops open the virtual machine installation wizard which presents you with the
following four options:
In this guide, we have downloaded a Debian 11 ISO image, and therefore, if you have an
ISO image, select the first option and click ‘Forward’.
In the next step, click ‘Browse’ to navigate to the location of the ISO image,
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 11/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
In the next window, click ‘Browse local’ in order to select the ISO image from the local
directories on your Linux PC.
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 12/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
···
As demonstrated below, we have selected the Debian 11 ISO image. Then click ‘Open’
Once the ISO image is selected, click ‘Forward’ to proceed to the next step.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 13/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Next, define the RAM and the number of CPU cores for your virtual machine and click
‘Forward’.
In the next step, define the disk space for your virtual machine and click ‘Forward’.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 14/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
To associate virtual machine’s nic to network bridge, click on ‘Network selection’ and choose
br0 bridge.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 15/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Once completed, the virtual machine will start with the OS installer displayed. Below is the
Debian 11 installer listing the options for installation. From here, you can proceed to install
your preferred system.
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 16/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Conclusion
And that’s it. In this guide, we have demonstrated how you can install the KVM hypervisor
on Ubuntu 22.04. Your feedback on this guide is much welcome.
Read Also: How to Create KVM Virtual Machine Snapshot with Virsh Command
Share Now!
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 17/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Kamus
July 4, 2022 at 10:44 am
Hi James, thanks for this great article, I would like to add a little comment.
If you want to let host machine to access the vm machine by SSH, and let the vm
machine to access internet by the host machine ethernet, there is a additional
package should be installed.
sudo apt install libnss-libvirt
Reply
Pål Bjartan
October 10, 2022 at 10:42 am
Reply
John
October 16, 2022 at 12:01 am
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 18/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
tried to re-install via APT, APT-GET ‘virt-manager’ and ‘virtinst’ packages, neither
one is found.
Anyone else encountering this issue after Ubuntu 22.04 LTS ‘jammy jellyfish’
upgrade from 20.04 LTS?
Reply
Leave a Comment
Name *
Email *
Post Comment
Search …
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 19/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 20/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Recent Posts
···
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 21/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 22/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 23/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 24/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 25/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 26/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 27/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 28/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 29/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 30/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 31/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 32/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 33/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 34/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 35/36
02/11/2023 01:50 How to Install KVM on Ubuntu 22.04 Step-by-Step
Follow Us
© 2023 LinuxTechi
https://www.linuxtechi.com/how-to-install-kvm-on-ubuntu-22-04/ 36/36