pixel

How to install KVM on Rocky Linux 10

Share on Social Media

Discover how to install KVM on Rocky Linux 10 step-by-step and unlock powerful virtualization for free. Learn everything from setup to security—don’t fall behind, start virtualizing like a pro today! #centlinux #linux #virtualization



Introduction

Virtualization is an essential tool in modern IT infrastructure. If you’re using Rocky Linux 10 and looking to harness the power of virtualization, KVM (Kernel-based Virtual Machine) is a great choice. This comprehensive guide will walk you through the steps required to install and configure KVM on Rocky Linux 10, whether you’re a seasoned system admin or a curious beginner.

What is KVM?

KVM, short for Kernel-based Virtual Machine, is an open-source virtualization module that’s built into the Linux kernel. It allows a Linux system to function as a hypervisor, enabling the creation and management of multiple virtual machines (VMs) on a single physical host. Each VM has its own virtualized hardware, including CPU, memory, network interface, and storage.

One of the reasons KVM is so popular is because it leverages the capabilities of modern CPUs that support virtualization extensions like Intel VT or AMD-V. Unlike proprietary virtualization solutions, KVM integrates directly with the Linux kernel, ensuring better performance and efficiency.

Here are some core features of KVM:

  • Full virtualization support
  • Integration with libvirt and virt-manager
  • Support for snapshots and live migration
  • Scalable to match enterprise-grade workloads
  • Seamless support for various operating systems as guests

For organizations aiming to reduce hardware costs and improve flexibility, KVM provides a high-performance, cost-effective solution.

How to install KVM on Rocky Linux 10
How to install KVM on Rocky Linux 10

Overview of Rocky Linux 10

Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux (RHEL). After the shift in CentOS’s direction, Rocky Linux emerged as a reliable, community-driven alternative backed by the Rocky Enterprise Software Foundation.

Rocky Linux 10 builds on its predecessors’ solid reputation, offering stability, security, and compatibility. It’s particularly favored in server environments and enterprise data centers. With support for a wide range of packages and enterprise-grade tools, it’s a natural platform for running KVM-based virtual machines.

Whether you’re deploying servers, setting up testing environments, or running a full virtualization infrastructure, combining KVM with Rocky Linux 10 provides a powerful, secure, and reliable setup.


Why Use KVM on Rocky Linux 10?

Benefits of Using KVM for Virtualization

KVM has earned its place as one of the top virtualization technologies. Why? Because it’s fast, efficient, and free. Here’s a deeper dive into the core benefits:

  • Performance: Since KVM is baked right into the Linux kernel, it doesn’t require a separate layer like other hypervisors. This results in near-native performance for guest VMs.
  • Security: With support for SELinux and secure virtualization (sVirt), KVM provides robust security features to isolate VMs and reduce vulnerabilities.
  • Flexibility: KVM can run a wide variety of guest operating systems, from various Linux distros to Windows, BSD, and even legacy systems.
  • Scalability: Whether you’re running a single VM or a cluster of hundreds, KVM scales efficiently.
  • Community Support: As an open-source project, KVM is supported by a vibrant global community and integrated into many popular platforms, including OpenStack.

In short, KVM offers enterprise-level capabilities without the enterprise-level cost, making it a great fit for both home labs and large-scale deployments.

Advantages of Rocky Linux for Servers

Why pair KVM with Rocky Linux 10? Because Rocky Linux brings enterprise-grade power and stability to the table, without licensing fees. Some of its standout features include:

  • RHEL Compatibility: Rocky Linux is binary-compatible with RHEL, ensuring you can run the same applications and tools without changes.
  • Long-Term Support: Each Rocky Linux release offers up to 10 years of support, making it ideal for long-term server environments.
  • Security Updates: Rocky Linux has a fast response cycle for CVEs and security patches.
  • Container and Cloud Ready: Fully supports modern technologies like Podman, Kubernetes, and cloud deployments.
  • Enterprise Tools: It includes system management tools like Cockpit, systemd, SELinux, and more.

Together, KVM and Rocky Linux create a stable, secure, and efficient virtualization platform suited for any workload.

Recommended Training: VMWare for Absolute Beginners from Imran Afzal

5046686 5074 2
show?id=oLRJ54lcVEg&bids=1597309

System Requirements for Installing KVM

Before you install KVM, it’s critical to ensure your system meets the minimum requirements. Skipping this step can lead to installation errors or poor performance.

Hardware Requirements

