Chapter 1: Build Your Practice Lab
Prepare the host and LXD
Phases 01 and 02: update the Ubuntu host, check it can run virtual machines, install LXD from the long-term-support track, and open the LXD web UI in your browser.
Phase 01 · Prepare the Ubuntu host (~15 min)
- Confirm hardware virtualisation works.
- Install LXD 5.21 LTS and hold it at that version.
- Initialise LXD with a ZFS storage pool.
Host: update the system and check virtualisation
sudo apt update && sudo apt full-upgrade -y
sudo apt install -y cpu-checker nftables
kvm-ok
# Expected: "KVM acceleration can be used"Host: install LXD 5.21 LTS and hold it
Install from the 5.21 LTS track (supported until June 2029), hold it so it cannot jump to a new version without you, and add yourself to the lxd group.
snap list lxd 2>/dev/null || sudo snap install lxd --channel=5.21/stable
sudo snap refresh lxd --channel=5.21/stable # no-op if already on 5.21/stable
sudo snap refresh --hold lxd # stop automatic updates (undo: --unhold)
sudo usermod -aG lxd "$USER"
newgrp lxd # or log out and back in
lxc version # Client/Server version: 5.21.x LTSHost: run the first-time setup
lxd initAnswer the questions like this:
| Question | Answer | Why |
|---|---|---|
| Would you like to use LXD clustering? | no | One machine |
| Do you want to configure a new storage pool? | yes | |
| Name of the new storage pool | default | |
| Name of the storage backend | zfs | Instant snapshots, thin disks |
| Create a new ZFS pool? | yes | |
| Use an existing empty block device? | no | Uses a file on your disk; simplest |
| Size in GiB of the new loop device | 200 | Sparse file: grows only as used. The lab used about 2 GiB; 100 is plenty if space is tight. |
| Connect to a MAAS server? | no | |
| Create a new local network bridge? | no | You create the lab network yourself next |
| Configure LXD to use an existing bridge or host interface? | no | |
| Would you like the LXD server to be available over the network? | yes | Needed for the web UI |
| Address to bind LXD to | <HOST_LAN_IP> | Only the host's LAN address, never the lab network |
| Port to bind LXD to | 8443 | |
| Would you like stale cached images to be updated automatically? | yes | |
| Print a YAML "lxd init" preseed? | no |
Phase 02 · Open the LXD UI (~5 min)
- Log in to the LXD web UI with a client certificate.
LXD UI: open the address
From any browser on your local network, go to https://<HOST_LAN_IP>:8443. Accept the self-signed certificate warning (Advanced → Proceed).
LXD UI: create a certificate
Choose Create a new certificate and follow the wizard: Generate → copy the command it shows → run it on the host → Download .pfx → import it into your browser → restart the browser.
lxc config trust add --name lxd-ui
# newer LXD 6.x shows: lxc auth identity create tls/lxd-ui --group adminsLXD UI: log in
Reload the page and pick the certificate when asked. You should land on Instances.