Install And Set Up KVM On Ubuntu 18.04 Bionic Beaver Linux


Install KVM with bridged networking and virt-manager on Ubuntu 18.04 Bionic Beaver


Ubuntu 18.04


A working install of Ubuntu 18.04 with root privileges


  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)


KVM is the Linux kernel’s own answer to virtualization. As a result, it’s the lightest, most stable, and most universal virtualization option for Linux systems. While, KVM isn’t as simple to set up as packaged solutions like VirtualBox, it’s ultimately more efficient and flexible.

When you pair KVM with a graphical manager like virt-manager, it’s extremely simple to use, and it integrates well with your Linux desktop. It’s also simple to get VM guests on your regular network through bridged networking. This provides a more seamless experience overall.

Install The Packages

Even though the capabilities for KVM are built into the kernel itself, there are a couple of packages that you’ll need to get started. They’re all standard packages in the default Ubuntu repositories, so install them first.

$ sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager

Configure The Network Bridge

Before you can dive in and start making virtual machines, you’re going to need to set up a network bridge. Bridged networking is what allows your VMs to access your network and be assigned their own IP addresses.

To start, find out what names your network interfaces have been assigned. This guide will use eth0, but your interface will probably be different. To find out your network interfaces, run $ ip a. Notate the interface with your computer’s local IP next to it. Chances are, it’ll be something like enp5s0.

Once you have your network interface, you need to edit a configuration file to tell Ubuntu that your connection is going to be bridged. This process won’t negatively impact your connection at all. It’ll just allow that connection to be shared with the VMs.

Default Network Interfaces Ubuntu 18.04

Default Network Interfaces

Using your favorite text editor, open /etc/network/interfaces. The default file is pretty plain. It really only concerns the loopback interface. You’re obviously going to change that.

In order to bring your new bridge interface up by default, add br0 at the end of the autoauto lo br0

Below the loopback information, add the following line for your current interface.

iface eth0 inet manual

Next, you can add the bridge information. These lines tell Ubuntu that your bridge will use DHCP for automatic IP address assignment, and your bridge will manage your current interface.

iface br0 inet dhcp
    bridge_ports eth0
Bridged Network Interfaces Ubuntu 18.04

Bridged Network Interfaces

That’s it for your bridge. Save and exit.

Add Your User To The Groups

Next, you’re going to need to add your user to the appropriate groups so you don’t need root privileges to manage your virtual machines. There are two groups that you need.

$ sudo adduser username libvirt
$ sudo adduser username libvirt-qemu

When you’re done there, restart your system. That’s the best way to ensure that both the networking and user changes take effect.

Creating A VM

Virt-Manager On Ubuntu 18.04

Virt-Manager On Ubuntu 18.04

When Ubuntu comes back up, look for virt-manager in your application launcher. Click on it to open it up. The window that opens up is fairly plain, but it has everything that you need to manage your VMs. To start making a new one, click on the icon that looks like a shining screen. It’s the first one in the icon row.

Virt-Manager Select Install Type Ubuntu 18.04

Virt-Manager Select Install Type

A new window will pop open to walk you through the process. The first thing that it will ask you to do is select a source. In most cases, you’re going to use a regular install ISO to make your VMs, so leave the first option selected and keep going.

Virt-Manager Select Install Media Ubuntu 18.04

Virt-Manager Select Install Media

The next screen asks you to select your image. Browse to the location of your image. If the folder with your image isn’t available, use the + icon at the bottom of the left side to add it.

Virt-Manager Allocate CPU Memory Ubuntu 18.04

Virt-Manager Allocate CPU Memory

On the following screen, you can allocate memory and cpu cores to the VM. Don’t give it all of your system’s resources. That obviously won’t go well.

Virt-Manager Allocate HDD Ubuntu 18.04

Virt-Manager Allocate HDD

The next screen lets you determine the hard drive size of your VM. It’s just a VM, so it doesn’t need a huge hard drive. Just make sure to give it enough to install and run what you need.

Virt-Manager Finalize Install Ubuntu 18.04

Virt-Manager Finalize Install

Finally, you can see an overview of your VM before you finalize it. On this screen, you can also name it.

Once you finalize your VM, a new window will open and boot up the VM. In that window, you will see the installer for the image that you selected. Everything from here is exactly the same as installing on a regular computer.

Closing Thoughts

KVM provides a great amount of flexibility and power to your computer. It lets you easily run and manage multiple VMs from a convenient interface when paired with virt-manager. With KVM set up, you’ll have access to just about any operating system in a virtualized form, directly from your Ubuntu desktop.