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.

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.
| Component | Purpose |
|---|---|
| KVM | Kernel virtualization support and hardware-assisted execution. |
| QEMU | Virtual machine process, virtual hardware and device emulation. |
| libvirt | VM lifecycle, network and storage management; accessed through tools such as virsh. |
| virt-manager | Optional 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 upgradeReview 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/cpuinfoA 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-okExpected 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
Install KVM on Ubuntu 24.04
Install the core packages from Ubuntu’s repositories:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clientsFor 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-viewerFor 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 virtqemudIf your installation uses the traditional monolithic daemon and it is not active, enable it:
sudo systemctl enable --now libvirtdIf 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" libvirtLog 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 --allAn empty table is normal when you have not created a VM yet. Confirm the default network state:
virsh -c qemu:///system net-list --allCheck KVM kernel modules and the device node if acceleration is not working:
lsmod | grep -E '^kvm'
ls -l /dev/kvmDo 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 defaultIf 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
| Mode | Best for | Behavior |
|---|---|---|
| Default NAT | Personal labs, testing and outbound guest connectivity | Guest traffic is NATed through the host; LAN devices usually cannot initiate connections to the guest directly. |
| Linux bridge | Servers where VMs need first-class LAN presence | Guests can appear as separate machines on the physical network when the bridge and network support it. |
| Isolated network | Malware analysis in a controlled lab or private test networks | Guest 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 defaultThe 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
- Open Virtual Machine Manager (
virt-manager). - Connect to the local QEMU/KVM system connection, not just a user-mode QEMU connection.
- Select Create a new virtual machine.
- Choose local installation media and select the ISO.
- Allocate vCPUs and RAM according to guest requirements while leaving resources for Ubuntu.
- Create a virtual disk in the appropriate storage pool.
- Review the network device, firmware and installation settings, then start the VM.
- 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 spiceThis 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-ubuntudestroy 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-ubuntuUse autostart selectively. Confirm that guest startup ordering, storage availability and application dependencies are appropriate for the host.
Troubleshooting common KVM problems
| Symptom | Likely cause | What to check |
|---|---|---|
kvm-ok says acceleration cannot be used | Virtualization disabled, unsupported CPU or nested virtualization not exposed | Firmware settings, CPU flags and outer hypervisor configuration. |
/dev/kvm is missing | KVM module unavailable or hardware acceleration not exposed | lsmod, kernel logs and virtualization support. |
| Permission denied from virsh | Wrong connection URI or user permissions | Use qemu:///system, check groups, log out and back in. |
| VM has no network access | Default network inactive or guest network misconfigured | virsh net-list --all, guest IP, DHCP and host firewall. |
| VM is not visible in virt-manager | Connected to session instead of system URI | Open the correct QEMU/KVM system connection. |
| VM is slow | Insufficient RAM/CPU, storage bottleneck or no KVM acceleration | Host load, guest allocation, disk performance and /dev/kvm. |
Inspect service logs
sudo journalctl -b -u libvirtd --no-pager
sudo journalctl -b -u virtqemud --no-pagerOne 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:
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
- Ubuntu Server documentation: libvirt
- Ubuntu Server documentation: QEMU
- Ubuntu Community Help: KVM overview
- Ubuntu Community Help: KVM networking
- Official libvirt documentation
- virsh command reference
Build your Linux virtualization lab
Explore more VMoreCloud tutorials covering Linux, VMware, cloud infrastructure, networking and backup.
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.