Here’s what your physical server or PC should support:

  • 64-bit CPU with Virtualization Extensions: Your CPU must support Intel VT-x or AMD-V. These extensions enable full virtualization and are usually enabled in the BIOS/UEFI.
  • Minimum RAM: At least 4GB of RAM is recommended. More is better, especially if you plan to run multiple VMs.
  • Sufficient Storage: Each VM needs disk space. SSDs are highly recommended for better I/O performance.
  • Network Interface: At least one active network interface, especially if you plan to use bridged networking or NAT for your VMs.

Software Requirements

Your operating system must be up-to-date and include the required packages to install KVM and its management tools. On Rocky Linux 10, you’ll primarily use:

  • qemu-kvm
  • libvirt
  • virt-manager
  • bridge-utils (for network bridging)

Additionally, make sure you have dnf as your package manager and superuser privileges (sudo access).

Checking CPU Virtualization Support

To verify whether your CPU supports virtualization, run the following command in your terminal:

egrep -c '(vmx|svm)' /proc/cpuinfo

If the output is 1 or higher, your CPU supports hardware virtualization.

You can also use the lscpu command to get more details:

lscpu | grep Virtualization

If virtualization is listed, you’re good to go. Otherwise, you may need to enable it in your BIOS/UEFI settings.


Preparing Your System for KVM Installation

Update System Packages

Before installing anything, ensure your system is fully updated. Open your terminal and run:

sudo dnf update -y

This ensures that all installed packages are up to date, minimizing the chance of conflicts during installation.

Install Required Dependencies

Next, install some basic development and networking tools that might be needed later. While not all are mandatory, they’re good to have on hand:

sudo dnf install -y epel-release
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y wget curl net-tools

Adding the EPEL (Extra Packages for Enterprise Linux) repository can also unlock access to additional useful packages.

Now that your system is prepped and ready, you’re good to move on to the actual KVM installation process.


Install KVM on Rocky Linux 10

To install KVM along with the necessary tools, use the following command:

sudo dnf install -y qemu-kvm libvirt virt-install bridge-utils virt-manager

Let’s break down what each package does:

  • qemu-kvm: The core virtualization software
  • libvirt: A toolkit to manage virtualization platforms
  • virt-install: Helps create new virtual machines from the command line
  • bridge-utils: Enables bridged networking for VMs
  • virt-manager: A GUI-based VM management tool

Once installed, enable and start the libvirtd service:

sudo systemctl enable libvirtd --now

Verify that the service is running:

sudo systemctl status libvirtd

If it’s active and running, your KVM setup is on the right track.


Verifying the KVM Installation

Check if KVM modules are loaded:

lsmod | grep kvm

You should see something like kvm_intel or kvm_amd depending on your processor.

Next, check the virtualization support using:

virt-host-validate

This command will give you a detailed report of your system’s readiness for virtualization. If everything checks out, congratulations—you’ve successfully installed KVM on Rocky Linux 10!

Read Also: Install KVM Virtualization Host on Rocky Linux 9


Configuring KVM Networking

Understanding Virtual Networks in KVM

Once KVM is installed, one of the first things you’ll need to understand is how networking works in the virtual environment. KVM uses libvirt to manage virtual networks, and by default, it sets up a NAT-based virtual network that allows guest VMs to access the outside internet through the host.

There are three common types of networking modes in KVM:

  1. NAT (Network Address Translation)
    • Default mode
    • Easy to set up
    • Suitable for most desktop use cases
    • Guests can access the internet, but inbound connections to the guests require port forwarding.
  2. Bridged Networking
    • Shares the physical interface
    • Guests appear as regular devices on the physical LAN
    • Ideal for server use or when guests need their own IPs on the same subnet
  3. Isolated Network
    • No external access
    • VMs can only talk to each other
    • Useful for testing or secure sandboxing

The default NAT mode might be sufficient for most users, but for more complex setups like hosting web servers or using static IPs, bridged networking is preferred.

Setting Up a Bridged Network

To configure bridged networking manually:

  1. Open the network scripts directory:
    • cd /etc/sysconfig/network-scripts/
  2. Identify your network interface:
    • ip a
  3. Create a new bridge interface file (e.g., ifcfg-br0):
    • DEVICE=br0 TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes
  4. Modify your original interface (e.g., ifcfg-eth0) to use the bridge:
    • DEVICE=eth0 BOOTPROTO=none ONBOOT=yes BRIDGE=br0
  5. Restart the network service:
    • sudo systemctl restart NetworkManager

You can also create and manage virtual networks using virt-manager or the virsh CLI, making it easier for users who prefer GUI-based tools.


Creating a Virtual Machine (VM) Using CLI

Using virt-install to Deploy a VM

KVM provides a powerful command-line tool called virt-install that lets you create and configure VMs directly from the terminal. It’s perfect for automated deployments or remote installations where GUI access is not available.

