CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Monday, December 30, 2019

How to Setup KVM Virtualization Host on CentOS 8

Install KVM Virtualization Host on CentOS 8

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 Setup KVM Virtualization Host on Rocky Linux 9


Table of Contents:

 

System Requirements:

The recommended system requirements for KVM 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

 Install KVM Virtualization Host on CentOS 8

Environment Specification:

We have configured a CentOS 8 (minimal) 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

 

Installing KVM Virtualization Host 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,

  1. In case of bare-metal machine, you have to enable the VT support from system BIOS.
  2. 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.

 

Installing Cockpit Web Interface in 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.

01-install-kvm-virtualization-centos-8-cockpit-loging

Login to Cockpit Web UI as root user.

02-install-kvm-virtualization-centos-8-cockpit-dashboard

Click on the Virtual Machines from the left side-pane.

03-install-kvm-virtualization-centos-8-cockpit-virtual-machines

We are now at the Virtual Machines page. We can manage our KVM virtualization environment from here.

We have successfully installed KVM virtualization host on CentOS 8. For further studies, please read Foundations of Libvirt Development by Apress.

If you find this article useful? Consider supporting us by Buy Me A Coffee


2 comments:

  1. good tutorial. Thanks for posting it. The only change that I saw was that the 'virt-host-validate' command showed a warning at the end for a 'secure guest support' which provided 'WARN (Unknown if this platform has Secure Guest support)

    ReplyDelete
  2. That's great! thank you so much, everything running fine.

    ReplyDelete

© 2023 CentLinux. All Rights Reserved.