Jul 26, 2022 5 min read

How to Install Kvm on Ubuntu 20.04

Install KVM on Ubuntu 20.04 with our step-by-step tutorial. It's a virtualization technology for running multiple OS on a single machine.

Install Kvm on Ubuntu 20.04
Table of Contents

Choose a different version or distribution


Before we begin talking about how to install KVM on Ubuntu 20.04, let's briefly understand – What is KVM?

KVM, short for Kernel-based Virtual Machine, is an open-source virtualization technology that allows you to run multiple operating systems on a single physical machine. By leveraging the power of the host kernel, KVM provides efficient and secure virtualization capabilities.

It offers flexibility, scalability, and excellent performance, making it a popular choice for businesses and individuals looking to create virtual environments. With KVM, you can consolidate your hardware resources, optimize server utilization, and streamline management, all while enjoying the benefits of virtualization.

This tutorial will show you how to install and configure KVM on Ubuntu 20.04 desktop. We'll also demonstrate how to build virtual machines that can be used as development environments for various applications.

Advantages of KVM

  1. Efficient Virtualization: KVM leverages the host kernel, ensuring high-performance virtualization with minimal overhead.
  2. Scalability: KVM enables you to scale your virtualized environment easily, accommodating changing resource requirements.
  3. Security: By utilizing the host's security features, KVM provides a robust and secure virtualization platform.
  4. Flexibility: KVM supports a wide range of operating systems, giving you the flexibility to run diverse workloads.
  5. Management Simplicity: KVM offers user-friendly management tools, making it easy to create, configure, and monitor virtual machines.

Prerequisites to Install Kvm on Ubuntu 20.04

A 64-bit host system is required to run guests with more than 2 GB of RAM.

Check that your Ubuntu host machine supports KVM virtualization before proceeding with the installation. The system should include either an Intel processor with VT-x (vmx) technology support or an AMD processor with AMD-V (svm) technology support.

To check whether your processor supports hardware virtualization, use the grep command:

grep -Eoc '(vmx|svm)' /proc/cpuinfo

If the CPU supports hardware virtualization, the command will return a value greater than zero, indicating the number of CPU cores. Otherwise, a 0 result indicates that the CPU does not support hardware virtualization.

Manufacturers may disable virtual technology extensions in the BIOS on some machines.

Use the kvm-ok tool included in the package to see if VT is enabled in the BIOS. To install the cpu-checker package, which includes the kvm-ok command, run the following commands as root or a user with sudo privileges:

sudo apt update
sudo apt install cpu-checker

Once installed, determine whether your system is capable of running hardware-accelerated KVM virtual machines:


If the BIOS does not disable the processor virtualization capability, the output will look like this:

INFO: /dev/kvm exists
KVM acceleration can be used

Otherwise, the command will print a failure message as well as a short message explaining how to enable the extension. The procedure for enabling AMD-V or VT technology is determined by your motherboard and processor type. For information on how to configure your system BIOS, refer to the documentation included with your motherboard.

Install KVM on Ubuntu 20.04

To install KVM and other virtualization management packages, run the following command:

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager
  • qemu-kvm⁣—software that emulates hardware for the KVM hypervisor.
  • libvirt-daemon-system⁣—configuration files for running libvirt as a system service
  • libvirt-clients⁣—platform management software for virtualization.
  • bridge-utils⁣—a set of command-line tools for configuring Ethernet bridges.
  • virtinst⁣—a set of command-line tools for creating virtual machines.
  • virt-manager - libvirt provides an easy-to-use GUI interface as well as command-line utilities for managing virtual machines.

The libvirt daemon will start automatically after the packages are installed. You can check it by typing:

sudo systemctl is-active libvirtd

You must add your user to the "libvirt" and "kvm" groups in order to create and manage virtual machines. To do so, type:

sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USER

The name of the currently logged-in user is stored in the environment variable $USER.

Log out and log back in again to refresh the group membership.

Network Setup

During the installation, a bridge called "virbr0" is created. This device connects the machines of the guests to the outside world via NAT.

The brctl command can be used to list the current bridges and the interfaces to which they are connected:

brctl show
bridge name	bridge id		      STP enabled	interfaces
virbr0		  8000.52540089db3f	yes		      virbr0-nic

There are no physical interfaces added to the "virbr0" bridge. "virbr0-nic" is a virtual device that receives no traffic. The sole purpose of this device is to prevent the "virbr0" bridge's MAC address from changing.

This network configuration is suitable for the majority of Ubuntu desktop users, but it has limitations. If you want to connect to the guests from outside the network, you must first create a new bridge and configure it so that the guest machines can connect to the outside world via the host physical interface.

Creating Virtual Machines

Now that KVM is installed on your Ubuntu desktop, you can create your first virtual machine (VM). This can be done using the command line or the virt-manager application.

To create your virtual machine, download the ISO image of the operating system you want to install and follow the steps below:

  1. Enter "Virtual Machine Manager" in the Activities search bar and click on the icon to launch the application.
  2. After starting the application, go to the top menu and select "File" -> "New Virtual Machine".
  3. A new window will be opened. Select "Local install media" and click on the "Forward" button.
  4. Enter your ISO image path and click on the Forward button.
  5. Select the VM's memory and CPU settings on the following screen. Click the Forward button.
  6. Next, select "Create a disc image for the virtual machine" and enter the disc space size for the VM. Click the Forward button.
  7. Fill in a name for your virtual machine and click "Finish."
  8. The VM will start, and a new window will appear.

From here, simply follow the on-screen instructions to finish installing the operating system.

After installing the operating system, you can access the virtual machine via the virt-manager application, ssh, or the Serial Console interface.

FAQs to Install KVM on Ubuntu 20.04

How do I verify if KVM is installed correctly?

After installing KVM, you can verify its installation by running the command: sudo kvm-ok. If the output shows "KVM acceleration can be used," it means KVM is installed and working correctly.

How do I create a virtual machine (VM) using KVM?

You can create a VM using KVM by using the command-line tools like virt-install or by using a graphical tool like virt-manager. Both methods provide options to customize the VM's hardware and settings.

How do I start and stop a virtual machine with KVM?

To start a virtual machine, you can use the virsh start command followed by the VM name. For example, sudo virsh start myvm. To stop a VM, use the virsh shutdown command followed by the VM name. For example, sudo virsh shutdown myvm.

Can I use KVM without a graphical interface?

Yes, KVM can be used without a graphical interface. You can manage KVM and its virtual machines entirely from the command line using tools like virsh, qemu-img, and virt-install.

How do I enable bridged networking for my KVM virtual machines?

To enable bridged networking, you need to configure a bridge interface on your Ubuntu host. You can do this by modifying the /etc/netplan/01-netcfg.yaml file and adding the necessary bridge configuration. After making changes, apply the configuration using sudo netplan apply.

Can I use KVM with other virtualization technologies like VMware or VirtualBox?

KVM is a standalone virtualization solution and cannot be used simultaneously with other hypervisors like VMware or VirtualBox. You can, however, import and convert virtual machines between different formats using tools like qemu-img.

How do I uninstall KVM from my Ubuntu 20.04 system?

To uninstall KVM and its associated packages, you can use the command: sudo apt remove --purge qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager. This will remove KVM and all its dependencies from your system.


We demonstrated how to install KVM on Ubuntu 20.04 systems. You can now start creating Windows or Linux guest machines. More information about KVM can be found on the KVM documentation page.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.