How To Install QEMU on Ubuntu 24.04 LTS
QEMU (Quick Emulator) serves as one of the most powerful and versatile virtualization platforms available for Ubuntu 24.04 LTS systems. This comprehensive guide provides detailed instructions for installing and configuring QEMU with KVM acceleration, transforming your Ubuntu machine into a robust virtualization environment capable of running multiple operating systems simultaneously.
Understanding QEMU and KVM
What is QEMU?
QEMU stands as a complete machine emulator and virtualizer that enables users to run guest operating systems on host machines. Unlike traditional virtual machines that require extensive hardware resources, QEMU efficiently utilizes system resources through dynamic translation and hardware acceleration. The platform supports numerous architectures including x86, ARM, PowerPC, and RISC-V, making it an ideal choice for developers and system administrators working with diverse computing environments.
The emulator operates in two primary modes: system emulation and user-mode emulation. System emulation allows complete operating system virtualization, while user-mode emulation enables running applications compiled for different architectures. This flexibility makes QEMU particularly valuable for cross-platform development and testing scenarios.
QEMU and KVM Integration
Kernel-based Virtual Machine (KVM) transforms Linux into a bare-metal hypervisor, providing hardware-assisted virtualization capabilities. When QEMU integrates with KVM, it leverages hardware virtualization extensions present in modern processors, delivering near-native performance for virtual machines. This integration eliminates the performance overhead typically associated with software-based virtualization solutions.
KVM requires CPU virtualization support, specifically Intel VT-x or AMD-V extensions. The kernel module manages virtual machine execution while QEMU handles device emulation, creating a powerful combination that rivals commercial virtualization platforms.
Prerequisites and System Requirements
Hardware Requirements
Your Ubuntu 24.04 LTS system must meet specific hardware requirements for optimal QEMU performance. Modern multi-core processors with at least 4GB RAM provide adequate resources for basic virtualization tasks. However, production environments typically require 8GB or more RAM to accommodate multiple virtual machines effectively.
CPU virtualization extensions (Intel VT-x or AMD-V) are mandatory for KVM acceleration. Most processors manufactured after 2010 include these features, but verification remains essential before proceeding with installation.
Software Requirements
Ubuntu 24.04 LTS provides the foundation for QEMU installation. Ensure your system maintains active internet connectivity for package downloads and updates. Administrative privileges (sudo access) are required throughout the installation process.
The system should run on a 64-bit architecture for optimal compatibility with modern guest operating systems. While 32-bit systems can run QEMU, they face significant limitations in memory allocation and guest OS support.
Pre-Installation Checks
Verify CPU virtualization support using the lscpu
command:
lscpu | grep -i virtualization
This command displays available virtualization features. Look for “VT-x” (Intel) or “AMD-V” (AMD) in the output. Additionally, check KVM module availability:
lsmod | grep kvm
If no output appears, the KVM modules may require loading or your system BIOS/UEFI settings need adjustment. Access your system BIOS/UEFI settings during boot and enable virtualization features, typically found under “Advanced” or “Security” sections.
Installation Methods Overview
Ubuntu 24.04 LTS offers multiple QEMU installation approaches, each serving different user requirements and scenarios. The package manager installation method provides the most straightforward approach for standard deployments, offering automatic dependency resolution and regular security updates through the Ubuntu repository system.
Source code compilation appeals to advanced users requiring the latest QEMU features or custom compilation options. This method demands additional time and technical expertise but delivers maximum flexibility. Snap package installation provides an alternative containerized approach, though it may introduce performance considerations.
Method 1: Installing QEMU via APT Package Manager
System Update
Begin the installation process by updating your Ubuntu 24.04 LTS system to ensure all packages reflect the latest versions and security patches:
sudo apt update && sudo apt upgrade -y
This command refreshes package repositories and installs available updates. System updates prevent compatibility issues and ensure optimal security before introducing new software components.
Core Package Installation
Install essential QEMU and virtualization packages using a single comprehensive command:
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -y
This command installs several critical components:
- qemu-kvm: Core QEMU package with KVM support
- libvirt-daemon-system: Virtualization management daemon
- libvirt-clients: Command-line tools for VM management
- bridge-utils: Network bridging utilities for VM connectivity
- virt-manager: Graphical interface for virtual machine management
The installation process automatically resolves dependencies and configures basic system integration. Package installation typically completes within 5-10 minutes, depending on network speed and system performance.
Additional Useful Packages
Enhance your QEMU installation with supplementary packages for extended functionality:
sudo apt install qemu-system qemu-utils cpu-checker -y
These packages provide:
- qemu-system: Support for various guest architectures
- qemu-utils: Disk image manipulation utilities
- cpu-checker: Hardware virtualization verification tools
For ARM64 virtualization support, install the dedicated package:
sudo apt install qemu-system-arm -y
Installation Verification
Confirm successful installation by checking QEMU version and service status:
qemu-system-x86_64 --version
sudo systemctl status libvirtd
The first command displays the installed QEMU version, while the second verifies the libvirt daemon runs correctly. Active libvirt service status indicates proper installation and system integration.
Test KVM functionality using the verification utility:
sudo kvm-ok
This command confirms hardware virtualization support and KVM module loading status.
Method 2: Installing QEMU from Source Code
When to Choose Source Installation
Source code installation becomes necessary when requiring cutting-edge QEMU features unavailable in Ubuntu repositories. Development environments, specialized hardware support, or custom compilation options justify the additional complexity of building from source.
Research projects and testing scenarios often demand the latest QEMU versions for accessing experimental features or bug fixes not yet incorporated into stable releases.
Dependency Installation
Install comprehensive build dependencies for QEMU compilation:
sudo apt install build-essential ninja-build libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libaio-dev libbluetooth-dev libbrlapi-dev libbz2-dev libcap-dev libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev libibverbs-dev libjpeg8-dev libncurses5-dev libnuma-dev librbd-dev librdmacm-dev libsasl2-dev libsdl2-dev libseccomp-dev libsnappy-dev libssh-dev libvde-dev libvdeplug-dev libvte-2.91-dev libxen-dev liblzo2-dev valgrind xfslibs-dev libnfs-dev libiscsi-dev -y
This extensive package list ensures successful compilation across various QEMU features and hardware accelerations.
Source Code Download and Compilation
Download the latest QEMU source code from the official repository:
wget https://download.qemu.org/qemu-10.1.0.tar.xz
tar xvJf qemu-10.1.0.tar.xz
cd qemu-10.1.0
Configure the build environment with optimization options:
mkdir build
cd build
../configure --target-list=x86_64-softmmu --enable-kvm
Compile QEMU using available CPU cores:
make -j$(nproc)
Install the compiled binaries system-wide:
sudo make install
Source Installation Verification
Verify the custom-compiled QEMU installation:
/usr/local/bin/qemu-system-x86_64 --version
Update system PATH if necessary to prioritize the custom installation over package manager versions.
Post-Installation Configuration
User Group Management
Add your user account to the libvirt and KVM groups for proper virtual machine access:
sudo usermod -aG libvirt,kvm $USER
This command grants necessary permissions for managing virtual machines without requiring sudo privileges for routine operations. Group membership changes require logging out and back in to take effect.
Verify group membership:
groups $USER
The output should include both “libvirt” and “kvm” groups.
Libvirt Service Configuration
Ensure the libvirt daemon starts automatically and runs correctly:
sudo systemctl enable --now libvirtd
sudo systemctl status libvirtd
The first command enables automatic startup during boot, while the second displays current service status. Active status indicates proper configuration and readiness for virtual machine management.
Network Configuration
Configure default virtual network for guest connectivity:
sudo virsh net-start default
sudo virsh net-autostart default
These commands activate the default NAT network and configure automatic startup. The default network provides internet access for virtual machines through network address translation.
For advanced networking requirements, create custom bridge configurations. Bridge networking enables direct guest access to physical network segments, suitable for production environments requiring specific network topologies.
Installing and Configuring Virt-Manager
Virt-Manager Installation
Virt-Manager provides an intuitive graphical interface for virtual machine management. If not installed during the initial QEMU setup, install it separately:
sudo apt install virt-manager -y
The graphical interface simplifies VM creation, configuration, and monitoring tasks compared to command-line alternatives.
Initial Virt-Manager Setup
Launch Virt-Manager from the applications menu or command line:
virt-manager
The application automatically detects the local QEMU/KVM connection upon first launch. The interface displays available virtual machines, network configurations, and storage pools. Navigate through the intuitive menu system to access various management functions.
Configure connection preferences through the “File” menu to customize display options, update intervals, and connection settings. The interface supports multiple hypervisor connections, enabling centralized management of distributed virtualization infrastructure.
Creating Your First Virtual Machine
VM Creation via Command Line
Create virtual machine disk images using QEMU utilities:
qemu-img create -f qcow2 ubuntu-vm.qcow2 20G
This command creates a 20GB dynamic disk image in the efficient qcow2 format. Dynamic allocation ensures the file grows only as the guest OS requires storage space.
Launch a basic virtual machine with ISO installation media:
qemu-system-x86_64 -hda ubuntu-vm.qcow2 -cdrom ubuntu-24.04-desktop-amd64.iso -boot d -m 2048 -enable-kvm
This command allocates 2GB RAM, boots from the ISO image, and enables KVM acceleration for optimal performance.
VM Creation via Virt-Manager
The graphical approach simplifies virtual machine creation through wizard-driven dialogs. Click “Create a new virtual machine” and follow the step-by-step process:
- Select installation media (ISO file, network installation, or existing disk image)
- Configure memory and CPU allocation based on guest OS requirements
- Create or select storage volumes with appropriate sizing
- Review and customize network configuration options
- Complete the wizard and begin guest OS installation
The wizard automatically optimizes settings based on detected guest operating systems, ensuring compatibility and performance optimization.
Advanced QEMU Features and Options
Hardware Acceleration
Modern QEMU installations automatically detect and enable available hardware acceleration features. Verify KVM acceleration status during VM runtime:
ps aux | grep qemu | grep accel
Look for “accel=kvm” in the process arguments, confirming hardware acceleration engagement. CPU feature passthrough enables guests to utilize specific processor capabilities for enhanced performance in specialized applications.
Storage Options
QEMU supports multiple disk image formats, each offering distinct advantages:
- qcow2: Feature-rich format with compression, encryption, and snapshot support
- raw: Maximum performance with direct disk access
- vmdk: VMware compatibility for hybrid environments
Create snapshots for quick system state preservation:
qemu-img snapshot -c snapshot-name disk-image.qcow2
Networking Configurations
QEMU provides flexible networking options for diverse connectivity requirements. User-mode networking offers simple internet access without administrative configuration. Bridge networking provides direct network access, while port forwarding enables selective service exposure.
Configure port forwarding for SSH access:
qemu-system-x86_64 ... -netdev user,id=net0,hostfwd=tcp::2222-:22 -device e1000,netdev=net0
Troubleshooting Common Issues
Installation Problems
Package dependency conflicts occasionally arise during installation. Resolve conflicts by updating package repositories and removing conflicting packages:
sudo apt update
sudo apt autoremove
sudo apt install --fix-broken
Permission problems typically result from incorrect user group membership or inadequate file system permissions. Verify group assignments and file ownership for affected components.
Runtime Issues
Virtual machine boot failures often indicate hardware resource constraints or configuration errors. Monitor system resource utilization during VM startup to identify bottlenecks. Increase memory allocation or reduce concurrent VM counts to resolve resource conflicts.
Network connectivity issues may stem from firewall restrictions or incorrect network configurations. Verify libvirt network status and adjust firewall rules as necessary:
sudo virsh net-list --all
sudo ufw status
Hardware-Related Issues
BIOS/UEFI virtualization settings require enabling before KVM functionality becomes available. Access system firmware settings during boot and locate virtualization options under advanced or security sections. Enable Intel VT-x or AMD-V as appropriate for your processor.
Memory allocation errors indicate insufficient system RAM or improper VM configuration. Adjust guest memory allocation to remain within physical system limits while maintaining host OS operational requirements.
Performance Optimization and Best Practices
Resource Allocation
Optimal virtual machine performance depends on balanced resource allocation. Assign CPU cores based on guest workload requirements while preserving adequate resources for host system operations. Memory allocation should reflect guest OS requirements plus application overhead.
Storage performance benefits from solid-state drives and appropriate file system selections. Avoid over-provisioning storage across multiple concurrent VMs to prevent I/O bottlenecks during peak usage periods.
Security Considerations
Virtual machine isolation protects both host and guest systems from security compromises. Configure appropriate network segmentation to limit inter-VM communication based on security requirements. Regular updates for both host Ubuntu system and QEMU components maintain security patch levels.
User permission management ensures authorized access to virtualization resources while preventing unauthorized virtual machine creation or modification. Implement monitoring solutions for tracking VM resource utilization and access patterns.
Alternative Virtualization Solutions Comparison
QEMU/KVM offers distinct advantages over competing virtualization platforms. VirtualBox provides easier initial setup but lacks enterprise-grade performance optimization. VMware delivers commercial support and advanced features at significant licensing costs.
QEMU excels in flexibility, cost-effectiveness, and integration with Linux environments. The open-source nature enables customization and eliminates licensing restrictions common in proprietary solutions. Performance characteristics often surpass commercial alternatives when properly configured.
Choose QEMU for development environments, testing scenarios, and production deployments requiring cost-effective virtualization. Consider alternatives when specific vendor support requirements or simplified management interfaces take priority over technical flexibility.
Congratulations! You have successfully installed QEMU. Thanks for using this tutorial for installing the QEMU open-source machine emulator and virtualizer on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend check the official QEMU website.