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.
Latest KVM video lessons
These walkthroughs continue the same retained lab from the published lessons above. Their versioned commands and validation files are linked from each video description.
Episode 6: KVM snapshots, backup, and tested restore
Create an atomic, quiesced external snapshot across two KVM disks, turn the frozen bases into standalone backups, test an isolated restore, and merge the live overlays safely.
Episode 7: Clone KVM VMs without duplicating identity
Clone a guest while replacing its UUID, MAC addresses, hostname, machine ID, SSH host keys, cloud-init state, network identity, and disk paths.
Episode 8: KVM GPU passthrough readiness
Audit CPU virtualization, firmware and kernel IOMMU state, PCIe ownership, isolation groups, and libvirt device mapping before attempting VFIO detach.
Episode 9: Measurable and reversible KVM performance tuning
Capture CPU, memory, and block-device evidence, benchmark a bounded test file, apply a live disk limit, and verify recovery after rolling the change back.
Episode 10: Live-migrate a KVM VM with non-shared storage
Move a running guest between hosts that do not share a storage backend, copying the disk as part of the migration and validating continuity on the far side.
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 |
| 11 | Recover a broken KVM virtual machine | Domain state, XML, disk maps, journal output, QEMU logs, and a repeatable start-failure diagnosis |
| 12 | Repair a VM that will not boot | Rescue media, offline disk access, filesystem and configuration repair, and a validated return to service |
| 13 | Give a KVM VM direct LAN access with a bridge | A Linux bridge, a guest LAN address, end-to-end validation, and remote-host access protection |
| 14 | Build isolated KVM lab networks | Application and database segments, deterministic DHCP, routing policy, and proof of isolation |
| 15 | Understand qcow2, raw disks, and storage pools | Allocation, conversion, pool and volume workflows, and measured format tradeoffs |
| 16 | Build repeatable KVM VMs with cloud-init | Reusable templates, users, SSH keys, packages, networking, and deterministic first boot |
| 17 | Automate KVM provisioning with Bash and virsh | Validated configuration, multiple predictable guests, idempotence, and safe cleanup |
| 18 | Migrate a KVM VM to another host | Offline compatibility, storage and XML transfer, network parity, identity checks, and rollback |
| 19 | Perform a live KVM migration | Running-workload migration, continuity evidence, interruption measurement, and post-migration ownership |
| 20 | Monitor and troubleshoot KVM performance | Correlated domain, vCPU, block, network, host, and guest evidence before tuning |
| 21 | Design a highly available KVM cluster | Three-host quorum, fencing, storage, networks, failure domains, and recovery objectives |
| 22 | Build a three-node KVM HA lab | Consistent libvirt resources, Corosync, Pacemaker, name resolution, time, and quorum |
| 23 | Add a KVM virtual machine to Pacemaker | Single ownership, placement, monitoring, planned moves, and maintenance behavior |
| 24 | Configure fencing and prove split-brain protection | Nested-host fencing, quorum-loss behavior, and proof that the old disk owner is stopped |
| 25 | Test KVM host failure and automatic VM recovery | Detection, fencing, restart, measured outage, data validation, and node rejoin |
| 26 | Remove the storage single point of failure | Redundant storage, path and node failure tests, and documented remaining failure domains |
| 27 | Operate and maintain a KVM HA cluster | Rolling maintenance, standby mode, host replacement, failure cleanup, and health monitoring |
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.