Virtual machines with KVM and libvirt
You turn Linux into a virtualisation host, build VMs with virsh and virt-install, and manage their disks, networks and snapshots.
Level 201 · 16 lessons · 15 practice labs
Lessons
Basics
- What virtualisation is: hypervisor and guest
- KVM, QEMU and libvirt: who does what
- Checking hardware support
- Short task: get a server ready for virtualisation
Virtual machines
- Installing a VM with virt-install
- Life cycle with virsh: start, stop, autostart
- Domain XML: reading and editing a machine's definition
- Getting to the console: serial and VNC
- Short task: build two small VMs that start at boot
Disks, networks and snapshots
- Disk images: qcow2, raw and qemu-img
- Storage pools
- Virtual networks: NAT and bridge
- Snapshots and clones
- Short task: take a snapshot, upgrade, and roll back if needed
Wrap-up
- Ready-made images and first-boot configuration
- Capstone: build a three-VM test environment for the team
Practice labs
- Verify a host is ready for virtualisation: Check the CPU extensions, the KVM module and the libvirt service and write down which component is missing.
- List virtual machines and their resources: Tabulate the state, CPU and memory settings and disk file of every virtual machine.
- Find the faulty device in a VM definition: Inspect the XML definition of a VM that will not start and fix the missing disk path and wrong network name.
- Create a virtual machine from a ready image: Define a VM with two CPUs and two gigabytes of memory from a cloud image and connect to its console.
- Configure a VM automatically at first boot: Use cloud-init data to set the host name, user and SSH key at first boot and log in with the key.
- Arrange VM start-up and shutdown behaviour: Start VMs in the right order at host boot and configure and test a graceful guest shutdown when the host goes down.
- Add a disk to a running VM: Create a new qcow2 disk, attach it persistently to a running VM and verify it appears inside the guest.
- Grow a virtual disk and the file system inside: Grow a virtual disk about to fill, then extend the partition and file system in the guest.
- Inspect and merge a disk image chain: Show the chain of disks derived from a shared base and merge one VM's layer with the base into a standalone image.
- Create a NAT network for VMs: Define a new virtual network, connect a VM and find the address it received in the lease list.
- Put a VM on the local network through a bridge: Set up a bridge interface on the host, connect the VM to it and show it is reachable from another lab machine.
- Build a two-tier isolated virtual network: Place the web VM on an outward network and the database VM on an isolated one, and prove only the web VM reaches the database.
- Snapshot before a change and revert: Snapshot a VM, remove a package, revert and verify the package is back.
- Produce a cleaned clone from a template: Clone a VM and show the copy has a fresh machine ID, SSH host keys and network address.
- Take a consistent backup of a running VM: Take an external snapshot with the guest agent freezing the file system, copy the disk, merge the chain and boot a new VM from the backup.
About this course
You turn Linux into a virtualisation host, build VMs with virsh and virt-install, and manage their disks, networks and snapshots.
What you will learn
- Basics
- Virtual machines
- Disks, networks and snapshots
- Wrap-up
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.