vmorecloud - Free IT training download and specialized forum of Cisco and Microsoft VMware virtualization cloud and Linux

Install KVM Ubuntu 22.04 – Step-by-Step

- Advertisement -

151

I believe that numerous individuals are examining the hypervisor landscape in 2024, particularly those who are VMware customers. When it comes to selecting a virtualization platform that can effectively handle important virtualization workloads such as Windows Server, Linux, and containers for production purposes, hypervisors based on KVM are an excellent option.

When we consider the multitude of solutions that operate on KVM beneath the surface, there are numerous choices available for running virtual operating systems. However, there are various factors and considerations to take into account. For instance, customers must assess which solution aligns closely with their specific use cases, development requirements, product innovation, device support, application demands, financial considerations, budget constraints, compatibility, and automation capabilities utilizing standard tools like Ansible, Chef, and others for provisioning tasks.

What is Kernel-based virtual machine (KVM)?

- Advertisement -

The KVM hypervisor, which has been included in Linux distributions since approximately 2006, is a freely available hypervisor. It operates as a type 1 hypervisor within the Linux kernel and functions as a loadable kernel module. Its purpose is to enable virtualization on Linux systems, thereby facilitating the running of virtual machines.

A type 1 hypervisor

Type 1 means it is a bare metal hypervisor capable of really robust performance. It allows running virtual machines on top of your host hardware by using host hardware emulation.

Many available tools

There are numerous tools accessible that enable effective management of virtual machines operating on KVM. KVM virtual machines function and operate similarly to virtual machines on alternative hypervisor platforms.

Features of KVM

The configuration of the KVM kernel-based virtual machine offers numerous features and capabilities that are commonly found in enterprise hypervisors available for commercial use. Similar to other hypervisors, it replicates the functionalities of a physical machine, such as a system BIOS, CPU, memory, disk, and other essential components required to operate a complete operating system within its own isolated environment.

Administrators have the capability to assign CPU cores and other necessary resources in a detailed manner, based on the specific requirements of virtual machine workloads.

Benefits of KVM hypervisor

What are the benefits of the KVM hypervisor? There are many, but below are a few of the ones to note:

  • It is free
  • It is easy to install
  • There are GUI management tools available
  • It has proven scalability – capable of thousands of nodes in a cluster
  • Amazon AWS EC2 services are said to be built on a version of KVM

What are the requirements for running KVM on ubuntu 22.04?

To successfully utilize KVM on Ubuntu 22.04, it is essential to have a CPU that is equipped with built-in CPU virtualization extensions. These extensions are present in processors such as Intel VT and AMD-V technologies. This enables KVM to optimize the performance of virtual machines by providing accelerated processing capabilities.

Checking for the CPU requirements

Ensure that you verify the presence of the listed VMX capabilities (Intel) to confirm the availability of CPU hardware virtualization. Linux offers a built-in CPU checker accessible through the command line.

grep –color vmx /proc/cpuinfo

You want to ensure your host machine has a compatible CPU and plenty of memory and disk space for running KVM virtualization. Storage space needed and other resources will depend on the number of virtual machines ran on the host.

Network resources

To ensure a range of choices while setting up your bridge interface and bridge network in the KVM hypervisor host, it is advisable to have multiple network interface cards.

If your KVM hypervisor host is intended for production use, it is recommended to configure a bonded network interface setup. This will provide high availability, redundancy, and improved bandwidth.

Additionally, you can create virtual bridge configurations to accommodate VLANs and other specific use cases.

Healthy ecosystem of support and applications

Running KVM on an Ubuntu system provides benefits since Ubuntu is an extremely popular distribution, with great community support, and a healthy app repository.

Install KVM on Ubuntu 22.04

In order to install KVM on Ubuntu 22.04, we will explore the necessary command line instructions. To begin, it is essential to have an already prepared Ubuntu 22.04 system for the installation process.

To ensure that we have the most up-to-date Ubuntu packages, I am executing a “sudo apt update” command.

If you are interested in learning how to efficiently create an Ubuntu 22.04 template within your VMware vSphere environment, I invite you to refer to my blog post that provides step-by-step instructions on accomplishing this task. You can find the post here:
Packer Build Ubuntu 22.04 for VMware vSphere

Installing packages overview

Which KVM packages are necessary for the installation of kvm on Ubuntu 22.04?

  • You will need to install qemu-kvm. You will need to install qemu-kvm-libvirt.
  • To install KVM virt-manager with a graphical interface, use the “apt install virt-manager” command from the apt package manager.

KVM virtual machines packages install:

Note the following command line commands in Ubuntu 22.04:

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

- Advertisement -

Checking for KVM virtual machines capabilities

To verify if our Ubuntu 22.04 installation supports KVM virtualization, we can execute a prompt command. Just enter the following command:

kvm-ok

To verify if our Ubuntu 22.04 installation supports KVM virtualization, we can execute a prompt command. Just enter the following command:

Install Virt-Manager in Ubuntu 22.04 workstation

To effortlessly handle your KVM installation on Ubuntu using a visual interface and conveniently create virtual machines, the Virt-Manager tool provides a graphical interface that enables you to manage your KVM installation.

With Virt-Manager, you have the capability to generate a fresh virtual machine and oversee local installation media, such as an ISO file for operating system installation on your newly created virtual machine.

Below, we are using the command:

sudo apt install virt-manager

Install ssh-askpass

To effectively utilize password authentication on your KVM host, you will need to employ the ask-ssh package. By using the ssh-askpass utility, you can receive a prompt to enter your SSH credentials directly from Virt-Manager.

To manage the KVM installation, it is essential that the user you are utilizing is a part of the libvirt group.

sudo apt install ssh-askpass

Adding a new connection to your KVM installation in Virt-Manager

After installing Virt-manager, we can now add a connection to our KVM host.

After adding the connection, the KVM host will be displayed. At this stage, you can easily establish a connection by double-clicking on the host.

Upload an ISO image to use for guest operating system installation

We can now proceed to transfer an ISO file to the KVM host for the purpose of installing the guest operating system. The designated directory for uploading ISO image files to KVM is the /var/lib/libvirt/images location.

Once we successfully upload the ISO file to the KVM host, we can initiate the procedure of creating a virtual machine using Virt-Manager.

Create a new virtual machine in KVM virt manager

Let’s get started on creating a fresh virtual machine. Begin by clicking on the option File > New Virtual Machine. The first step is to choose the ISO image that we will use for the installation.

Click Browse.

Select the ISO image displaying in the default images location.

I observed that Windows Server 2022 was not populated in the operating system. When you start typing in the operating system field, a list will appear for you to select from. I opted for the installation option of Windows Server 2022 as the operating system.

Choose your CPU and memory configuration.

Configure the disk size for the installation.

On the configuration screen for reviewing, you also have the option to select the network interface of your choice, such as the default bridge. By default, it will be set to a configuration that utilizes NAT.

After modifying the sequence of startup, the virtual machine manager VM successfully initiated.

Wrapping Up

Overall, the process of setting up and using KVM in Ubuntu 22.04 is effortless. Once you have a Ubuntu 22.04 machine up and running, all you need to do is install the necessary KVM packages to enable its functionality. After that, you can effortlessly connect to the KVM host using Virt-Manager on another Ubuntu workstation machine.

- Advertisement -

Leave A Reply

Your email address will not be published.