Linux Quick Start
6 minute read
You will boot a Debian 13 VM, log in to it, then grow it into a four-node lab by editing one YAML file. Every command runs on your host as your normal user. For macOS guests, see macOS VMs.
Before you start
- Install Barn.
- Keep about 2 GiB of free memory per VM; each node defaults to 1 vCPU and 2 GiB.
- Use an interactive terminal. The first run prepares the host and asks once before changing anything;
sudomay then ask for your password. For CI and other unattended runs, see Automation. - In mainland China, add
--mirrorto the firstbarn upto download images fromrepo.pigsty.cc.
Start a VM
In 1.5.0, barn up selects Debian 13 for a new lab. With Barn 1.4.0, use barn up -I d13 on the first run to follow this tutorial.
On a fresh host, barn up first shows what it will set up and asks you to confirm. Only the rows that apply appear: dependencies (QEMU, UEFI firmware, OpenSSH), network (the lab subnet), config (the one-node barn.yml it writes here), and sudo (which of those steps need root). On a host that already has QEMU:
Barn then downloads and verifies the Debian image, boots the VM, and waits until SSH answers:
If 10.10.10.0/24 is already routed on your machine, Barn picks a free private /24 for this first lab instead; barn status shows the address it chose.
If barn up stops with an error, run barn doctor to check the host and barn logs meta to read the guest console, fix what they report, and run barn up again. It continues from where it stopped and leaves healthy VMs running. Troubleshooting covers the common cases.
Log in and look around
You are now user dba on meta, with key-based SSH and passwordless sudo. barn up also installed SSH aliases, so plain ssh meta works from any terminal. Type exit to return to the host.
From the host, list the lab and run commands inside a guest. Everything after -- runs in the VM:
The image version in the status output depends on your active catalog.
| What you just created | Value |
|---|---|
| Node and address | meta at 10.10.10.10 |
| Image | Debian 13 (d13), same CPU architecture as the host |
| CPU and memory | 1 vCPU, 2 GiB |
| Disks | 64 GiB root disk, 128 GiB data disk mounted at /data |
Both disks are thin-provisioned, so they take host space only as the guest writes data. Treat /data as test storage, not a home for files you care about: if barn up finds its filesystem corrupted while recovering a node, it reformats it. Storage and Access shows what each command keeps.
The lab’s state lives in ~/.barn, not in ~/barn-lab, so barn status, barn ssh, and barn stop work from any directory. Each user has one Linux lab at a time; barn up in another directory without an inventory resumes it rather than starting a second one (why).
Grow it into a four-node lab
Open ~/barn-lab/barn.yml, which the first run wrote, and add three hosts under nodes. Use addresses in the same /24 as meta:
Preview the change, then apply it:
barn plan reports create: node-1, node-2, node-3, and barn up creates the three VMs without restarting meta. All four nodes now reach each other at these addresses, which is what a database cluster or an Ansible playbook expects. At the default size, the lab uses 8 GiB of guest memory.
Every later change follows the same loop: edit barn.yml, run barn plan, then apply. The command that applies it depends on what changed, because barn up never replaces an existing VM’s disks:
Change in barn.yml | Apply with | Result |
|---|---|---|
| Add a node | barn up | Creates the new VM |
| CPU or memory | barn resize <node> | Same VM, same disks, new size |
| Image or disk layout | barn recreate <node> | New root and non-persistent data disks; persistent data disks are kept |
| Remove a node | barn destroy <node> | Deletes the VM; until then it stays on disk |
Pick the image, size, or subnet
The defaults suit a first run. To start from something else, generate barn.yml yourself in an empty directory before the first barn up:
| To get | Run |
|---|---|
| Two, three, or four nodes | barn init dual -I d13, barn init trio -I d13, or barn init full -I d13 |
| Another OS for every node | barn init -I el9 — see Images for the names |
| Another subnet | barn init -c 10.20.30.0/24 -I d13 |
| amd64 guests on an Apple Silicon Mac | barn init -A amd64 -I d13 — emulated, so slower |
The options combine, for example barn init full -I el9. barn init writes the result to barn.yml; edit it for anything else, such as the size of every node:
Check the file before booting anything:
validate and plan need neither QEMU nor the host network, so you can check an inventory on any machine. Linux Configuration lists every variable, and image and architecture settings explains how -I and -A interact with the file.
Stop, start, and clean up
barn destroy deletes the VMs with their root disks and non-persistent data disks, the deployment state, and the SSH aliases it installed. It keeps persistent data disks, the deployment’s SSH keys, downloaded images, and the host network, so running barn up in ~/barn-lab later rebuilds the lab from barn.yml without downloading again. To remove everything, see Uninstall.
Next steps
- Daily Operations — Restart nodes, read logs, and apply inventory changes safely.
- Storage and Access — Add persistent disks, copy files, and reach services in the guest.
- Images — Run Ubuntu, Rocky Linux, other Debian releases, or your own
qcow2. - Automation — Drive Barn from scripts, CI, or Pigsty.