Skip to Content

How to Install KVM on Ubuntu 18.04 LTS Server

This tutorial will show you how to install KVM on Ubuntu 18.04 so that you can run multiple operating systems on the same server at the same time.


KVM (Kernel-based Virtual Machine) is an open-source virtualization solution for Linux. It allows you to reduce hardware costs by running multiple operating systems as virtual machines at the same time.

The kernel component of KVM is included in mainline Linux (as of 2.6.20) and the userspace component is included in mainline QEMU (as of 1.3).

Just like VMware ESXi and XenServer, it requires a CPU that supports hardware virtualization so that it can run VMs at near native performance.


KVM only works with a CPU that supports hardware virtualization. You can check if your CPU is supported by installing cpu-checker and running the kvm-ok command.

sudo apt install cpu-checker -y

The output of kvm-ok should be

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

If the output says “KVM acceleration can be used” then we are good to go. If your system supports hardware acceleration and its not enabled in the BIOS, you should see a message like:

INFO: /dev/kvm does not exist
HINT:   sudo modprobe kvm_amd
INFO: Your CPU supports KVM extensions
INFO: KVM (svm) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
      and then hard poweroff/poweron your system
KVM acceleration can NOT be used

Note: If you are running Linux as a VMware virtual machine on Fusion, Workstation or ESXi as a test lab, you might need to edit the VMX file to enable hardware virtualization inside the VM. Power off the VM and then add the following line to the .vmx file:

vhv.enable = “TRUE”

Power the VM back on and check again with the kvm-ok command.

How to Install KVM on Ubuntu 18.04 LTS Server

Run the following commands to upgrade your system and then install KVM.

sudo apt update && sudo apt upgrade -y
sudo apt install qemu-kvm libvirt-bin virtinst -y

The libvirt-bin package will give us utilities like virsh to manage VMs on the host and the virtinst package will allow us to create VMs using virt-install.

Next Steps

KVM is now installed and you’re ready to create a VM and install a guest operating system. The following tutorial will help you get you started:

Creating a Virtual Machine with virt-install