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
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.
KVM is installed and you’re now ready to create a VM and install a Guest operating system. The following tutorials will help you get you started:
- Creating a Virtual Machine with Virt-Install
- Configuring a KVM Virtual Machine to use Bridged Networking