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.

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

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 roadmap includes snapshots and backup, reusable templates and cloning, PCIe and GPU passthrough, CPU and storage performance tuning, and virtual machine migration. Planned lessons appear on this page before publication and become links when their lab validation and companion articles are complete.

Need help from an IT & cybersecurity partner?

InventiveHQ helps businesses secure, modernize, and run their technology. Let's talk about your goals.

Get in touch