How to Install KVM on Ubuntu, Debian and RHEL (Step by Step)

Install KVM, QEMU and libvirt on Ubuntu, Debian, Rocky or RHEL. Check CPU support, add user groups, start libvirtd and verify the default network.

Published November 27, 2026

Installing KVM takes about five minutes on any modern distribution. The steps are the same everywhere: confirm CPU support, install QEMU and libvirt, start the daemon, give your user permission, and verify the default NAT network. This guide covers both Debian/Ubuntu and RHEL/Rocky/Alma/Fedora.

The concept

KVM is already part of the kernel on every mainstream distribution, so there is no kernel to compile. What you install are the userspace pieces: QEMU (the emulator), libvirt (the management daemon), and client tools such as virsh and virt-install. On a server you rarely need the virt-manager GUI. On a desktop it is handy.

Permissions are the most common stumbling block. libvirt has two connection modes. qemu:///system is the system-wide daemon that owns bridged networks and /var/lib/libvirt/images. qemu:///session is a per-user instance with fewer privileges. For servers you almost always want qemu:///system, and membership in the libvirt group lets a normal user manage it without sudo.

Overview of the steps

  1. Verify vmx/svm flags and enable VT-x/AMD-V in firmware if missing
  2. Install qemu-kvm, libvirt and virtinst packages
  3. Enable and start the libvirt daemon (or virtqemud socket)
  4. Add your user to the libvirt and kvm groups, then log in again
  5. Run virt-host-validate and check the default network is active
The install workflow is identical across distributions; only package names differ.

Debian and Ubuntu

On Ubuntu 22.04/24.04 and Debian 12, the packages below give you everything for a headless hypervisor. bridge-utils is optional but useful when you later build a bridged network.

sudo apt update
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients \
                    virtinst bridge-utils cpu-checker
kvm-ok
sudo systemctl enable --now libvirtd
sudo usermod -aG libvirt,kvm "$USER"

Log out and back in (or run newgrp libvirt) so the new group membership applies.

RHEL, Rocky, AlmaLinux and Fedora

Red Hat family distributions ship a virtualization group. On RHEL 9 and newer the modular daemons are socket-activated, so you enable the sockets rather than a single libvirtd service.

sudo dnf install -y qemu-kvm libvirt virt-install virt-viewer
# RHEL 9+/Fedora modular daemons
for drv in qemu network nodedev nwfilter secret storage interface; do
  sudo systemctl enable --now virt${drv}d.socket
done
sudo usermod -aG libvirt "$USER"

Verify the installation

virt-host-validate qemu
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 secure guest support : WARN (not supported)
virsh net-list --all
Name State Autostart Persistent
default active yes yes
virt-host-validate checks hardware, devices and cgroups. A secure-guest WARN is normal on most hardware.

Practical examples

Start the default network if it is inactive

The default network gives VMs NAT internet access on 192.168.122.0/24.

virsh net-start default
virsh net-autostart default

Set the default connection URI

Without this, virsh as a normal user connects to qemu:///session and shows an empty VM list.

echo 'export LIBVIRT_DEFAULT_URI=qemu:///system' >> ~/.bashrc
source ~/.bashrc && virsh uri

Manage the host from your laptop

virt-manager and virsh can connect over SSH, so no GUI is needed on the server.

virsh -c qemu+ssh://admin@kvm-host.example.com/system list --all
virt-manager -c qemu+ssh://admin@kvm-host.example.com/system

Common mistakes

  • Skipping the re-login after usermod. Group changes do not apply to existing sessions.
  • Installing on a cloud VM without nested virtualization: /dev/kvm will be missing.
  • Leaving firewalld or ufw blocking the virbr0 bridge so guests get no DHCP lease.
  • Running two hypervisors at once: VirtualBox with its own kernel modules can conflict with KVM on the same host.

Key takeaways

  • Install qemu-kvm, libvirt and virt-install; the kernel already has KVM.
  • Add your user to the libvirt group and use qemu:///system.
  • virt-host-validate is the fastest health check for a new hypervisor.
  • Make sure the default NAT network is active and set to autostart.

FAQ

Do I need a desktop environment?

No. A headless server with libvirt is ideal. Manage it remotely with virsh or virt-manager over SSH, or with the Cockpit web UI (cockpit-machines).

How much RAM does the host need?

Plan for the sum of all guest memory plus 1-2 GB for the host. KVM supports overcommit through KSM and ballooning, but heavy overcommit causes swapping.

Why does virsh list show nothing?

You are probably connected to qemu:///session. Run virsh -c qemu:///system list --all or set LIBVIRT_DEFAULT_URI.

More Linux articles