View Categories

How to install KVM in Ubuntu Linux

Estimated Reading Time: 2 minute(s)

Table of Contents

Case #

You need to install the KVM hypervisor in Ubuntu Linux. For the purpose of this demo I will be deploying KVM in Ubuntu Linux LTS server, as shown below. This article provides guidance on how to install KVM in Ubuntu Linux.

Cloud School Docs - image 27 -

However you can follow the same procedure on any Linux platform, making any adjustments related to the package management system used by your distribution (e.g. deb vs rpm). This article offers step-by-step instructions on how to install KVM in Ubuntu Linux.

Solution #

First check if your Ubuntu server or desktop installation supports virtualization by running the below command. You need to get a result which is greater than 0, to ensure that your system supports virtualization.

egrep -c '(vmx|svm)' /proc/cpuinfo
Cloud School Docs - image 24 -

Run the following command to ensure that kvm can be supported and installed on your machine. If the kvm-ok command is not available it should be installed as part of the cpu-checker deb package.

Cloud School Docs - image 25 -
Cloud School Docs - image 26 -
You are now ready to install the KVM-related packages to enable KVM virtualization in your Ubuntu system. Run the command below.
sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager
Cloud School Docs - image 28 -

After successful installation of the KVM packages and dependencies, ensure that the libvirt deamon is configured to start automatically at system boot and that it is running, before moving on with remaining configuration steps.

sudo systemctl enable --now libvirtd
sudo systemctl status libvirtd
Cloud School Docs - image 29 -

After confirming that the KVM modules are loaded in your system and getting information about the available guest operating systems, you can run virt-manager to start creating your KVM virtual machines.

lsmod | grep -i kvm
osinfo-query os
Cloud School Docs - image 30 -
Cloud School Docs - image 31 -
Cloud School Docs - image 33 -

If you don't have a graphical environment in your Linux system, you can alternatively run the virt-install command to deploy virtual machines under KVM.

Cloud School Docs - image 32 -

Powered by BetterDocs