This is the starting point for the InventiveHQ KVM and libvirt lab series. The goal is not to collect disconnected command snippets. We build one working virtualization environment in layers, verify every layer from the host and guest, and retain the lab state so the next lesson starts from something real.
The series begins with an empty Ubuntu host, creates an Ubuntu guest, then adds administration, storage, and networking. Later lessons will use those same resources for backups, cloning, passthrough, performance tuning, and migration.
Series lab verified July 2026 · Ubuntu 26.04 LTS host · Ubuntu 24.04 LTS guest · libvirt 12.0.0 · QEMU 10.2.1
Use the command builder while following the lessons to construct local, session, or remote virsh commands and review lifecycle and data-loss warnings before copying them.
Published KVM lessons
1. Install KVM on Ubuntu
Turn a clean Ubuntu server into a validated KVM host. This lesson checks hardware virtualization, installs QEMU and libvirt, configures administrator access, starts the default private network, and verifies the qemu:///system connection.
Finished state: a working host with KVM acceleration, libvirt, virsh, virt-install, and private NAT networking.
2. Create an Ubuntu VM with virt-install and cloud-init
Download an Ubuntu cloud image, create a qcow2 overlay, build a NoCloud seed, and import the first guest with SSH, QEMU guest-agent, and serial-console access.
Finished state: demo-ubuntu01, initially sized at 2 vCPUs and 2 GiB RAM with headroom for live changes.
3. Manage KVM virtual machines with virsh
Inventory the guest, distinguish live from persistent configuration, change CPU and memory, verify the result inside Ubuntu, use the serial recovery path, and understand the difference between graceful and destructive lifecycle operations.
Finished state: the guest is running with 4 vCPUs and 4 GiB RAM and has a documented recovery path.
4. Manage KVM storage pools, volumes, and disk expansion
Create a persistent directory storage pool, allocate a qcow2 volume, attach it to the running guest, create and mount an ext4 filesystem, expand the active disk safely, and grow the filesystem online.
Finished state: an autostarting tutorial-data pool and an attached 8 GiB demo-data01.qcow2 data disk mounted at /srv/demo-data.
5. Create a custom KVM NAT network with static DHCP
Define a custom libvirt network, reserve a predictable address for a known MAC, hot-plug a second virtio NIC, configure it with Netplan, and use route metrics to preserve the guest's preferred default path.
Finished state: an autostarting tutorial-net network and a second guest interface at 192.168.150.10.
Future KVM article roadmap
These lessons are planned. They will become links only after their commands are validated in the retained series lab, so this index never intentionally sends readers to an unfinished article.
| Episode | Planned lesson | What it will prove |
|---|---|---|
| 6 | KVM snapshots, backup, and restore | Crash consistency, external versus internal snapshots, disk copies, XML backup, and a tested restore |
| 7 | Clone KVM VMs and build reusable templates | virt-clone, cloud-init identity reset, unique MAC addresses, and repeatable guest provisioning |
| 8 | KVM PCIe and GPU passthrough | IOMMU groups, VFIO binding, host-device XML, reset behavior, and recovery planning |
| 9 | KVM performance tuning | CPU topology and pinning, memory backing, disk cache and I/O modes, and measurement before tuning |
| 10 | Migrate KVM virtual machines | Prerequisites, shared versus copied storage, live migration checks, rollback, and post-migration validation |
Lab topology after Episode 5
dell01 (physical KVM host)
└── ihq-kvm-ep01 (Ubuntu KVM teaching host)
├── default network: 192.168.122.0/24
├── tutorial-net: 192.168.150.0/24
├── images storage pool
├── tutorial-data storage pool
└── demo-ubuntu01 (Ubuntu guest)
├── enp1s0: default network
├── enp8s0: 192.168.150.10 on tutorial-net
├── vda: system disk
└── vdb: 8 GiB data volume mounted at /srv/demo-data
The observed addresses are lab values, not values to copy into another environment. Query your own leases, devices, and routes.
How to use the series safely
- Work in a disposable lab or approved maintenance window.
- Finish each lesson's validation section before continuing.
- Keep
qemu:///systemandqemu:///sessionresources separate in your mental model. - Inventory domains, disks, pools, networks, and XML before making changes.
- Treat
destroy,reset, storage deletion, and forced snapshot recovery as danger-zone operations. - Back up persistent XML and irreplaceable data before destructive exercises.
- Replace example addresses, public keys, disk paths, and interface names with values discovered in your environment.
Reproducible lab files
Versioned scripts and templates live in the InventiveHQ KVM lab repository. Each episode uses a fixed release tag in its article and video description so later repository changes do not silently alter the tutorial someone is following.
Start with Episode 1: Install KVM on Ubuntu, or continue to Episode 4: KVM storage pools and volumes if your retained guest already matches the Episode 3 end state.