Virtualization

KVM Virtualization Series: Build and Manage a Linux Hypervisor Lab

Follow the complete InventiveHQ KVM series from host installation through virtual machines, storage, networking, backups, performance tuning, GPU passthrough, and migration.

By InventiveHQ Team

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.

Advertisement

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.

EpisodePlanned lessonWhat it will prove
6KVM snapshots, backup, and restoreCrash consistency, external versus internal snapshots, disk copies, XML backup, and a tested restore
7Clone KVM VMs and build reusable templatesvirt-clone, cloud-init identity reset, unique MAC addresses, and repeatable guest provisioning
8KVM PCIe and GPU passthroughIOMMU groups, VFIO binding, host-device XML, reset behavior, and recovery planning
9KVM performance tuningCPU topology and pinning, memory backing, disk cache and I/O modes, and measurement before tuning
10Migrate KVM virtual machinesPrerequisites, shared versus copied storage, live migration checks, rollback, and post-migration validation
11Recover a broken KVM virtual machineDomain state, XML, disk maps, journal output, QEMU logs, and a repeatable start-failure diagnosis
12Repair a VM that will not bootRescue media, offline disk access, filesystem and configuration repair, and a validated return to service
13Give a KVM VM direct LAN access with a bridgeA Linux bridge, a guest LAN address, end-to-end validation, and remote-host access protection
14Build isolated KVM lab networksApplication and database segments, deterministic DHCP, routing policy, and proof of isolation
15Understand qcow2, raw disks, and storage poolsAllocation, conversion, pool and volume workflows, and measured format tradeoffs
16Build repeatable KVM VMs with cloud-initReusable templates, users, SSH keys, packages, networking, and deterministic first boot
17Automate KVM provisioning with Bash and virshValidated configuration, multiple predictable guests, idempotence, and safe cleanup
18Migrate a KVM VM to another hostOffline compatibility, storage and XML transfer, network parity, identity checks, and rollback
19Perform a live KVM migrationRunning-workload migration, continuity evidence, interruption measurement, and post-migration ownership
20Monitor and troubleshoot KVM performanceCorrelated domain, vCPU, block, network, host, and guest evidence before tuning
21Design a highly available KVM clusterThree-host quorum, fencing, storage, networks, failure domains, and recovery objectives
22Build a three-node KVM HA labConsistent libvirt resources, Corosync, Pacemaker, name resolution, time, and quorum
23Add a KVM virtual machine to PacemakerSingle ownership, placement, monitoring, planned moves, and maintenance behavior
24Configure fencing and prove split-brain protectionNested-host fencing, quorum-loss behavior, and proof that the old disk owner is stopped
25Test KVM host failure and automatic VM recoveryDetection, fencing, restart, measured outage, data validation, and node rejoin
26Remove the storage single point of failureRedundant storage, path and node failure tests, and documented remaining failure domains
27Operate and maintain a KVM HA clusterRolling 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

  1. Work in a disposable lab or approved maintenance window.
  2. Finish each lesson's validation section before continuing.
  3. Keep qemu:///system and qemu:///session resources separate in your mental model.
  4. Inventory domains, disks, pools, networks, and XML before making changes.
  5. Treat destroy, reset, storage deletion, and forced snapshot recovery as danger-zone operations.
  6. Back up persistent XML and irreplaceable data before destructive exercises.
  7. 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.

Frequently Asked Questions

Where should I start learning KVM and libvirt?

Start with Episode 1 to install and validate KVM, QEMU, and libvirt on Ubuntu. Continue in order so each lesson can reuse the host, guest, storage, and network resources created by the previous episodes.

Do I need dedicated server hardware for this KVM series?

No. You need a Linux system with hardware virtualization available, or a virtual machine whose outer hypervisor exposes nested virtualization. Use a disposable lab rather than a production host while learning destructive lifecycle, storage, and network operations.

Which Linux distribution does the series use?

The validated host runs Ubuntu 26.04 LTS and the tutorial guest runs Ubuntu 24.04 LTS. Most virsh and libvirt concepts apply to other Linux distributions, although package names, service units, security policy, and network configuration can differ.

Are the KVM commands and templates available on GitHub?

Yes. Each published episode links to versioned scripts, configuration templates, expected output, validation notes, and safe cleanup guidance in the InventiveHQ kvm-lab repository.

What topics will future KVM episodes cover?

The complete 27-episode roadmap progresses from recovery, networking, storage, and automation into offline and live migration, performance troubleshooting, and a seven-part three-node high-availability cluster arc with quorum, Pacemaker, fencing, automatic recovery, redundant storage, and maintenance.