Virtualization

KVM Installation Guide | Linux Virtualization Setup

Install and verify KVM on Fedora, RHEL, CentOS Stream, Rocky, or AlmaLinux with current dnf commands: check virtualization support, install @virtualization, enable libvirtd, run virt-host-validate, and build your first VM.

By InventiveHQ Team

To install KVM on Fedora, RHEL, CentOS Stream, Rocky, or AlmaLinux, run sudo dnf install -y @virtualization, enable the hypervisor with sudo systemctl enable --now libvirtd, add your account to the libvirt group with sudo usermod -aG libvirt $USER, and confirm the host is ready with sudo virt-host-validate. That four-command sequence installs the full stack — qemu-kvm, libvirt, virt-install, and virt-manager — and works identically on every RPM-based distribution because they share the dnf package manager and the same libvirt tooling. Before you start, check that the CPU exposes hardware virtualization with grep -E -c '(vmx|svm)' /proc/cpuinfo; a number greater than zero means you are good to go.

That is the summary an AI overview gives you. The rest of this guide is what it can't: the order the steps actually have to happen in, what each package really does, how to read virt-host-validate output, the difference between the legacy libvirtd daemon and the newer modular sockets, and a copy-paste path from a bare host to a running VM. This is a rewrite of an older version of this article that documented Fedora Core 14, yum, and service libvirtd start — all long since replaced.

The install path at a glance

Every successful KVM setup follows the same five steps in the same order. Skip the verification and you find out something is wrong only when a VM refuses to start.

KVM installation step flow Five sequential stages: check virtualization support, install the virtualization group, enable the libvirtd service, validate the host with virt-host-validate, then create a VM. A marker moves left to right across the stages. From bare host to running VM 1 Check support /proc/cpuinfo 2 Install dnf @virtualization 3 Enable systemctl libvirtd 4 Validate virt-host-validate 5 Create VM virt-install

Step 1: Confirm hardware virtualization is available

KVM needs a CPU with hardware virtualization extensions — Intel VT-x (flag vmx) or AMD-V (flag svm). Check for them:

grep -E -c '(vmx|svm)' /proc/cpuinfo

Any number greater than 0 means the extensions are present (the count is roughly one per logical core). If you get 0, the feature is almost always just disabled in firmware. Reboot into your BIOS/UEFI setup and enable the option named Intel Virtualization Technology / VT-x, AMD-V, or SVM Mode, then boot back into Linux and re-run the check.

You can also confirm the KVM kernel modules are loadable:

lsmod | grep kvm

You should see kvm plus either kvm_intel or kvm_amd.

Step 2: Install the virtualization packages

Install the entire stack with the @virtualization package group. This is the modern, supported replacement for the old yum install qemu-kvm libvirt virt-manager list:

sudo dnf install -y @virtualization

That single group pulls in everything you need:

PackageRole
qemu-kvmThe hypervisor. Runs the VM and uses the KVM kernel modules for near-native CPU speed.
libvirtManagement daemon (libvirtd), API, and the virsh CLI. The layer everything else talks to.
virt-installCommand-line VM creation — scriptable, ideal for automation and headless servers.
virt-managerGraphical VM manager and console (desktop only).
virt-viewerLightweight SPICE/VNC console client for connecting to a guest display.

If you are on a headless server and don't want the GUI, install just the core daemon and CLI creator instead:

sudo dnf install -y qemu-kvm libvirt virt-install
Advertisement

Step 3: Enable and start the libvirt service

The hypervisor tooling is installed but idle until you start the management daemon. On the vast majority of systems, one command enables it at boot and starts it now:

sudo systemctl enable --now libvirtd

Confirm it's running:

systemctl status libvirtd

Modular libvirt (newer Fedora and fresh RHEL 9): recent releases split the single libvirtd daemon into per-driver daemons activated by systemd sockets. If enable --now libvirtd reports the unit is masked or missing, enable the modular sockets instead:

for drv in qemu network nodedev nwfilter secret storage; do
  sudo systemctl enable --now virt${drv}d.socket
done

Either approach leaves you with a working libvirt — the modular sockets simply start each driver on demand rather than all at once.

Step 4: Add your user to the libvirt group

