Virtual Machines & Containers
This article covers various virtualization and system container technologies available on Ubuntu 26.04.
Check Hardware Virtualization Support
Before getting started, confirm that your CPU supports hardware virtualization:
# Check for virtualization support
egrep -c '(vmx|svm)' /proc/cpuinfoA result greater than 0 indicates support. You can also use cpu-checker:
sudo apt install cpu-checker -y
kvm-okKVM / QEMU
KVM (Kernel-based Virtual Machine) is a virtualization solution built into the Linux kernel. Combined with QEMU, it provides full virtualization capabilities.
Install KVM and Related Tools
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager -yAdd the current user to the required groups:
sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USERLog out and back in for the group changes to take effect.
Verify Installation
# Check libvirt service status
sudo systemctl status libvirtd
# Verify connection
virsh list --allUsing virt-manager (GUI)
virt-managervirt-manager provides an intuitive graphical interface for creating and managing virtual machines.
Create a VM via Command Line
# Create a disk image
qemu-img create -f qcow2 /var/lib/libvirt/images/ubuntu-vm.qcow2 40G
# Install a VM from ISO
virt-install \
--name ubuntu-vm \
--ram 4096 \
--vcpus 2 \
--disk path=/var/lib/libvirt/images/ubuntu-vm.qcow2,size=40 \
--os-variant ubuntu26.04 \
--network bridge=virbr0 \
--graphics vnc \
--cdrom /path/to/ubuntu-26.04-desktop-amd64.isoRun osinfo-query os | grep ubuntu to confirm whether your local osinfo-db includes ubuntu26.04. If not, upgrade osinfo-db, fall back to the closest ubuntu24.04, or use --osinfo detect=on,require=off to let virt-install auto-detect.
Common virsh Commands
# List all VMs
virsh list --all
# Start a VM
virsh start ubuntu-vm
# Shut down a VM
virsh shutdown ubuntu-vm
# Force stop
virsh destroy ubuntu-vm
# Suspend and resume
virsh suspend ubuntu-vm
virsh resume ubuntu-vm
# Create snapshots
virsh snapshot-create-as ubuntu-vm --name "clean-install"
virsh snapshot-list ubuntu-vm
virsh snapshot-revert ubuntu-vm --snapshotname "clean-install"
# Delete a VM
virsh undefine ubuntu-vm --remove-all-storageUsing QEMU Directly
Without libvirt, using QEMU directly:
# Create a disk
qemu-img create -f qcow2 disk.qcow2 20G
# Start a VM
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-smp 2 \
-hda disk.qcow2 \
-cdrom ubuntu.iso \
-boot d \
-net nic -net user,hostfwd=tcp::2222-:22VirtualBox
VirtualBox is Oracle’s open-source virtualization software with a clean graphical interface.
Install VirtualBox
# Method 1: Install from Ubuntu repository
sudo apt install virtualbox -y
# Method 2: Install from Oracle's official repository (newer version)
wget -qO- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor -o /etc/apt/keyrings/oracle-virtualbox.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/oracle-virtualbox.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update
# Install VirtualBox (run apt-cache search virtualbox to confirm the current
# available package name, e.g. virtualbox-7.1 or a newer version)
sudo apt install virtualbox-7.1 -yInstall Extension Pack
The Extension Pack provides USB 3.0, RDP remote desktop, and other features:
# Install the extension pack after downloading the matching version
sudo VBoxManage extpack install Oracle_VirtualBox_Extension_Pack-*.vbox-extpackVBoxManage Command Line
# List VMs
VBoxManage list vms
# Start a VM (headless mode)
VBoxManage startvm "vm-name" --type headless
# Shut down a VM
VBoxManage controlvm "vm-name" acpipowerbutton
# Create a snapshot
VBoxManage snapshot "vm-name" take "snapshot-name"LXD / LXC System Containers
LXC is a Linux container technology, and LXD is its management daemon, providing a VM-like experience but more lightweight.
Install LXD
sudo snap install lxdInitialize LXD
lxd init --minimalOr use interactive configuration for more options:
lxd initLXD Basic Operations
# Launch an Ubuntu container
lxc launch ubuntu:26.04 mycontainer
# Launch a VM (yes, LXD supports VMs too)
lxc launch ubuntu:26.04 myvm --vm
# List instances
lxc list
# Enter a container
lxc exec mycontainer -- bash
# Push and pull files
lxc file push local-file.txt mycontainer/root/
lxc file pull mycontainer/root/file.txt .
# Stop and delete
lxc stop mycontainer
lxc delete mycontainer
# Create snapshots
lxc snapshot mycontainer snap0
lxc restore mycontainer snap0LXD Profile Configuration
# View default profile
lxc profile show default
# Create a custom profile
lxc profile create dev-profile
lxc profile set dev-profile limits.cpu 4
lxc profile set dev-profile limits.memory 8GB
# Launch a container with a custom profile
lxc launch ubuntu:26.04 devbox --profile dev-profileIncus
Incus is a community fork of LXD, maintained by the Linux Containers community. It has similar functionality but is independently developed.
Install Incus
# Add the Zabbly repository (officially recommended for Incus)
curl -fsSL https://pkgs.zabbly.com/key.asc | sudo gpg --dearmor -o /etc/apt/keyrings/zabbly.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/zabbly.gpg] https://pkgs.zabbly.com/incus/stable $(. /etc/os-release && echo "$VERSION_CODENAME") main" | sudo tee /etc/apt/sources.list.d/zabbly-incus-stable.list
sudo apt update
sudo apt install incus -yInitialize and Use
# Initialize
sudo incus admin init --minimal
# Add user to the incus-admin group
sudo usermod -aG incus-admin $USER
newgrp incus-admin
# Usage is similar to LXD
incus launch images:ubuntu/26.04 mycontainer
incus list
incus exec mycontainer -- bash
incus stop mycontainer
incus delete mycontainerMigrate from LXD to Incus
sudo incus admin migrate-lxdTechnology Comparison
| Feature | KVM/QEMU | VirtualBox | LXD/Incus |
|---|---|---|---|
| Virtualization type | Full virtualization | Full virtualization | System containers/VMs |
| Performance | Near-native | Good | Near-native |
| Isolation | Strong | Strong | Medium (containers) / Strong (VMs) |
| Resource usage | Medium | Higher | Low (containers) |
| Use cases | Servers, production | Desktop dev/testing | Dev environments, lightweight isolation |
Choose the right virtualization approach based on your use case: KVM for production servers, VirtualBox for desktop users, and LXD or Incus for development isolation environments.