How to install kernel virtual machine on rocky linux 8.6

To install Kernel-based Virtual Machines on Rocky Linux 8.6

Introduction:

Kernel-based Virtual Machines (KVM) are open-source virtualization technologies built into Linux® operating systems. In particular, KVM allows a host machine to run multiple, isolated virtual environments called guests or virtual machines (VMs).

Step1 : Check the installed version of OS by using the below command

[root@localhost ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

Step 2 : Install and list the groups list by using the below command

[root@localhost ~]# yum groups list
Rocky Linux 8 - AppStream                                            5.7 MB/s | 9.6 MB     00:01    
Rocky Linux 8 - BaseOS                                               4.8 MB/s | 6.7 MB     00:01    
Rocky Linux 8 - Extras                                                10 kB/s |  11 kB     00:01    
Last metadata expiration check: 0:00:01 ago on Sat 03 Sep 2022 05:36:06 PM EDT.
Available Environment Groups:
   Server
   Minimal Install
   Workstation
   Virtualization Host
   Custom Operating System
Installed Environment Groups:
   Server with GUI
Installed Groups:
   Container Management
   Headless Management
Available Groups:
   .NET Core Development
   RPM Development Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Network Servers
   Scientific Support
   Security Tools
   Smart Card Support
   System Tools

Step 3: Install the Virtualization Host from grouplist by using the below command

[root@localhost ~]# yum groupinstall "Virtualization Host"
Last metadata expiration check: 0:00:36 ago on Sat 03 Sep 2022 05:36:06 PM EDT.
Dependencies resolved.
=====================================================================================================
 Package                            Arch   Version                                   Repo       Size
=====================================================================================================
Upgrading:
 NetworkManager                     x86_64 1:1.36.0-7.el8_6                          baseos    2.3 M
 NetworkManager-adsl                x86_64 1:1.36.0-7.el8_6                          baseos    148 k
 NetworkManager-bluetooth           x86_64 1:1.36.0-7.el8_6                          baseos    174 k
 NetworkManager-libnm               x86_64 1:1.36.0-7.el8_6                          baseos    1.8 M
 NetworkManager-team                x86_64 1:1.36.0-7.el8_6                          baseos    152 k
 NetworkManager-tui                 x86_64 1:1.36.0-7.el8_6                          baseos    345 k
 NetworkManager-wifi                x86_64 1:1.36.0-7.el8_6                          baseos    193 k
 NetworkManager-wwan                x86_64 1:1.36.0-7.el8_6                          baseos    180 k
 bash                               x86_64 4.4.20-4.el8_6                            baseos    1.5 M
 bpftool                            x86_64 4.18.0-372.19.1.el8_6                     baseos    8.8 M
 curl                               x86_64 7.61.1-22.el8_6.4                         baseos    351 k
 dbus                               x86_64 1:1.12.8-18.el8_6.1                       baseos     40 k
 dbus-common                        noarch 1:1.12.8-18.el8_6.1                       baseos     45 k
 dbus-daemon                        x86_64 1:1.12.8-18.el8_6.1                       baseos    239 k
 dbus-libs                          x86_64 1:1.12.8-18.el8_6.1                       baseos    183 k
 dbus-tools                         x86_64 1:1.12.8-18.el8_6.1                       baseos     85 k
 dbus-x11                           x86_64 1:1.12.8-18.el8_6.1                       appstream  59 k
 device-mapper                      x86_64 8:1.02.181-3.el8_6.2                      baseos    376 k
 device-mapper-event                x86_64 8:1.02.181-3.el8_6.2                      baseos    270 k
 device-mapper-event-libs           x86_64 8:1.02.181-3.el8_6.2                      baseos    269 k
 device-mapper-libs                 x86_64 8:1.02.181-3.el8_6.2                      baseos    409 k

Step 4 : Install the virt-manager by using the below command

[root@localhost ~]# yum install virt-manager
Last metadata expiration check: 0:06:20 ago on Sat 03 Sep 2022 05:36:06 PM EDT.
Dependencies resolved.
=====================================================================================================
 Package                  Arch        Version                                   Repository      Size
=====================================================================================================
Installing:
 virt-manager             noarch      3.2.0-4.el8                               appstream      620 k
Installing dependencies:
 python3-argcomplete      noarch      1.9.3-6.el8                               appstream       59 k
 python3-libvirt          x86_64      8.0.0-1.module+el8.6.0+847+b490afdd       appstream      331 k
 virt-manager-common      noarch      3.2.0-4.el8                               appstream      1.0 M

Transaction Summary
=====================================================================================================
Install  4 Packages

Total download size: 2.0 M
Installed size: 9.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): python3-argcomplete-1.9.3-6.el8.noarch.rpm                    302 kB/s |  59 kB     00:00    
(2/4): python3-libvirt-8.0.0-1.module+el8.6.0+847+b490afdd.x86_64.rp 1.2 MB/s | 331 kB     00:00    
(3/4): virt-manager-3.2.0-4.el8.noarch.rpm                           2.2 MB/s | 620 kB     00:00    
(4/4): virt-manager-common-3.2.0-4.el8.noarch.rpm                    5.9 MB/s | 1.0 MB     00:00    
-----------------------------------------------------------------------------------------------------
Total                                                                1.7 MB/s | 2.0 MB     00:01     

Complete!

Step 5: Enable the service by using the below command

[root@localhost ~]# systemctl enable libvirtd

Step 6: Start the service by using the below command

[root@localhost ~]# systemctl start libvirtd

Step 7: Check the status by using the below command

[root@localhost ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2022-09-03 17:57:37 EDT; 9s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
 Main PID: 58693 (libvirtd)
    Tasks: 21 (limit: 32768)
   Memory: 50.6M

Step 8: Run the below command to get KVM console

[root@localhost ~]# virt-manager

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install kernel virtual machine on rocky Linux 8.6. Your feedback is much welcome.

FAQ
Q
What are the different states of a VM in Xen hypervisor?
A
A VM can have different states like
• r – Running
• b – Blocked
• c – crashed
• s – Shutdown
• p – Paused
Q
How to get hardware information on the KVM guest machine?
A
Use the command ‘virsh dominfo
Q
Which command is used in KVM for VMs live migration?
A
‘virsh migrate –live machine_name qemu+ssh://destination_server/system’
Q
How to verify Virtualization Technology (VT) is enabled in your server’s BIOS or not?
A
grep -E ‘svm|vmx’ /proc/cpuinfo
• vmx is for Intel processors
• svm is for AMD processors
Q
How To Identify The Kvm Version?
A
To locate the KVM model use the command ‘virsh model’