AlmaLinux and Rocky Linux are popular RHEL-compatible distributions for servers. This guide shows how to install KVM on AlmaLinux or Rocky Linux 9 (the steps are almost the same on 8), set up bridged networking with NetworkManager and manage VMs from the Cockpit web console.
Before you start
- A dedicated server or physical machine with AlmaLinux or Rocky Linux and root access.
- VT-x or AMD-V enabled; see enable hardware virtualization.
- Console or IPMI access for network changes.
Check CPU support
grep -E -c '(vmx|svm)' /proc/cpuinfoThe result must be greater than 0.
Install KVM packages
dnf update -ydnf install -y qemu-kvm libvirt virt-install virt-viewer libguestfs-toolsOn version 9 libvirt uses modular daemons. Enable them:
for drv in qemu network nodedev nwfilter secret storage interface; do systemctl enable --now virt${drv}d.socket; doneOn version 8, use systemctl enable --now libvirtd instead.
Validate the host
virt-host-validate qemuAll QEMU checks should show PASS. A warning about IOMMU only matters if you need PCI passthrough.
Create a bridge with nmcli
Replace eno1 and the addresses with yours, and run from the console:
nmcli con add type bridge ifname br0 con-name br0 ipv4.method manual ipv4.addresses 203.0.113.10/24 ipv4.gateway 203.0.113.1 ipv4.dns "1.1.1.1 8.8.8.8"nmcli con add type bridge-slave ifname eno1 master br0nmcli con down "eno1" ; nmcli con up br0The old connection name may differ; list them with nmcli con show. Check with ip a show br0.
Manage VMs with Cockpit
dnf install -y cockpit cockpit-machinessystemctl enable --now cockpit.socketOpen https://server-ip:9090, log in with a system user that has sudo, and go to Virtual machines → Create VM. Restrict port 9090 to your IP with firewalld:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.5" service name="cockpit" accept' && firewall-cmd --reloadYou can also create VMs from the CLI; see virt-install.
Troubleshooting
- SELinux denies access to images: keep disks in
/var/lib/libvirt/imagesor relabel a custom path withsemanage fcontextandrestorecon. - virsh cannot connect: the modular daemon sockets are not enabled.
- No network after creating bridge: fix from console with
nmcli; ensure the slave connection is up.
Frequently asked questions
Is virt-manager still available?
It was deprecated in RHEL 9 in favour of Cockpit, but you can run virt-manager on a desktop and connect over SSH.
AlmaLinux or Rocky for KVM?
Both are binary-compatible with RHEL; KVM works the same on either.
Does this work on a VPS?
Only if nested virtualization is enabled; see nested virtualization.
