Search

How to Install KVM on Rocky Linux 9

How to Install KVM on Rocky Linux 9

Kernel-based Virtual Machine (KVM) is a virtualization module in the Linux kernel that allows the kernel to function as a hypervisor. KVM is useful for running multiple virtual machines on a single server. This guide will show you how to install KVM on Rocky Linux 9.

Step-by-Step Guide

1. Update Your System

First, ensure your system is up-to-date by running the following commands:

sudo dnf update -y

2. Install KVM and Related Packages

Next, install KVM and other necessary packages:

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

3. Enable and Start the libvirtd Service

Enable and start the libvirtd service to manage virtual machines:

sudo systemctl enable --now libvirtd

4. Configure Network Bridge (Optional)

If you need your virtual machines to be accessible from the outside network, you should set up a network bridge. You can create a bridge by editing your network configuration files or using NetworkManager. Here, we'll use NetworkManager's command line tool.

First, install nmstate:

sudo dnf install -y nmstate

Next, create a network bridge:

sudo nmcli connection add type bridge autoconnect yes con-name br0 ifname br0
sudo nmcli connection add type ethernet autoconnect yes con-name bridge-slave-eth0 ifname eth0 master br0

Restart the network manager to apply changes:

sudo systemctl restart NetworkManager

5. Verify Installation

To verify that KVM is installed and running correctly, use the following command:

sudo virsh list --all

You should see an empty list indicating there are no virtual machines installed yet.

Conclusion

Congratulations! You have successfully installed KVM on Rocky Linux 9. You can now create and manage virtual machines using tools like virt-manager or the virsh command-line utility. If you have any questions or run into issues, consult the official documentation for additional help and resources.

Sys Admin

Sys Admin

I am a Red Hat Certified Engineer (RHCE) and working as an IT Professional since 2012...