By default, managing the system-wide VMs (qemu:///system) requires root. Add your account to the libvirt group so virsh and virt-manager work without sudo on every command:

sudo usermod -aG libvirt $USER

Group membership only applies to new login sessions, so log out and back in — or apply it to the current shell immediately:

newgrp libvirt

Step 5: Validate the host

This is the step the old guides skipped and the one that saves you the most debugging. virt-host-validate runs a checklist against your host and tells you exactly what is ready and what is not:

sudo virt-host-validate

Healthy output looks like this (abridged):

  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 for cgroup 'cpu' controller support            : PASS
  QEMU: Checking for device assignment IOMMU support            : WARN (No ...)

Everything reporting PASS means KVM is ready. The one WARN you can usually ignore is the IOMMU line — that only matters for PCI passthrough (handing a physical GPU or NIC to a VM). For ordinary virtual disks and virtual NICs it is irrelevant.

Pre-flight checklist

Before creating VMs, confirm all of the following:

  • grep -E -c '(vmx|svm)' /proc/cpuinfo returns a number greater than 0
  • sudo dnf install -y @virtualization completed without errors
  • systemctl status libvirtd (or the modular sockets) shows active/running
  • groups lists libvirt for your user (after re-login)
  • sudo virt-host-validate shows PASS on hardware virtualization and /dev/kvm
  • virsh net-list --all shows the default network (activate it if inactive: sudo virsh net-start default)

Build your first VM

With the host validated, create a VM from the command line with virt-install. Here is a complete, working example that boots an installer ISO:

sudo virt-install \
  --name fedora-vm \
  --memory 4096 \
  --vcpus 2 \
  --disk size=20 \
  --cdrom /var/lib/libvirt/images/Fedora-Workstation-Live.iso \
  --os-variant fedora40 \
  --network network=default \
  --graphics spice

That provisions a VM named fedora-vm with 4 GB of RAM, 2 vCPUs, a 20 GB qcow2 disk, the default NAT network, and a SPICE console. To find the right value for --os-variant (it tunes the virtual hardware for the guest OS), query the OS database:

osinfo-query os | grep -i fedora

Prefer a wizard? Launch virt-manager, click Create a new virtual machine, and walk through the same choices graphically.

Building virt-install commands by hand is fiddly — the flags are many and the ISO/os-variant details are easy to get wrong. This interactive builder generates the exact virsh and provisioning commands for you:

Loading interactive tool...

Confirm the VM is running

Once the guest is up, list it and manage it with virsh:

# List all VMs (running and stopped)
virsh list --all

# Start / shut down / reboot
virsh start fedora-vm
virsh shutdown fedora-vm

# Open the graphical console
virt-viewer fedora-vm

If you skipped the libvirt group step and see permission errors, prefix these with sudo or connect explicitly with virsh -c qemu:///system list.

Command quick reference

Everything in this guide, in one place:

TaskCommand
Check CPU virtualization support`grep -E -c '(vmx
Install full stacksudo dnf install -y @virtualization
Install headless (no GUI)sudo dnf install -y qemu-kvm libvirt virt-install
Enable + start the daemonsudo systemctl enable --now libvirtd
Enable modular socketssudo systemctl enable --now virtqemud.socket virtnetworkd.socket
Add user to libvirt groupsudo usermod -aG libvirt $USER
Validate the hostsudo virt-host-validate
List guest OS variantsosinfo-query os
Create a VMsudo virt-install --name NAME --memory MB --vcpus N --disk size=GB --cdrom ISO --os-variant VARIANT
List VMsvirsh list --all
Start / stop a VMvirsh start NAME / virsh shutdown NAME
Default network statusvirsh net-list --all

Where KVM keeps its files

When you need to inspect or back up configuration:

  • VM and network definitions: /etc/libvirt/ (XML for each domain, plus qemu.conf)
  • Virtual disk images: /var/lib/libvirt/images/ (the default storage pool)
  • Logs: /var/log/libvirt/ — per-VM logs live under qemu/

Configuration should be changed with virsh edit NAME rather than by hand-editing the XML, so libvirt validates and reloads it correctly.

Next steps

You now have a validated KVM host and a running VM. From here:

Frequently Asked Questions

How do I install KVM on Fedora, RHEL, or CentOS?

Install the whole virtualization stack with one command: sudo dnf install -y @virtualization. That package group pulls in qemu-kvm (the hypervisor), libvirt (the management daemon and API), virt-install (command-line VM creation), virt-manager (the GUI), and virt-viewer. Then enable the service with sudo systemctl enable --now libvirtd, add your user to the libvirt group so you can manage VMs without sudo, and run sudo virt-host-validate to confirm the host is ready. The commands are identical across Fedora, RHEL 8/9, CentOS Stream, Rocky Linux, and AlmaLinux because they all share the dnf package manager and the same libvirt tooling.

How do I check if my CPU supports KVM virtualization?

Run grep -E -c '(vmx|svm)' /proc/cpuinfo. A result greater than 0 means your CPU exposes hardware virtualization (vmx on Intel VT-x, svm on AMD-V). If it returns 0, virtualization is either unsupported or, far more commonly, disabled in the BIOS/UEFI firmware — reboot, enter firmware setup, and enable "Intel VT-x", "AMD-V", or "SVM Mode". The definitive check after installing KVM is sudo virt-host-validate, which tests hardware support, the KVM kernel modules, IOMMU, and cgroups and prints PASS or FAIL for each.

What is the difference between qemu-kvm, libvirt, and virt-install?

They are three layers of the same stack. qemu-kvm is the hypervisor that actually runs the virtual machine, using the KVM kernel modules for near-native CPU performance. libvirt is the management layer — a daemon (libvirtd), an API, and the virsh command line — that starts, stops, and defines VMs and networks in a consistent way. virt-install and virt-manager are front ends that talk to libvirt: virt-install builds VMs from the command line (great for scripting), virt-manager is the graphical console. You install all of them together with the @virtualization group.

Do I need to add my user to the libvirt group?

Yes, if you want to manage VMs without typing sudo for every command. Run sudo usermod -aG libvirt $USER, then log out and back in (or run newgrp libvirt) for the new group membership to take effect. Members of the libvirt group can connect to the system libvirt instance (qemu:///system) and manage all VMs on the host. Without it, virsh and virt-manager either prompt for a password through Polkit or fall back to the unprivileged qemu:///session, which cannot use the default bridged networking.

Why does virt-host-validate report that IOMMU is not activated?

The IOMMU warning is normal on a fresh install and only matters if you plan to do PCI passthrough (assigning a physical GPU or NIC directly to a VM). To enable it, turn on VT-d (Intel) or AMD-Vi/IOMMU in the firmware, then add intel_iommu=on (or amd_iommu=on) to the kernel command line in /etc/default/grub, rebuild the GRUB config, and reboot. For ordinary VMs that use virtual disks and virtual NICs, you can safely ignore this warning — every other line reporting PASS means KVM is ready.

How do I create a virtual machine after installing KVM?

Use virt-install from the command line or virt-manager from the GUI. A minimal command-line example: sudo virt-install --name fedora-vm --memory 4096 --vcpus 2 --disk size=20 --cdrom /path/to/installer.iso --os-variant fedora40. That creates a VM named fedora-vm with 4 GB RAM, 2 vCPUs, a 20 GB virtual disk, and boots the installer ISO. Run osinfo-query os to find the correct --os-variant value for your guest. virt-manager gives you the same result through a step-by-step wizard if you prefer a graphical interface.

Is the libvirtd service still the right thing to enable on RHEL 9 and Fedora?

On most systems sudo systemctl enable --now libvirtd still works and is the simplest option. Newer Fedora and fresh RHEL 9 installs ship "modular" libvirt, which splits the monolithic daemon into per-driver daemons (virtqemud, virtnetworkd, virtstoraged, and so on) that are activated by systemd sockets. On those hosts the recommended pattern is to enable the sockets rather than the legacy service. If systemctl enable --now libvirtd succeeds, you are fine; if it reports the unit is masked or missing, enable the modular sockets instead (shown in the guide below).

Which Linux distributions do these KVM commands work on?

Any RPM-based distribution that uses dnf: Fedora, Red Hat Enterprise Linux 8 and 9, CentOS Stream, Rocky Linux, AlmaLinux, and Oracle Linux. The package group name (@virtualization), the service (libvirtd), the validator (virt-host-validate), and the tooling (virsh, virt-install, virt-manager) are the same across all of them. On Debian and Ubuntu the concept is identical but the package names differ — you install qemu-kvm libvirt-daemon-system virtinst with apt instead.

KVMVirtualizationFedoraRHELCentOSlibvirtvirt-install