Table of Contents
In this article I will share step by step tutorial to install KVM on RHEL 8 or CentOS 8 Linux. But before we start with the installation steps, let us understand little bit about KVM Virtualization and about KVM Hypervisor.
What is Virtualization?
- CentOS/RHEL 8 provides the virtualization functionality (so does many other distros..)
- This enables a machine running CentOS/RHEL 8 to host multiple virtual machines (VMs), also referred to as guests.
- VMs use the host’s physical hardware and computing resources to run a separate, virtualized operating system (guest OS) as a user-space process on the host’s operating system.
What is Hypervisor?
- The basis of creating virtual machines (VMs) in RHEL and CentOS 8 is the hypervisor.
- It is a software layer that controls hardware and enables running multiple operating systems on a host machine.
- The hypervisor in RHEL/CentOS includes the Kernel-based Virtual Machine (KVM) module and virtualization kernel drivers, such as
- These components ensure that the Linux kernel on the host machine provides resources for virtualization to user-space software.
There are two types of hypervisor
- Type 1 Hypervisor
- Type 2 Hypervisor
What is KVM?
- KVM is short abbreviation for Kernel Based Virtual Machine.
- It gives the Linux kernel hypervisor capabilities.
- Because KVM is implemented directly in the Linux kernel, it has great support across a wide variety of Linux distros.
- At the user-space level, the QEMU emulator simulates a complete virtualized hardware platform that the guest operating system can run in, and manages how resources are allocated on the host and presented to the guest.
- In addition, the
libvirtsoftware suite serves as a management and communication layer, making QEMU easier to interact with, enforcing security rules, and providing a number of additional tools for configuring and running VMs.
Pre-requisites to Install and Configure KVM
Install RHEL 8 or CentOS 8
Red Hat Enterprise Linux 8 or CentOS 8 must be installed on your physical host machine.
Verify support for KVM Virtualization
- The physical host machine must support KVM Virtualization.
- On an Intel platform, the flag that shows support for full hardware-based virtualization is the
- To check whether an Intel processor has support for
vmx, you could grep for the desired flag in
/proc/cpuinfo, like so
# lscpu | grep -i "Model Name" Model name: Intel(R) Xeon(R) CPU E5-2640 v3 @ 2.60GHz # grep -i -o vmx /proc/cpuinfo | uniq vmx
The presence of
vmx in this sample output shows that necessary CPU extensions are in place on the Intel processor.
- On an AMD platform, the flag that shows support for full hardware-based virtualization is the Secure Virtual Machine (
- To check whether an AMD processor has support for
svm, you could grep for the desired flag in
/proc/cpuinfo, like so:
# lscpu | grep -i "Model Name" Model name: AMD EPYC 7402P 24-Core Processor # grep -i -o svm /proc/cpuinfo | uniq svm
The presence of
svm in this sample output shows that necessary CPU extensions are in place on the AMD processor.
Register RHEL 8 to RHN (Optional)
- I have mentioned this chapter as Optional but it is recommended if you are using RHEL 8.
- On CentOS 8 you only need an active internet connection to connect to CentOS repositories
- On RHEL 8 you should register your host to RHN to get latest updates. We will need this in our next chapters to set up KVM HA Cluster
- To only install KVM you can just create an offline repository using Red Hat 8 ISO DVD to install KVM Virtualization related packages
My RHEL 8 node is registered with Red Hat Network
[root@rhel-8 ~]# subscription-manager list +-------------------------------------------+ Installed Product Status +-------------------------------------------+ Product Name: Red Hat Enterprise Linux for x86_64 Product ID: 479 Version: 8.2 Arch: x86_64 Status: Subscribed Status Details: Starts: 12/10/2019 Ends: 12/10/2020
Install KVM on RHEL/CentOS 8
To use virtualization in RHEL/CentOS 8, you must enable the virtualization module, install virtualization packages, and ensure your system is configured to host virtual machines (VMs).
I hope you are already aware of YUM alternative DNF tool
[root@rhel-8 ~]# dnf module install virt
Once installed you can check if
kvm module is loaded on your Physical Host
[root@rhel-8 ~]# lsmod | grep kvm kvm_intel 290816 16 kvm 761856 1 kvm_intel irqbypass 16384 2 kvm
On AMD host, you would get output like below
# lsmod | grep kvm kvm_amd 2177260 0 kvm 621480 1 kvm_amd irqbypass 13503 1 kvm
virt-viewer packages. We will need them to create KVM Virtual Machines
[root@rhel-8 ~]# dnf install virt-install virt-viewer
Enable and start libvirtd service
Start and enable the
[root@rhel-8 ~]# systemctl enable libvirtd --now
Verify KVM Virtualization Status
After you install KVM rpms and start
libvirtd service, verify if your RHEL/CentOS 8 physical host is enabled to support KVM Virtualization
[root@rhel-8 ~]# virt-host-validate QEMU: Checking for hardware virtualization : PASS QEMU: Checking if device /dev/kvm exists : PASS QEMU: Checking if device /dev/kvm is accessible : PASS QEMU: Checking if device /dev/vhost-net exists : PASS QEMU: Checking if device /dev/net/tun exists : PASS QEMU: Checking for cgroup 'cpu' controller support : PASS QEMU: Checking for cgroup 'cpuacct' controller support : PASS QEMU: Checking for cgroup 'cpuset' controller support : PASS QEMU: Checking for cgroup 'memory' controller support : PASS QEMU: Checking for cgroup 'devices' controller support : PASS QEMU: Checking for cgroup 'blkio' controller support : PASS QEMU: Checking for device assignment IOMMU support : PASS QEMU: Checking if IOMMU is enabled by kernel : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)
Here our first part of KVM Tutorial is complete. Now our RHEL/CentOS 8 physical host is ready to create KVM Virtual Machines
Lastly I hope the steps from the article to install LVM on RHEL/CentOS 8 Linux was helpful. So, let me know your suggestions and feedback using the comment section.