Virtualization

KVM Installation Guide | Linux Virtualization Setup

Install and verify KVM on Fedora, RHEL, CentOS Stream, Rocky, or AlmaLinux: check virtualization support, install the needed packages, start libvirt, validate the host, and build your first VM.

By InventiveHQ Team

To install KVM on Fedora or a RHEL-family host, check virtualization support, install qemu-kvm, libvirt, and virt-install with dnf, start the available libvirt service or sockets, and run sudo virt-host-validate. Package groups and GUI tools vary by distribution. Before you start, check that the CPU exposes hardware virtualization with grep -E -c '(vmx|svm)' /proc/cpuinfo.

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

On Fedora, the @virtualization package group is a convenient option:

sudo dnf install -y @virtualization

Group contents vary by distribution. The main components are:

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.

For a core setup, install the packages explicitly:

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

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.

Advertisement

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
  • The required virtualization packages installed 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 vnc

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 VNC console. SPICE is unavailable in some RHEL configurations. 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? Install virt-manager if it is not already present, launch it, 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:

Interactive toolVirsh Command BuilderRuns in your browser — nothing is uploaded.

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 core packagessudo dnf install -y qemu-kvm libvirt virt-install
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:

For another dedicated-host hypervisor setup, see the XenServer installation guide.

Frequently Asked Questions

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

Install the core packages with sudo dnf install -y qemu-kvm libvirt virt-install, then start the available libvirt service or modular sockets and run sudo virt-host-validate. Fedora may offer the @virtualization group, but package groups and included GUI tools vary across distributions. Install virt-manager and virt-viewer separately if you need a local GUI.

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 runs the virtual machine using the KVM kernel modules. libvirt is the management layer, and virt-install and virt-manager are command-line and graphical front ends. Install the components you need; group contents vary by distribution.

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?

The core dnf package approach applies to Fedora and RHEL-family distributions, though package groups, GUI availability, and libvirt service units vary. Check your distribution's package list and use the available libvirt service or modular sockets. Debian and Ubuntu use different package names.

KVMVirtualizationFedoraRHELCentOSlibvirtvirt-install