Here’s an example command to create a CentOS VM:

sudo virt-install \
--name centos-vm \
--ram 2048 \
--vcpus=2 \
--os-type=linux \
--os-variant=centos7.0 \
--cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-DVD.iso \
--network bridge=br0 \
--graphics=none \
--disk path=/var/lib/libvirt/images/centos-vm.img,size=20

Let’s break that down:

  • --name: The name of the VM
  • --ram: Memory allocation
  • --vcpus: Number of virtual CPUs
  • --os-type and --os-variant: Operating system details for optimization
  • --cdrom: Path to the installation ISO
  • --network: Defines network interface (in this case, bridged)
  • --graphics=none: Disables GUI installation (uses text-based)
  • --disk: Creates and allocates disk space for the VM

Once you execute this command, it will launch a terminal-based installation process using the ISO file.

Using virsh for VM Management

After creating a VM, you can manage it with the virsh tool:

  • List all VMs:
    • virsh list --all
  • Start a VM:
    • virsh start centos-vm
  • Shutdown a VM:
    • virsh shutdown centos-vm
  • Delete a VM:
    • virsh undefine centos-vm

CLI tools like virt-install and virsh offer unmatched control and automation, especially in headless server environments.


Creating a Virtual Machine (VM) Using GUI (Virt-Manager)

Installing and Using Virt-Manager

If you prefer a graphical interface over command-line tools, Virt-Manager is your best friend. It provides a user-friendly GUI for managing VMs, networks, and storage pools.

To launch Virt-Manager, run:

virt-manager

If you’re accessing a server remotely, make sure you’ve enabled X11 forwarding with SSH:

ssh -X user@your-server

Creating a New VM in Virt-Manager

  1. Open Virt-Manager.
  2. Click on the “Create a new virtual machine” button.
  3. Choose how you want to install the OS (e.g., ISO image).
  4. Allocate CPU and RAM resources.
  5. Configure networking options (bridged, NAT, etc.).
  6. Assign storage space.
  7. Finish and begin the installation.

The beauty of Virt-Manager is its simplicity. You can configure advanced features like snapshots, shared folders, and virtual CPU tuning with just a few clicks.

It also supports remote server management. So you can manage KVM VMs on a remote Rocky Linux host from your local system using SSH or TCP.


Managing Storage for Virtual Machines

Understanding Storage Pools and Volumes

In KVM, storage pools and storage volumes are how virtual disks and devices are managed. A storage pool is a location (directory, LVM group, etc.), and a volume is a file or device within that pool.

By default, libvirt uses /var/lib/libvirt/images/ as the default storage pool.

You can create additional storage pools if you want to:

  • Separate data from the root file system
  • Use LVM or physical disks
  • Connect to remote storage (e.g., NFS or iSCSI)

To create a new storage pool:

virsh pool-define-as mypool dir - - - - "/mnt/storage"
virsh pool-start mypool
virsh pool-autostart mypool

Then create a new volume inside that pool:

virsh vol-create-as mypool centos-disk.img 10G

Now you can use this volume as a virtual disk when creating VMs.

Backing Up and Managing Disks

It’s a good idea to periodically back up your VM disks. You can copy .img files to another directory or remote server.

To convert or resize virtual disk files:

  • Convert format (e.g., from qcow2 to raw):
    • qemu-img convert -f qcow2 -O raw disk.qcow2 disk.raw
  • Resize a disk:
    • qemu-img resize disk.img +5G

Just remember to extend the partition inside the guest OS after resizing.


Enabling Remote Access to KVM

Using SSH for Remote Management

When managing KVM in production or across data centers, remote access becomes essential. The most secure and efficient way is via SSH (Secure Shell). SSH allows you to manage KVM and virsh commands without physically accessing the host machine.

Here’s how you can connect remotely:

ssh user@your-kvm-host

To enable SSH access:

  1. Ensure the OpenSSH server is installed:
    • sudo dnf install -y openssh-server
  2. Enable and start the SSH service:
    • sudo systemctl enable sshd --now
  3. Confirm it’s active:
    • sudo systemctl status sshd

Once connected, you can execute virsh, manage VMs, or even run GUI tools via X11 forwarding:

ssh -X user@your-kvm-host virt-manager

Accessing Virt-Manager Remotely

If you’re on a local Linux desktop and want to connect Virt-Manager to a remote KVM host:

  1. Open Virt-Manager locally.
  2. Go to File > Add Connection.
  3. Choose:
    • Hypervisor: QEMU/KVM
    • Connection: Remote via SSH
  4. Enter the connection URI:
    • qemu+ssh://user@remote-host/system

This setup allows you to manage remote VMs with the same ease as local ones.

