Skip to content

Linux Quick Start

Boot a Debian 13 VM, log in, and grow it into a four-node fixed-IP lab by editing one YAML file.

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; sudo may then ask for your password. For CI and other unattended runs, see Automation.
  • In mainland China, add --mirror to the first barn up to download images from repo.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.

mkdir -p ~/barn-lab && cd ~/barn-lab
barn up -I d13

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:

ITEM     STATE    MESSAGE
network  planned  prepare 10.10.10.0/24
config   planned  create /home/alice/barn-lab/barn.yml
sudo: network (root-owned barn0 bridge)
Continue with this setup? [Y/n]

Barn then downloads and verifies the Debian image, boots the VM, and waits until SSH answers:

NAME  ADDRESS      STATE  MESSAGE
meta  10.10.10.10  ready  SSH ready: barn ssh meta
boot 1/1 nodes: 39s [DONE]

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

barn ssh

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:

barn status
barn exec meta -- df -h / /data

The image version in the status output depends on your active catalog.

NAME  ADDRESS      STATE    IMAGE                SPEC  ROOT
meta  10.10.10.10  running  d13@20261130.2678.1  1c2g  64 GiB
What you just createdValue
Node and addressmeta at 10.10.10.10
ImageDebian 13 (d13), same CPU architecture as the host
CPU and memory1 vCPU, 2 GiB
Disks64 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:

barn.yml
all:
  vars:
    admin_ip: 10.10.10.10
    vm_image: d13
  children:
    nodes:
      hosts:
        10.10.10.10: { nodename: meta }
        10.10.10.11: { nodename: node-1 }   # new
        10.10.10.12: { nodename: node-2 }   # new
        10.10.10.13: { nodename: node-3 }   # new

Preview the change, then apply it:

barn plan
barn up

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.ymlApply withResult
Add a nodebarn upCreates the new VM
CPU or memorybarn resize <node>Same VM, same disks, new size
Image or disk layoutbarn recreate <node>New root and non-persistent data disks; persistent data disks are kept
Remove a nodebarn 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 getRun
Two, three, or four nodesbarn init dual -I d13, barn init trio -I d13, or barn init full -I d13
Another OS for every nodebarn init -I el9 — see Images for the names
Another subnetbarn init -c 10.20.30.0/24 -I d13
amd64 guests on an Apple Silicon Macbarn 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:

barn.yml
all:
  vars:
    admin_ip: 10.10.10.10
    vm_image: d13
    vm_cpu: 1
    vm_mem: 2GiB
  children:
    nodes:
      hosts:
        10.10.10.10: { nodename: meta }

Check the file before booting anything:

barn validate
barn plan

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 stop      # shut down every node; all disks are kept
barn start     # boot them again
barn destroy   # delete the lab; asks you to type "destroy"

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.