How to Install KVM on Ubuntu 24.04: Complete Guide

Home / Linux / Virtualization

How to Install KVM on Ubuntu 24.04 LTS

Set up a reliable Linux virtualization host with KVM, QEMU and libvirt on Ubuntu 24.04 LTS. This step-by-step guide covers hardware checks, package installation, virtual networking, storage, VM creation, verification and common troubleshooting tasks.

By Khurram ShahzadLinux TutorialUpdated October 18, 2026Approx. 12–15 min read
KVM virtualization on Ubuntu 24.04 with QEMU and libvirt
Featured image placeholder: upload a 1200 × 675 WebP image and replace this URL here and in the structured data.
What you will build: an Ubuntu 24.04 host running KVM acceleration through QEMU, managed by libvirt. You can administer VMs from the terminal with virsh or use the optional graphical tool Virtual Machine Manager (virt-manager).

Prerequisites

Ubuntu 24.04 LTS, sudo access, CPU virtualization enabled and enough RAM/storage for guests.

Core packages

qemu-kvm, libvirt-daemon-system, libvirt-clients and cpu-checker.

Management

Use virsh for CLI administration or install virt-manager for a GUI.

What are KVM, QEMU and libvirt?

KVM (Kernel-based Virtual Machine) is Linux kernel virtualization infrastructure that uses hardware virtualization extensions to run guest operating systems efficiently. QEMU provides the machine emulator and virtual device model, while libvirt offers a consistent management API and tools for creating, configuring and controlling VMs.

ComponentPurpose
KVMKernel virtualization support and hardware-assisted execution.
QEMUVirtual machine process, virtual hardware and device emulation.
libvirtVM lifecycle, network and storage management; accessed through tools such as virsh.
virt-managerOptional graphical interface for local and remote VM management.

This guide follows Ubuntu’s server virtualization documentation for the core installation steps. Package names and available features can change over time, so consult the official Ubuntu documentation linked at the end if your system differs.

Requirements and hardware checks

1. Update package metadata

sudo apt update
sudo apt upgrade

Review proposed upgrades before confirming, especially on a production server. Reboot if a kernel or firmware update requires it.

2. Confirm CPU virtualization support

Intel systems generally expose VT-x as vmx; AMD systems generally expose AMD-V as svm. Run:

grep -Eoc '(vmx|svm)' /proc/cpuinfo

A value greater than zero means the kernel can see a virtualization flag. A zero result can mean the CPU lacks the feature, firmware has disabled it, or the Ubuntu host is itself a VM without nested virtualization exposed.

3. Install the check utility and verify KVM

sudo apt install cpu-checker
kvm-ok

Expected output on a suitable host includes a message similar to KVM acceleration can be used. You can also check the device node:

ls -l /dev/kvm
Nested virtualization: if Ubuntu 24.04 is itself running inside VMware, Hyper-V, VirtualBox or another hypervisor, enable nested virtualization in the outer hypervisor and expose VT-x/AMD-V to the guest. Otherwise KVM acceleration may be unavailable.

Install KVM on Ubuntu 24.04

Install the core packages from Ubuntu’s repositories:

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients

For a host that will create VMs from the command line, add the VM provisioning tool and a console viewer if needed:

sudo apt install virtinst virt-viewer

For a desktop system, install the graphical manager too:

sudo apt install virt-manager

Enable and start libvirt

Ubuntu package versions can use different libvirt service layouts. Check the available service rather than assuming a service name:

systemctl status libvirtd
systemctl status virtqemud

If your installation uses the traditional monolithic daemon and it is not active, enable it:

sudo systemctl enable --now libvirtd

If the system uses modular libvirt daemons, consult the service status and Ubuntu documentation for the installed package version. Do not try to enable a service that does not exist on your host.

Allow your user to manage system VMs

Ubuntu’s documentation notes that users in the sudo group are commonly configured for system libvirt access automatically; other users may need to be added to the libvirt group:

sudo adduser "$USER" libvirt

Log out and back in for new group membership to take effect. Avoid adding users to privileged groups unless they are trusted: system-level VM management can provide substantial control over the host.

Verify the installation

Check that libvirt responds and list all defined VMs:

virsh -c qemu:///system list --all

An empty table is normal when you have not created a VM yet. Confirm the default network state:

virsh -c qemu:///system net-list --all

Check KVM kernel modules and the device node if acceleration is not working:

lsmod | grep -E '^kvm'
ls -l /dev/kvm

Do not manually change ownership or permissions on /dev/kvm as a first troubleshooting step. Identify whether the issue is firmware, nested virtualization, kernel module loading, permissions or the selected libvirt connection.

Configure virtual networking

For a typical workstation or lab, libvirt’s default NAT network is the simplest starting point. Guests can initiate outbound connections through the host, while inbound access from other LAN devices is not automatically provided. The common default network uses a private subnet such as 192.168.122.0/24, but check your actual configuration rather than assuming that range.

Check and start the default network

virsh -c qemu:///system net-list --all
sudo virsh -c qemu:///system net-start default
sudo virsh -c qemu:///system net-autostart default

If the network is already active, the start command may report that. If the network named default does not exist, inspect the installed libvirt network definitions and official Ubuntu guidance instead of blindly redefining one.

NAT versus bridged networking

ModeBest forBehavior
Default NATPersonal labs, testing and outbound guest connectivityGuest traffic is NATed through the host; LAN devices usually cannot initiate connections to the guest directly.
Linux bridgeServers where VMs need first-class LAN presenceGuests can appear as separate machines on the physical network when the bridge and network support it.
Isolated networkMalware analysis in a controlled lab or private test networksGuest traffic can be restricted to the host or selected virtual machines.

Bridging requires careful configuration of Netplan and the physical network interface. On a remote host, a wrong bridge change can disconnect SSH or management access. Back up the current Netplan configuration and plan console or out-of-band access before changing production networking.

Understand VM storage

libvirt commonly stores disk images under /var/lib/libvirt/images/, though your host may use a different directory or storage pool. The QCOW2 format supports features such as thin provisioning and snapshots; raw images can be useful for some performance or storage scenarios. Choose based on your workload, backup strategy and storage backend.

sudo virsh -c qemu:///system pool-list --all
sudo virsh -c qemu:///system vol-list default

The second command assumes a storage pool named default exists. If it does not, list the pools and use the actual pool name. Ensure the host has enough free capacity for guest disks, snapshots and backups.

Create your first virtual machine

Download an installation ISO from the operating system’s official website and verify its checksum where the publisher provides one. Save it somewhere readable by the host and ensure there is sufficient disk space.

Option A: Use Virtual Machine Manager

  1. Open Virtual Machine Manager (virt-manager).
  2. Connect to the local QEMU/KVM system connection, not just a user-mode QEMU connection.
  3. Select Create a new virtual machine.
  4. Choose local installation media and select the ISO.
  5. Allocate vCPUs and RAM according to guest requirements while leaving resources for Ubuntu.
  6. Create a virtual disk in the appropriate storage pool.
  7. Review the network device, firmware and installation settings, then start the VM.
  8. Complete the guest OS installer and install guest integration tools where appropriate.

Option B: Use virt-install

The following example creates a VM named lab-ubuntu using an Ubuntu ISO. Replace the ISO path and disk size to suit your environment:

sudo virt-install \\
  --connect qemu:///system \\
  --name lab-ubuntu \\
  --memory 4096 \\
  --vcpus 2 \\
  --disk size=30,format=qcow2,bus=virtio \\
  --cdrom /var/lib/libvirt/images/ubuntu-24.04.iso \\
  --os-variant ubuntu24.04 \\
  --network network=default,model=virtio \\
  --graphics spice

This is an example, not a universal sizing recommendation. Confirm that the ISO path exists and the ubuntu24.04 OS variant is recognized by your installed libosinfo database. If virt-install cannot find a graphical display, use virt-manager or configure a supported console/display method.

Manage virtual machines

Use virsh for common lifecycle tasks:

# List all VMs
virsh -c qemu:///system list --all

# Start a VM
sudo virsh -c qemu:///system start lab-ubuntu

# Request a graceful shutdown
sudo virsh -c qemu:///system shutdown lab-ubuntu

# Force-stop only if graceful shutdown is not possible
sudo virsh -c qemu:///system destroy lab-ubuntu

# Show VM details
sudo virsh -c qemu:///system dominfo lab-ubuntu

# View VM console/display URI details
sudo virsh -c qemu:///system domdisplay lab-ubuntu

destroy stops the VM immediately; it does not delete the virtual disk, but it can cause guest data loss just like powering off a physical machine without shutting down the OS.

Autostart a VM with the host

sudo virsh -c qemu:///system autostart lab-ubuntu

