Lab 0D — Ops cheatsheet

Updated

July 30, 2026

Lab 0D — Ops cheatsheet (single-server lab)

Quick reference while studying. Details live in Labs 0A–0C.

Daily

# host — libvirt (default path)
virsh list --all
virsh start nixlab
virsh snapshot-list nixlab

# host — Incus (if that is your primary)
incus list
incus start nixlab
incus info nixlab

# network (libvirt NAT example)
virsh net-dhcp-leases default

# ssh
ssh nixlab
ssh deploy-a

Snapshots / restore points

# libvirt
virsh snapshot-create-as nixlab "label" "notes"
virsh snapshot-revert nixlab "label"
virsh snapshot-delete nixlab "label"

# Incus (publish image / snapshot features — see `incus snapshot` help for your version)
incus snapshot create nixlab pre-change
incus snapshot restore nixlab pre-change

Disk pressure

df -h / /nix /var/lib/libvirt/images
nix store gc          # careful: know generations
nix store optimise
du -sh /var/lib/libvirt/images/*

Guest rebuild (from host flake)

cd ~/src/nix-config
nix build .#nixosConfigurations.nixlab.config.system.build.toplevel
nixos-rebuild switch --flake .#nixlab --target-host USER@nixlab --use-remote-sudo

When the Elitebook sweats

  1. Shut down deploy-a
  2. Set max-jobs = 1
  3. Close browser
  4. Prefer substitutes over local compiles when possible
  5. Pause nested experiments

Drift control

cd ~/src/nix-config
git status          # uncommitted host/guest edits?
git diff
# After a live debug: encode the fix in *.nix, rebuild, then commit

Emergency

Problem Action
Host unresponsive REISUB if enabled; else hard power; check disk full
Guest won’t boot libvirt/Incus snapshot or NixOS generation from boot menu
Locked out of guest virt-manager / virsh console / incus console
Store full Delete old snapshots; nix store gc with eyes open
“Fixed it in the shell, lost it on reboot” That was drift—put it in the flake

Inventory template (fill once)

Host hostname: ________
Host IP: ________
nixlab IP: ________
deploy-a IP: ________
Flake path: ________
Lab SSH key: ________
Age key backup: ________
Wipe-allowed disks: ________