How to Install Kvm on Ubuntu 18.04

Published on

5 min read

Install Kvm on Ubuntu 18.04

KVM (Kernel-based Virtual Machine) is an open-source virtualization technology built into the Linux kernel. It allows you to run multiple isolated guest virtual machines based on Linux or Windows. Each guest has its own operating system and dedicated virtual hardware such as CPU(s), memory, network interfaces and storage.

This guide explains how to install and configure KVM on Ubuntu 18.04 desktop. We’ll also show you how to create virtual machines that can be used as a development environment for PHP, Node.js, Ruby, and so on.

The same instructions apply for Ubuntu 16.04 and any other Ubuntu-based distribution, including Linux Mint and Elementary OS.


To be able to run guests with more than 2 GB of RAM, and to host both 32-bit and 64-bit KVM guests, you must have a 64-bit host system.

Before continuing with the installation, make sure your Ubuntu host machine supports KVM virtualization. The system should have either an Intel processor with the VT-x (vmx), or an AMD processor with the AMD-V (svm) technology support.

Enter the following grep command to see if your processor supports hardware virtualization:

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

If your CPU supports hardware virtualization, the command will output a number greater than zero, which is the number of the CPU cores. Otherwise, if the output is 0 it means that the CPU doesn’t support hardware virtualization.

On some machines, the virtual technology extensions may be disabled in the BIOS by the manufacturers.

To check if VT is enabled in the BIOS, use the kvm-ok tool, which is included in the cpu-checker package. Run the following commands as root or user with sudo privileges to install the package:

sudo apt updatesudo apt install cpu-checker

Once done, check if your system can run hardware-accelerated KVM virtual machines:


If the processor virtualization capability is not disabled in the BIOS the command will output:

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

Otherwise, the command will print and a failure message and optionally a short message on how to enable the extension. The process of enabling the AMD-V or VT technology depends on your motherboard and processor type. Refer to your motherboard documentation for the information on configuring your system BIOS.

Installing KVM on Ubuntu

Run the following command to install KVM and additional virtualization management packages:

sudo apt install qemu-kvm libvirt-bin bridge-utils virtinst virt-manager
  • qemu-kvm - software that provides hardware emulation for the KVM hypervisor.
  • libvirt-bin - software for managing virtualization platforms.
  • 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 provides an easy-to-use GUI interface and supporting command-line utilities for managing virtual machines through libvirt.

Once the packages are installed, the libvirt daemon will start automatically. You can verify it by running:

sudo systemctl is-active libvirtd

To be able to create and manage virtual machines, you’ll need to add your user to the “libvirt” and “kvm” groups. To do that, type in:

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

$USER is an environment variable that holds the name of the currently logged-in user.

Log out and log back in so that the group membership is refreshed.

Network Setup

A bridge device called “virbr0” is created by default during the libvirt installation process. This device uses NAT to connect the guests’ machines to the outside world.

Run the brctl tool to list the current bridges and the interfaces they are connected to:

brctl show
bridge name	bridge id		      STP enabled	interfaces
virbr0		  8000.52540003f59e	yes		      virbr0-nic

The “virbr0” bridge does not have any physical interfaces added. “virbr0-nic” is a virtual device with no traffic routed through it. The sole purpose of this device is to avoid changing the MAC address of the “virbr0” bridge.

This network setup is suitable for most Ubuntu desktop users but has limitations. If you want to access the guests from outside the local network, you’ll need to create a new bridge and configure it so that the guest machines can connect to the outside world through the host physical interface.

Creating Virtual Machines

Now that KVM is installed on your Ubuntu desktop, let’s create the first VM. This can be done either from the command-line or using the virt-manager application.

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

  1. In the Activities search bar type “Virtual Machine Manager” and click on the icon to launch the application.

  2. After the application is started, from the top menu click on “File” -> “New Virtual Machine”:

    New Virtual Machine
  3. A new window will appear. Choose “Local install media” and click on the “Forward” button.

  4. Provide your ISO image path and click on the Forward button.

  5. In the next screen, choose the VM’s memory and CPU settings. Click Forward.

  6. Next, select “Create a disk image for the virtual machine” and select the VM’s disk space size. Click Forward.

  7. Enter a name for your virtual machine name and click “Finish”.

  8. The VM will boot up, and a new window will open:

    Virtual Machine Install

    From here, you can follow the instructions on the screen to complete the installation of the operating system.

Once the operating system has been installed, you can access it from the virt-manager application, via ssh or using the Serial Console interface.


We’ve shown you how to install KVM on Ubuntu 18.04 systems. You can now create your Windows or Linux guest machines. To find more information about KVM, visit the KVM documentation page.

If you have any questions, please leave a comment below.