Linux

How to Install KVM on Ubuntu 20.04 LTS

How to Install KVM on Ubuntu 20.04 LTS

Step by step guide for installing KVM on Ubuntu 20.04 and creating a virtual machine using virt-manager

KVM or Kernel-based Virtual Machines are modules in the Linux Kernel that allow users to run Virtual Machines on their systems. It boasts almost bare-metal performance compared to other virtualization software because it is closely related to the Linux kernel.

KVM combined with an API / Toolkit called libvirt is used to create VMs on Ubuntu. Tools such as Virt-Manager (front-end GUI) and Virsh (CLI) are used to simplify VM creation and management.

In this article, we will learn how to install KVM correctly on Ubuntu 20.04 LTS.

Precondition

Before we begin the installation, we need to ensure that we meet the requirements needed to run the KVM. We need a processor that supports hardware virtualization. If the processor supports hardware virtualization, we must ensure that it is enabled in the BIOS.

To check if your processor supports hardware virtualization, press ctrl + alt + t to open the terminal. We will use a neat command called egrep which uses Regexp to look for text patterns from files. The file that we are looking for information about the CPU is located at / proc / cpuinfo. Paste the following command in the terminal to check hardware virtualization support.

egrep -c '(vmx|svm)' /proc/cpuinfo

1

If you get an output other than 0, your processor supports hardware virtualization. The output number is no. the core or thread your processor has. The only step left now is to make sure hardware virtualization is enabled in the BIOS.

The process of enabling hardware virtualization now depends on whether you have an Intel or AMD processor. See your motherboard’s manual to find out how to enable virtualization. For Intel Processors, you must enable Virtualization in the BIOS settings. For AMD processors, activate a setting called SVM Mode.

2

We have now verified that we have a processor that supports hardware virtualization and activated it in the BIOS. Now we can move to Installation.

Installation

Open a terminal by pressing ctrl + alt + t keyboard shortcuts. To install KVM paste the following command in the terminal and press enter.

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

3

Qemu-kvm is a KVM package, while libvirt-daemon-system and libvirt-clients are libvirt toolkit packages. The bridge-utils package is used to configure the Ethernet bridge for the VM.

Verifying the Installation

There are two methods for verifying the success of a KVM installation. Good run

kvm --version

4

or

virsh list --all

5

If you get output as shown above, then KVM is installed correctly on your system. You can now create a VM using the virsh command to create a VM or install a virt-manager GUI tool to create and manage your VM as you wish.

Creating a VM

In this section we will use virt-manager to create and run a VM on Ubuntu 20.04. To install virt-manager on Ubuntu 20.04, run the following command:

sudo apt install virt-manager

After installation is complete, run virt-manager. You will be greeted with the following window.

6

To create a new VM, you need to click the Create a new virtual machine button.

7

A pop-up window titled New VM will appear, select the Local installation media (ISO image or CDROM) option and click Continue.

8

We need an ISO image of the Operating System that our Virtual Machine wants to create. Click browse to select the OS to be installed.

9

You will be presented with the Choose Storage Volume window, we will now use the default storage set, you can try playing around by creating a new storage set for the virt-manager to use. For now, we will copy the ISO image from the OS to the following directory using the cp command.

10

sudo cp source_of_iso_file /var/lib/libvirt/images

We need root privileges to copy the ISO to the default set, so we use the sudo command and source_of_iso_file is the OS location you choose. After copying the ISO image directory to libvirt, press the Refresh list volume button. Your ISO OS of choice will appear in the list below, I chose MX-Linux to install.

11

Select the OS you chose to install and press the Choose Volume button.

12

After selecting ISO, click Forward in the previous window.

13

Select the amount of Memory / RAM to be allocated to the VM and the Number of CPU cores in the next window. I recommend allocating at least the minimum number of recommendations required by the OS.

14

Next, allocate at least the minimum amount of disk space required by the OS. I recommend a minimum of 30 GB for Windows and 20 GB for Linux distributions. Virt-manager will automatically create a Virtual Disk for the OS if the first option is selected.

Tip: You can create your own custom storage with the second option.

15

You can change the name of the VM on this new screen and confirm the details. Click Finish to begin your OS installation on the virtual disk.

Tip: You can also try changing your VM settings by checking custom configurations before installing options for additional features.

16

Selesaikan penginstalan OS dengan mengikuti proses penginstalan untuk OS yang dipilih….

17

After completing the installation, you can start the VM by selecting it and clicking Power on the virtual machine button

18

Now we have a functional VM that is ready to use.

19

Related posts

How to Change the Time Zone in Ubuntu 20.04

Linux

How to Get Windows Terminal Fonts (Cascadia Code) on an Ubuntu Terminal

Linux

How to Install and Use PHP Composer on Debian 10

Linux

How to Install the NoSQL Apache CouchDB Database on CentOS 8

Linux

How to Install Yarn on Ubuntu 20.04

Linux

How to Install TeamViewer on Ubuntu 20.04

Linux

How to Change the Directory Name in Linux

Linux

How to make Ubuntu look like Windows XP

Windows

How to Install VirtualBox Guest Additions on Ubuntu 20.04

Linux