In this article, you will learn how to setup KVM hypervisor on CentOS 8 or other Redhat based Linux distros. #centlinux #linux #virtualization
Table of Contents
What is KVM Hypervisor?
KVM (Kernel based Virtual Machine) is the virtualization solution for Linux. It consist of a loadable Kernel module that allows the Linux Kernel to work as a Hypervisor. KVM provides hardware-assisted virtualization for a wide variety of guest operating systems.
In this article, we are installing KVM virtualization host on CentOS 8. We are also installing Cockpit to manage our KVM Virtualization environment through a graphical interface.
Read Also: How to install KVM Virtualization on Rocky Linux 9
System Requirements:
The recommended system requirements for KVM Hypervisor are:
- CPU – 1 CPU core or thread per virtual machine
- Memory – 2 GB RAM for the virtualization host + 2 GB RAM for each intended guest
- Storage – 6 GB space for the virtualization host + 6 GB space for each intended guest
Environment Specification:
We have configured a CentOS 8 minimal installed virtual machine with following specification.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – CentOS 8.0
- Hostname – kvm-virtualization-01.recipes.com
- IP Address – 192.168.116.206 /24
Setup KVM Hypervisor on CentOS 8:
Connect with kvm-virtualization-01.recipes.com using ssh as root user.
Verify support for Virtual Technology by the CPU.
# lscpu | grep Virtualization
Virtualization: VT-x
Virtualization type: full
The output of the above command shows that, our server kvm-virtualization-01.recipes.com supports Virtualization.
However, if the above command returns no result on your server then,
- In case of bare-metal machine, you have to enable the VT support from system BIOS.
- In case of virtual machine, you have to enable the VT support from VM’s CPU Settings.
In CentOS 8 / RHEL 8, virtualization components including KVM and QEMU hypervisors are bundled in virt module. Therefore, it is really simple now to configure a KVM virtualization host in CentOS 8.
We are installing virt module using dnf command.
# dnf install -y @virt
We are also installing virt-install package, because it provides some very useful command line tools.
# dnf install -y virt-install
Validate all the components on your KVM host can support virtualization.
# virt-host-validate
...
QEMU: Checking if IOMMU is enabled by kernel : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)
It looks like IOMMU (input-output memory management unit) support is not yet enabled in the CentOS 8 Kernel.
The solution is already suggested by the above command. Therefore, we are adding the same in the Kernel command line options.
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) intel_iommu=on"
Restart your machine to make the above change effective.
# systemctl reboot
After reboot, again run the virt-host-validate command.
# virt-host-validate
...
QEMU: Checking if IOMMU is enabled by kernel : PASS
Everything is fine now.
KVM and QEMU hypervisors has been installed on CentOS 8.
Install Cockpit on CentOS 8:
Although, KVM commandline-tools are quite sufficient for managing a Virtualization environment. But, we can also use the CentOS 8 native Web UI i.e. Cockpit to manage virtual machines via a graphical interface.
We are installing Cockpit using dnf command.
# dnf install -y cockpit
To add support of managing virtual machines via Cockpit, we have to install cockpit-machines package.
# dnf install -y cockpit-machines
Enable and start Cockpit Unit.
# systemctl enable --now cockpit.socket
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket â /usr/lib/systemd/system/cockpit.socket.
Cockpit service is by-default allowed in CentOS 8 firewall.
Open URL https://kvm-virtualization-01.recipes.com:9090/ in a web browser.
The Cockpit uses a self-signed SSL certificate, therefore, you may see a Security warning.
Ignore the Security warning and continue to the website.
Login to Cockpit Web UI as root user.
Click on the Virtual Machines from the left side-pane.
We are now at the Virtual Machines page. We can manage our KVM virtualization environment from here.
Conclusion:
In this article, you have learned how to setup KVM hypervisor on CentOS 8. For further studies, please read Foundations of Libvirt Development (PAID LINK) by Apress.