Use autostart selectively. Confirm that guest startup ordering, storage availability and application dependencies are appropriate for the host.

Troubleshooting common KVM problems

SymptomLikely causeWhat to check
kvm-ok says acceleration cannot be usedVirtualization disabled, unsupported CPU or nested virtualization not exposedFirmware settings, CPU flags and outer hypervisor configuration.
/dev/kvm is missingKVM module unavailable or hardware acceleration not exposedlsmod, kernel logs and virtualization support.
Permission denied from virshWrong connection URI or user permissionsUse qemu:///system, check groups, log out and back in.
VM has no network accessDefault network inactive or guest network misconfiguredvirsh net-list --all, guest IP, DHCP and host firewall.
VM is not visible in virt-managerConnected to session instead of system URIOpen the correct QEMU/KVM system connection.
VM is slowInsufficient RAM/CPU, storage bottleneck or no KVM accelerationHost load, guest allocation, disk performance and /dev/kvm.

Inspect service logs

sudo journalctl -b -u libvirtd --no-pager
sudo journalctl -b -u virtqemud --no-pager

One of these service names may not exist if your host uses a different libvirt daemon layout. Review whichever service is installed and inspect QEMU/libvirt logs around the time the failure occurred.

Security and operational best practices

  • Install host updates regularly and use trusted guest ISO sources.
  • Restrict access to system libvirt; membership in privileged management groups should be limited to trusted administrators.
  • Do not expose libvirt management sockets or APIs to untrusted networks.
  • Use isolated virtual networks for untrusted guests and control guest-to-host access.
  • Back up guest disks and important configuration, and periodically test restores.
  • Monitor storage usage to prevent guest disks or snapshots from filling the host filesystem.
  • Document VM ownership, resource allocations, IP addresses, backup policies and patch schedules.

Related guide: Install AlmaLinux 10

After setting up KVM on Ubuntu, you can use it to build a Linux lab, test server roles or practice enterprise administration. For a guest operating system installation walkthrough, continue with our related guide:

Internal link: How to Install AlmaLinux 10 — use this tutorial to prepare an AlmaLinux guest for your KVM lab.

Frequently asked questions

Does Ubuntu 24.04 support KVM?

Yes. Ubuntu 24.04 LTS supports KVM-based virtualization. Your CPU must support hardware virtualization and it must be enabled and exposed to the Ubuntu host.

Is KVM free to use?

KVM, QEMU and libvirt are open-source projects available through Ubuntu packages. Review the licenses for each component and any guest operating system you install.

Do I need virt-manager?

No. You can create and manage virtual machines using CLI tools such as virsh and virt-install. virt-manager is an optional graphical interface.

What is the difference between KVM and QEMU?

KVM provides kernel-based hardware virtualization support. QEMU provides the VM process and virtual device emulation; QEMU uses KVM acceleration when it is available and configured.

Does the default KVM network let other computers connect to my VM?

Usually not directly. The default libvirt NAT network typically supports outbound guest connections. Use carefully configured bridging or explicit network rules when inbound LAN access is required.

Can I install KVM inside a VMware virtual machine?

Yes, if nested virtualization is supported and enabled by the outer hypervisor and the CPU features are exposed to the Ubuntu guest. Otherwise, hardware acceleration may be unavailable.

Where are KVM virtual disks stored?

A common default location is /var/lib/libvirt/images/, but the actual location depends on the configured libvirt storage pool. Check with virsh pool-list --all.

Can KVM run Windows guests?

Yes, subject to guest licensing and hardware requirements. Use legitimate installation media, allocate suitable resources, and configure virtual devices and drivers according to the guest OS guidance.

Official references and further reading

Build your Linux virtualization lab

Explore more VMoreCloud tutorials covering Linux, VMware, cloud infrastructure, networking and backup.

Explore Linux tutorials →

Khurram Shahzad

Hybrid Cloud & Virtualization Engineer

Hybrid Cloud & Virtualization Engineer specializing in VMware, Azure, AWS, Windows Server, Microsoft 365, Linux, networking, backup & disaster recovery. I share practical guides, technical projects and insights into modern IT infrastructure through VMoreCloud.

Editorial note: This guide is based on published Ubuntu and libvirt documentation. Commands are provided for a typical Ubuntu 24.04 host; service names, network definitions and package behavior can vary by installation. Test configuration changes in a lab before applying them to production hosts. No claim of hands-on testing is made.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO