Virtualization is a popular technology used in cloud-based services and even in modern day datacenters to host applications. So what exactly is virtulization? This is a process of creating a virtual machine(s) from the hardware components of a PC using a hypervisor. Virtual machines, also known as guests, are isolated environments that run their own operating system independently of the host system which is th ephysical hardware. The hypervisor provides an additional layer on top of the physical system that enables the abstraction of hardware components such as CPU, RAM, disk space, USB controllers, keyboard, mouse, NICs and so much more.
You can create multiple virtual machines from a single PC hardware provided it has the right amount of resources required to run the virtual machines. Benefits of virtulization include reduced operational costs, increased efficiency and productivity, and faster provisioning of services and applications.
KVM ( Kernel Virtualization Manager ) is an opensource virtualization technology built specifically for Linux operating system. It converts your system into a type 1 hypervisor and allows users to create virtual machine instances using either the GUI or on command-line.
In this guide, we will seek to install KVM on Rocky Linux / AlmaLinux
The first step is to check if Virtualization is enabled on your system. Modern systems typically come with the virtualization feature enabled in the BIOS. To confirm that the virtualization feature is enabled, run the command:
$ cat /proc/cpuinfo | egrep "vmx|svm"
If you are running an Intel CPU, you should get the “vmx” keyword in the output. This is proof that Virtualization is enabled.
If the output does not contain the “vmx” keyword , then you need to go back to the BIOS settings and turn on virtualization.
Additionally, you can check if KVM modules are enabled using the command:
$ lsmod | grep kvm
Perfect! At this point, we are ready to proceed with the installation of KVM.
First, upgrade the existing software packages as follows.
$ sudo dnf update
When the upgrade is complete, install KVM along with other KVM management tools for managing the virtual machines.
$ sudo dnf install qemu-kvm qemu-img libvirt virt-manager virt-install virt-viewer libvirt-client
Once installed, start and enable the libvirtd service which is a virtualization daemon and a toolkit for managing virtualization platforms such as KVM, Xen, and ESXi.
$ sudo systemctl start libvirtd $ sudo systemctl enable libvirtd
Then confirm the running status of the daemon.
$ sudo systemctl status libvirtd
At this point, KVM and all of its associated packages required fot the installation and management of virtual machines is installed. The virt-manager utility is a graphical tool that is used for graphically creating and launching virtual machines using the libvirt service.
There are two ways you can use to launch virt-manager. You can use the application manager to search for it as follows:
On command-line, simply run the command:
$ sudo virt-manager
This will pop open the Virt manager desktop interface as shown.
Click on the top-left icon as shown to start creating a virtual machine.
The next step presents you with a list of options on how you would like to install your virtual machine. In my case, I’m installing Debian 10 from an ISO image. So I selected the first option ‘Local Install Media’. Your scenario may be different from mine. Other options include
- Network Install ( HTTP, HTTPS, FTP )
- Network Boot ( PXE )
- Importing existing boot image
Once you have selected your preferred installation method, click on ‘Forward’.
If you selected the first option, click on ‘Browse’.
This takes you to this window where you need to click on ‘Browse local’ to browse your Linux system for the location of the ISO image or DVD ROM.
Navigate to the directory that contains your ISO image.In my case, the ISO image is contained in the ‘Downloads’ directory.
Back to the Virtual machine manager. The path of the installation media is already selected. Down below, Specify the Operating system and click ‘Forward’.
Specify the memory or RAM in Megabytes and the number of CPU cores and click ‘Forward’.
Next, specify the disk space and enable storage for the virtual machine and click ‘Forward’.
Finally, review your settings and click ‘Finish’ to wind up creating the virtual machine.
The virtual machine manager will start allocating the resources you selected to your virtual machine.
Once done , the virt-viewer GUI will pop up prompting you to begin the installation of the operating system. What you see below is the Debian 10 installer prompting you to select your preferred option to commence the installation.
When you head back to the Virtual machine manager, you will find that your virtual machine is up and running. From here, you can manage your virtual machine including starting, pausing, stopping, and cloning the virtual machine.
This wraps up our topic today on the installation of KVM on Rocky Linux / AlmaLinux. As you have seen it’s quite simple and no code is required to create the virtual machine. Everything is done by the virtual machine manager.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.