Learn how to install KVM Virtualization Host on Rocky Linux 9 with our step-by-step guide. Set up your virtual environment efficiently and get started with KVM virtualization today. #centlinux #linux #virtualization
Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux®. Specifically, KVM lets you turn Linux into a hypervisor that allows a host machine to run multiple, isolated virtual environments called guests or virtual machines (VMs).
KVM is part of Linux. If you’ve got Linux 2.6.20 or newer, you’ve got Linux hypervisor. KVM was first announced in 2006 and merged into the mainline Linux kernel version a year later. Because KVM is part of existing Linux code, it immediately benefits from every new Linux feature, fix, and advancement without additional engineering.
KVM converts Linux into a type-1 (bare-metal) hypervisor. All hypervisors need some operating system-level components—such as a memory manager, process scheduler, input/output (I/O) stack, device drivers, security manager, a network stack, and more—to run VMs. KVM has all these components because it’s part of the Linux kernel. Every VM is implemented as a regular Linux process, scheduled by the standard Linux scheduler, with dedicated virtual hardware like a network card, graphics adapter, CPU(s), memory, and disks.
Recommended Online Training: Linux KVM for System Engineers
Recommeded Book: Mastering KVM Virtualization (PAID LINK)
Comparing KVM (Kernel-based Virtual Machine) virtualization with VMware reveals several differences and considerations, each having its own strengths and suited use cases. Here’s an overview:
Choosing between KVM and VMware ultimately depends on your specific needs, budget, and the existing IT infrastructure. Both have their unique advantages and can serve as powerful tools for virtualization.
We are using a Rocky Linux 9 minimal installed virtual machine with following specifications.
Connect with kvm-01.centlinux.com as root user by using a ssh client.
By executing lscpu command, you can easily verify that, Is your CPU is supporting virtualization or not?
# lscpu | grep Virtualization Virtualization: VT-x Virtualization type: full
If you get the above output, then it means that your CPU supports virtualization and you can setup a KVM virtualization host thereon.
However, if the above command returns no result on your server then:
By using hostnamectl command, set the hostname of your Linux KVM host.
# hostnamectl set-hostname kvm-01.centlinux.com
Execute following command to enable Name resolution of your Local Linux server.
# echo "192.168.116.131 kvm-01 kvm-01.centlinux.com" >> /etc/hosts
Refresh cache of your enabled yum repositories with the help of dnf command.
# dnf makecache Rocky Linux 9 - BaseOS 1.2 kB/s | 3.6 kB 00:03 Rocky Linux 9 - AppStream 1.9 kB/s | 3.6 kB 00:01 Rocky Linux 9 - Extras 1.3 kB/s | 3.4 kB 00:02 Metadata cache created.
Now, execute following command to update your Linux operating system.
# dnf update -y
If the above command updates your Linux Kernel, then you should reboot your operating system with the new Linux Kernel.
# reboot
Check the versions of your Linux operating system and Kernel as follows.
# cat /etc/rocky-release Rocky Linux release 9.0 (Blue Onyx) # uname -r 5.14.0-70.17.1.el9_0.x86_64
Execute following dnf command to install KVM virtualization software on your Rocky Linux server.
# dnf install -y qemu-kvm qemu-img libvirt virt-install
To enable IOMMU (input-output memory management unit) support, you are required to edit GRUB configurations.
Edit grub configuration file by using vim text editor.
# vi /etc/default/grub
Edit GRUB_CMDLINE_LINUX directive and add “intel_iommu=on iommu=pt” at the end of the line.
GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rl-swap rd.lvm.lv=rl/root rd.lvm.lv=rl/swap intel_iommu=on iommu=pt"
You need to regenerate your grub.cfg file by executing grub2-mkconfig command.
# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Adding boot menu entry for UEFI Firmware Settings ... done
Reboot your system with the modified directives.
# reboot
Execute the following command to check your platform support as required to install KVM virtualization host.
# 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 : PASS QEMU: Checking for secure guest support : WARN (Unknown if this platform has Secure Guest support)
Secure Guest Support warning can be ignored since that check is not for Intel CPUs and we are using an Intel Microprocessor.
KVM and QEMU hypervisors has been installed on your Rocky Linux 9 server.
Read Also: How to Setup KVM Hypervisor on CentOS 8
Your Linux virtualization platform has been configured successfully. Now, it is time to create your first KVM virtual machine.
Here, we are showing you the process of creating virtual machine from Linux Commandline. However, it is not the only way to do the job. You can also use GUI based virt-manager tool for this purpose.
But, we usually do not has GUI enabled on Linux servers, so we prefer to used the Linux CLI for Server management tasks.
Execute virt-install command to create your first KVM virtual machine. The command is self explanatory and requires only a few parameters such as machine name, memory, number of CPUs, Disk Size, etc.
# virt-install --name kvm-guest-01 > --memory 512 > --vcpus 1 > --disk size=20 > --os-variant rhel9.0 > --location /var/lib/libvirt/iso/Rocky-9.0-x86_64-minimal.iso > --graphics none > --extra-args='console=ttyS0' Starting installer, one moment... anaconda 34.25.0.29-1.el9_0.rocky.0.3 for Rocky Linux 9.0 started. * installation log files are stored in /tmp during the installation * shell is available on TTY2 * if the graphical installation interface fails to start, try again with the inst.text bootoption to start text installation * when reporting a bug add logs from /tmp as separate text/plain attachments ================================================================================ ================================================================================ Text mode provides a limited set of installation options. It does not offer custom partitioning for full control over the disk layout. Would you like to use VNC mode instead? 1) Start VNC 2) Use text mode Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to refresh]: 2
Enter ‘2’ and press <ENTER>.
================================================================================ Installation 1) [x] Language settings 2) [x] Time settings (English (United States)) (America/New_York timezone) 3) [!] Installation source 4) [!] Software selection (Processing...) (Processing...) 5) [!] Installation Destination 6) [x] Kdump (Processing...) (Kdump is enabled) 7) [x] Network configuration 8) [!] Root password (Wired (enp1s0) connected) (Root account is disabled) 9) [!] User creation (No user will be created) Please make a selection from the above ['b' to begin installation, 'q' to quit, 'r' to refresh]: 8
You are now at the Installation Summary screen. You can customize your Rocky Linux 9 installation from here.
Press ‘8’ to set root password.
================================================================================ Root password Please select new root password. You will have to type it twice. Password: Password (confirm): ================================================================================ ================================================================================ Installation 1) [x] Language settings 2) [x] Time settings (English (United States)) (America/New_York timezone) 3) [x] Installation source 4) [x] Software selection (Local media) (Minimal Install) 5) [!] Installation Destination 6) [x] Kdump (Automatic partitioning (Kdump is enabled) selected) 7) [x] Network configuration 8) [x] Root password (Wired (enp1s0) connected) (Root password is set) 9) [ ] User creation (No user will be created) Please make a selection from the above ['b' to begin installation, 'q' to quit, 'r' to refresh]: 5
Now press ‘5’ to Configure Hard Disk and Partitions of your KVM virtual machine.
Probing storage... ================================================================================ ================================================================================ Installation Destination 1) [x] DISK: 20 GiB (vda) 1 disk selected; 20 GiB capacity; 20 GiB free Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to refresh]: c ================================================================================ ================================================================================ Partitioning Options 1) [ ] Replace Existing Linux system(s) 2) [x] Use All Space 3) [ ] Use Free Space 4) [ ] Manually assign mount points Installation requires partitioning of your hard drive. Select what space to use for the install target or manually assign mount points. Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to refresh]: c ================================================================================ ================================================================================ Partition Scheme Options 1) [ ] Standard Partition 2) [x] LVM 3) [ ] LVM Thin Provisioning Select a partition scheme configuration. Please make a selection from the above ['c' to continue, 'q' to quit, 'r' to refresh]: c Saving storage configuration... Checking storage configuration... ================================================================================ ================================================================================ Installation 1) [x] Language settings 2) [x] Time settings (English (United States)) (America/New_York timezone) 3) [x] Installation source 4) [x] Software selection (Local media) (Minimal Install) 5) [x] Installation Destination 6) [x] Kdump (Automatic partitioning (Kdump is enabled) selected) 7) [x] Network configuration 8) [x] Root password (Wired (enp1s0) connected) (Root password is set) 9) [ ] User creation (No user will be created) Please make a selection from the above ['b' to begin installation, 'q' to quit, 'r' to refresh]: b
Press ‘b’ to begin Rocky Linux 9 installation.
================================================================================ ================================================================================ Progress . Setting up the installation environment Configuring storage Creating disklabel on /dev/vda Creating xfs on /dev/vda1 Creating lvmpv on /dev/vda2 ... ... ... ... Configuring addons . Generating initramfs ... Storing configuration files and kickstarts . Running post-installation scripts . Installation complete Use of this product is subject to the license agreement found at: /usr/share/rocky-release/EULA Installation complete. Press ENTER to quit:
After reboot, the KVM guest machine will provide you the Linux CLI login prompt.
Login as root user and execute some test commands.
Rocky Linux 9.0 (Blue Onyx) Kernel 5.14.0-70.13.1.el9_0.x86_64 on an x86_64 localhost login: root Password: Last failed login: Tue Aug 9 08:06:43 EDT 2022 on ttyS0 There was 1 failed login attempt since the last successful login. # ip a | grep "inet " inet 127.0.0.1/8 scope host lo inet 192.168.122.25/24 brd 192.168.122.255 scope global dynamic noprefixroute enp1s0 # poweroff dracut Warning: Unmounted /oldroot. [ 213.159797] dracut: Disassembling device-mapper devices Powering off. [ 213.194994] kvm: exiting hardware virtualization [ 213.229673] ACPI: PM: Preparing to enter system sleep state S5 [ 213.235358] reboot: Power down
Besides virt-manager and Linux CLI, you can also use Cockpit Web UI to manage your KVM virtualization host.
Install cockpit and required virtualization plugin as follows.
# dnf install -y cockpit cockpit-machines
Enable and start Cockpit service.
# 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 Rocky Linux 9 firewall.
Open URL https://kvm-01.centlinux.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.
You are now at the Virtual Machines page. You can manage our KVM virtualization host from here.
Thank you for following our guide on how to install KVM Virtualization Host on Rocky Linux 9. We hope this tutorial has been helpful in setting up your virtual environment. If you need further assistance or customized support, feel free to visit my Fiverr page here.
Puppy Linux is a fast, lightweight OS designed for speed and simplicity, perfect for old…
Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…
Discover how to change Apache port in Linux easily. Follow our simple guide to modify…
Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…
Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…
Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…
This website uses cookies.