For enhanced security, consider using SSH key authentication, fail2ban, and firewalls to limit access.


Securing Your KVM Environment

Using SELinux and sVirt for Isolation

Security is critical in virtualization. Since all VMs share the same physical hardware, a single breach could jeopardize the entire host. Luckily, KVM on Rocky Linux leverages robust security models, such as SELinux and sVirt.

  • SELinux (Security-Enhanced Linux): Implements Mandatory Access Control (MAC) to limit what processes can access.
  • sVirt (Secure Virtualization): Integrates with SELinux to isolate VMs from each other using unique security contexts.

To confirm SELinux is enforcing:

getenforce

If it returns Enforcing, you’re good. If not, enable it in /etc/selinux/config.

Firewall and Port Management

Use firewalld to restrict access to virtualization services:

  • Install and start firewall if not running:
    • sudo dnf install -y firewalld
    • sudo systemctl enable firewalld --now
  • Allow specific services:
    • sudo firewall-cmd --permanent --add-service=ssh
    • sudo firewall-cmd --permanent --add-service=libvirt
    • sudo firewall-cmd --reload

You can also limit access to Virt-Manager’s VNC ports and other exposed services using firewall zones or iptables.

User Permissions and Groups

Add your user to the libvirt and kvm groups to allow management without root:

sudo usermod -aG libvirt $(whoami)
sudo usermod -aG kvm $(whoami)

Log out and back in for the changes to take effect.


Troubleshooting Common Issues

Fixing “KVM Not Found” Errors

If virt-host-validate shows that KVM is not loaded, ensure your CPU supports virtualization and that it’s enabled in the BIOS.

Check module status:

lsmod | grep kvm

If missing, manually load it:

sudo modprobe kvm_intel   # For Intel CPUs
sudo modprobe kvm_amd     # For AMD CPUs

Ensure the modules are auto-loaded on boot.

Networking Doesn’t Work in VM

If VMs can’t reach the internet:

  • Check that libvirtd is running
  • Restart the default virtual network:
    • virsh net-start default
    • virsh net-autostart default
  • Ensure firewalld or iptables aren’t blocking DHCP/DNS traffic

Virt-Manager Cannot Connect to Hypervisor

If you see the error: “Unable to connect to libvirt”:

  • Ensure your user is in the libvirt group
  • Restart the libvirtd service
  • Try running virt-manager with sudo or using SSH forwarding

Best Practices for KVM on Rocky Linux

Resource Planning and Monitoring

Don’t overcommit your CPU or RAM. Always plan VM resource allocation according to the host’s capacity.

  • Use top, htop, or virt-top to monitor performance
  • Limit unnecessary background processes on the host

Regular Backups and Snapshots

Create snapshots before updating or making changes to your VMs:

virsh snapshot-create-as vm-name snapshot1 "Pre-update snapshot"

Back up VM disks and XML configurations:

virsh dumpxml vm-name > vm-name.xml
cp /var/lib/libvirt/images/vm-name.img /backup/

Update Host and Guest OS Regularly

Security patches are released frequently. Use dnf update on both host and guest systems to stay protected.


Conclusion

Installing KVM on Rocky Linux 10 is a smart move if you’re looking to build a stable and high-performance virtual environment. Whether you’re running a home lab or setting up enterprise-grade virtual machines, KVM gives you the flexibility, speed, and control you need. Rocky Linux, with its enterprise-grade reliability and RHEL-compatibility, makes the perfect host OS for this purpose.

With the right setup—from verifying virtualization support and installing packages to configuring storage, networking, and security—you’ll have a virtualization powerhouse at your fingertips. Whether you’re using CLI or GUI tools, you now have the knowledge to deploy and manage VMs with confidence.

Struggling with Linux server management? I offer professional support to ensure your servers are secure, optimized, and always available. Visit my Fiverr profile to learn more!


Frequently Asked Questions (FAQs)

1. Can I install KVM on Rocky Linux 10 without a GUI?
Yes, KVM and all its tools, including virsh and virt-install, work perfectly on headless systems without GUI.

2. How do I enable VM auto-start on reboot?
Use virsh autostart vm-name to make a VM start automatically on host boot.

3. Is Virt-Manager available for Windows?
No, Virt-Manager is a Linux-only application. For Windows, use tools like virt-viewer or remote SSH access.

4. How do I migrate VMs from one KVM host to another?
You can use virsh migrate with shared storage or use snapshot + disk copy + XML dump/import for manual migration.

5. What alternatives to Virt-Manager exist?
You can use Cockpit, GNOME Boxes, or manage everything via command-line using virsh, virt-install, and qemu-system.


Looking for something?

Leave a Reply