Today you will learn how to install KVM on Ubuntu 22.04. KVM stands for Kernel-based Virtual Machine. It virtualizes x86 hardware containing virtualization extensions (Intel VT or AMD-V) on Linux systems allowing the virtualized system to run as an hypervisor.
It is similar to VirtualBox and VMWare Workstation. You can run create and execute multiple virtual machines using original Windows or Linux images.
- Ubuntu 22.04 installed
- CPU that supports virtualization
- Root privileges
- Fast internet
Install KVM on Ubuntu 22.04
First check if your CPU supports KVM
egrep -c '(vmx|svm)' /proc/cpuinfo
If the output is higher than zero, hardware virtualization is supported otherwise it is not. If virtualization is not not supported, enter system BIOS and enable VT technology.
Install QEMU / KVM & Libvirt on Ubuntu 22.04
All required packages are not preinstalled in Ubuntu 22.04 even though KVM is build in to the Linux Kernel.
Install required packages to allow installation of KVM.
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon
Start & Enable KVM service:
sudo systemctl enable --now libvirtd
Install KVM on Ubuntu 22.04
Install Virt-Manager which is a tool developed by RedHat to easily create, manage and run virtual machines using KVM graphically.
sudo apt install virt-manager -y
Configure network bridge
Bridge network connection to allow KVM to access your host network interface. To start with configuration, check the name of your network interface.
Execute the command;
[email protected]:~$ ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:e7:28:69 brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3 valid_lft 85541sec preferred_lft 85541sec inet6 fe80::2e18:c43:3ad1:7cdc/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:61:d8:fd brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever
From the code snippet above my network interface is
enp0s3. Yours can be similar too, it is mostly your Broadcast network adapter.
Share connection with VM(optional)
To share the connection, let Ubuntu 22.04 know that you need to bridge the communication.
Edit the network interface configuration file by using your favorite text editor. I will use
sudo gedit /etc/network/interfaces
This is the first edit and the file maybe empty or have few lines. Add the line below to allow bridging using the interface
br0 as the first line.
Add the following as the second line.
iface enp0s3 inet manual
Now add the bridging details. The lines below tells the bridge manage the network interface using DHCP for automatic IP address assignment.
iface br0 inet dhcp bridge_ports enp0s3
To make things simpler, open the file and paste the information below.
auto br0 iface enp0s3 inet manual iface br0 inet dhcp bridge_ports enp0s3
Save and close the file.
Add your user to the groups (optional)
If you have root privileges, you are good to go. If you don’t have root privileges or you want to add another user to use the VM, make sure you add them to both groups: libvirt and libvirt-qemu
sudo adduser user1 libvirt sudo adduser user1 libvirt-qemu
Now reboot the system even if you did not add yourself to the groups.
Launch KVM on Ubuntu 22.04
Open virt-manager called Virtual Machine Manger from the application launcher or open terminal and enter
KVM launches as below.
Uninstall KVM on Ubuntu 22.04
Execute the command:
sudo apt remove --purge qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon
Now remove the
sudo apt purge virt-manager
You have just managed to install KVM on Ubuntu 22.04 within few minutes. Now create and run multiple systems using KVM. Find more information KVM Articles
More interesting tutorials
Install Bacula Server with MariaDB on Ubuntu 22.04
Install Thunderbird mail client on Ubuntu 22.04