Learn Rocky Linux - Virtualization with KVM/libvirt
Episode 19 of 23

Learn Rocky Linux - Virtualization with KVM/libvirt

This episode covers KVM virtualization on Rocky Linux: installing KVM/QEMU and libvirt, provisioning VMs with virt-install, managing with virsh and virt-manager, storage pools and volumes, default versus bridged networking, and snapshots.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

In the previous episode 18, you learned to package an OS as an image. Now it's time for the capability that underpins the modern data center: virtualization — running many operating systems on a single physical machine with full isolation. Rocky Linux uses KVM (Kernel-based Virtual Machine) as its hypervisor, with QEMU as the emulator and libvirt as the management layer. KVM exploits CPU virtualization extensions, QEMU provides device emulation, and libvirt supplies the API and tools to manage it all.

Installing KVM and Libvirt

Installing the Virtualization Group

Installing the virt group
dnf5 group install "Virtualization Host"
Checking KVM support
grep -cE 'vmx|svm' /proc/cpuinfo

An output greater than zero means the CPU supports virtualization (Intel VT-x vmx or AMD-V svm). Without this, KVM cannot work.

Enabling Services

Enabling libvirtd
systemctl enable --now libvirtd
Verifying the hypervisor
virsh version
virsh list --all

Adding a User to the Libvirt Group

Adding a user to the libvirt group
usermod -aG libvirt arman

Provisioning with Virt-Install

Creating Your First VM

Creating a VM from an ISO
virt-install \
  --name rocky10-vm \
  --memory 2048 \
  --vcpus 2 \
  --disk size=20 \
  --os-variant rocky10.0 \
  --network default \
  --cdrom /iso/Rocky-10.2.iso \
  --graphics none \
  --console pty,target_type=serial
Viewing existing VMs
virsh list --all

Every option matters: --memory and --vcpus determine resources, --disk size=20 creates a 20 GB disk (from the storage pool we'll discuss shortly), and --network default connects the VM to libvirt's default network.

Variables and Hostname

Provisioning with kickstart
virt-install \
  --name web01 \
  --memory 2048 --vcpus 2 \
  --disk size=20 \
  --os-variant rocky10.0 \
  --network default \
  --extra-args "inst.ks=http://192.168.1.10/rocky.ks"

Managing with Virsh and Virt-Manager

Basic Virsh Operations

Controlling VMs
virsh start rocky10-vm
virsh shutdown rocky10-vm
virsh destroy rocky10-vm
virsh reboot rocky10-vm
Info and autostart
virsh dominfo rocky10-vm
virsh autostart rocky10-vm

virsh destroy force-kills (like pulling the power cord), while shutdown performs a clean shutdown. autostart makes a VM start automatically when the host boots.

Virt-Manager for GUI

Installing virt-manager
dnf5 install virt-manager
Opening the console
virt-manager

Storage Pools and Volumes

The Pool Concept

A storage pool is the central location where VM disks (volumes) are stored. Libvirt provides a default pool at /var/lib/libvirt/images:

Viewing pools
virsh pool-list
virsh vol-list default

Creating Pools and Volumes

Creating a pool from a partition
virsh pool-define-as vmpool fs - - /data/vms /dev/vgdata
virsh pool-build vmpool
virsh pool-start vmpool
virsh pool-autostart vmpool
Creating a volume
virsh vol-create-as vmpool web02.qcow2 30G --format qcow2

Virtual Networking

Default Network vs Bridge

Libvirt provides a default network that gives VMs NAT access to the outside network. For direct access to the physical network — the pattern discussed in episode 9 — use bridged networking:

Viewing virtual networks
virsh net-list
virsh net-dumpxml default
Attaching a VM to bridge br0
virsh attach-interface --domain rocky10-vm \
  --type bridge --source br0 --persistent

Creating a Custom Network

Custom network definition
cat > /tmp/net-isolated.xml <<'EOF'
<network>
  <name>isolated</name>
  <forward mode='isolated'/>
</network>
EOF
Activating the network
virsh net-define /tmp/net-isolated.xml
virsh net-start isolated
virsh net-autostart isolated

An isolated network connects VMs to each other but gives no external access — ideal for internal security segments.

Snapshot

Creating and Reverting Snapshots

Creating a snapshot
virsh snapshot-create-as rocky10-vm clean-install
Viewing snapshots
virsh snapshot-list rocky10-vm
Reverting to a snapshot
virsh snapshot-revert rocky10-vm clean-install
Deleting a snapshot
virsh snapshot-delete rocky10-vm clean-install

Success

The combination of a managed storage pool, proper bridged networking, and routine snapshots before major changes is an operational pattern that keeps virtualization safe and recoverable.

Closing

In this episode 19, you mastered KVM virtualization on Rocky Linux: installing the Virtualization Host group and libvirtd, provisioning VMs with virt-install (including Kickstart integration), managing with virsh and virt-manager, storage pools and qcow2 volumes, default versus bridged and custom networking, and snapshots for quick rollback.

Key takeaways:

  • Make sure the CPU supports virtualization (vmx/svm) before installing KVM.
  • Provisioning with virt-install and Kickstart makes VM creation fully automated.
  • virsh is the primary control; autostart starts VMs when the host boots.
  • Manage storage through pools and volumes; qcow2 supports snapshots and saves space.
  • Choose NAT for isolation and bridge for direct network access.
  • Snapshot before major changes — the undo button for an entire VM.

In the next episode 20, we will discuss containerization with Podman, Buildah, and Skopeo — the daemonless container engine, rootless containers, building images with Buildah, inspecting with Skopeo, and systemd integration through Quadlet. Virtualization is mastered; now it's time for the lighter, faster workload format!

Learn Rocky Linux - Virtualization with KVM/libvirt | Learn Rocky Linux