Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Barn documentation

Install Barn 1.5.0, start a Debian 13 lab and use the matching command and image references.

New Linux labs in Barn 1.5.0 default to Debian 13. Changes since 1.4.0

Start here

  • Install Barn 1.5.0 — Use Homebrew, the installer or the signed release checksums to verify a download.
  • Linux Quick Start — Boot one Debian 13 VM, log in, and expand to a four-node lab.
  • Native macOS VMs — Create a macOS 27 guest on Apple Silicon, open its desktop, or connect over SSH.

Find every command, option, and example in the Command Reference. Its version baseline identifies additions across 1.1.0–1.5.0. For a Pigsty lab, follow Use Barn with Pigsty.

Common tasks

  • Daily operations — Start, stop, inspect, plan changes, synchronize guest clocks, and recreate Linux lab nodes.
  • Storage and service access — Add persistent data disks, mount Virtio-9p host shares, and reach guest ports.
  • Image selection — Choose from 9 Linux distribution families, update the catalog, or import custom qcow2 images.
  • Scripting and automation — Drive Barn from CI or shell scripts with --yes, --json, and structured exit codes.
  • Troubleshooting — Diagnose host readiness, networking, SSH, and interrupted lifecycle runs with barn doctor.
  • What’s new in 1.5.0 — Debian 13 defaults, filename-based image repositories and official signatures.

Why Barn

Barn (Bootstrap And Run Nodes) runs local virtual machines for development and testing. It does two jobs with one CLI:

  • Linux labs on macOS or Linux. Describe your machines — names, fixed IP addresses, OS image, CPU, memory, disks — in one Ansible inventory. barn up boots them with QEMU and reads each guest’s readiness marker over SSH.
  • macOS VMs on Apple Silicon. barn mac up creates a disposable macOS machine with an admin account, SSH, a desktop window, shared folders, and clipboard sharing.

Barn is open source under Apache-2.0 and built by the Pigsty team; it does not depend on Pigsty.

Software that runs on several machines has to be tested on several machines. A PostgreSQL cluster with Patroni, an etcd quorum, a load balancer with a floating VIP, or an Ansible playbook all expect each node to have its own kernel, disks, and an IP address that its peers can reach across reboots. Containers share the host kernel. Forwarding a port gives the host access to one guest service. A private subnet also lets guests connect directly to one another at fixed addresses.

Barn gives each node a real VM on a private /24, at the address your inventory names. Because that inventory is ordinary Ansible YAML, the file that builds the lab is the same file your playbooks run against — Pigsty uses it unchanged. When you are done, barn destroy removes the VMs and keeps any persistent data disks. A later barn up rebuilds the VMs from the same file.

What you get in practice:

  • Hardware acceleration. Same-architecture Linux guests normally use HVF on macOS and KVM on Linux. Cross-architecture guests and Rocky Linux 8 arm64 on Apple Silicon use QEMU emulation. Runtime policy
  • Verified images. Ubuntu, Debian, and Rocky Linux images come from a signed catalog. Barn checks the signature and each file’s digest before a VM boots from it.
  • No surprise deletions. barn plan shows what barn up will do. Removing a node from the file does not delete its VM, and changing an image does not silently rebuild a disk; removing or replacing a VM takes an explicit destroy, purge or recreate.
  • Scriptable. Lifecycle and inspection commands accept --json, write progress to stderr, and return documented exit codes, so CI jobs and AI agents can drive it without parsing text.

How a Linux lab works

flowchart LR
  inv["barn.yml<br/>Ansible inventory"] -->|barn plan / barn up| barn["barn"]
  barn --> meta["meta<br/>10.10.10.10"]
  barn --> n1["node-1<br/>10.10.10.11"]
  barn --> n2["node-2<br/>10.10.10.12"]
  meta --- lan(("lab subnet<br/>10.10.10.0/24"))
  n1 --- lan
  n2 --- lan
  host["your host"] --- lan
  • Desired state is the inventory. barn plan compares barn.yml with what is running; barn up creates missing nodes and starts stopped ones. Changes that would replace a disk wait for an explicit barn recreate.
  • Each node has two network interfaces. The management interface uses QEMU’s built-in NAT for internet access and a loopback SSH port, so no firewall rules are needed. The lab interface carries the fixed address on a host bridge (socket_vmnet on macOS, barn0 on Linux), so nodes and your host reach each other directly. VMs run as your user. Host package installation, network configuration and publishing names to /etc/hosts can require sudo.
  • Disks are cheap copies. Each root disk is a thin copy-on-write overlay on a shared, read-only base image, and the default inventory adds a separate data disk at /data. A new node costs almost no space until it writes data.
  • State lives in ~/.barn. Each user has one lab, stored under BARN_HOME (default ~/.barn), so barn status and barn ssh work from any directory.

macOS VMs are managed separately: they use Apple’s Virtualization framework, each VM gets its own NAT subnet, and their state lives under $BARN_HOME/mac (default ~/.barn/mac). The design page explains the reasoning behind each of these choices.

Browse by section

1 - Guides

Install Barn, boot your first Linux or macOS VM, then run, change, and script your lab.

Task-by-task guides, roughly in the order you will need them. Linux labs and macOS VMs can run side by side on the same Apple Silicon Mac; each is managed on its own.

Get started

  • Install Barn — Homebrew, installer script, or DEB/RPM; host requirements and upgrades.
  • Linux Quick Start — Boot a Debian 13 VM, log in, and grow it into a four-node fixed-IP lab.
  • macOS VMs — Create a macOS machine on Apple Silicon with a desktop, SSH, shared folders, and clipboard.

Run a Linux lab

  • Daily Operations — Check status, stop and start nodes, and apply inventory changes safely.
  • Storage and Access — Add data disks that survive rebuilds, copy files, and reach guest services.
  • Images — Choose Ubuntu, Debian, or Rocky Linux, use the China mirror, or bring your own qcow2.
  • Automation — Drive Barn from scripts, CI, or AI agents, and pair it with Pigsty.
  • Use Barn with an AI agent — Give a coding agent the Barn skill and specify the lab you need.

Fix, build, and remove

  • Troubleshooting — Symptoms, checks, and fixes for setup, networking, SSH, and images.
  • Build from Source — Build the CLI and Barn.app yourself to try unreleased changes.
  • Uninstall — Remove VMs, cached images, the host network, and Barn itself.

1.1 - Download and Install Barn

Install Barn on macOS or Linux, check host requirements, and upgrade an existing installation.

Barn is one command-line tool, barn, with a small companion binary for editing /etc/hosts. On Apple Silicon it also ships Barn.app, the native component that runs macOS guests. Install it as your normal user: Barn asks for sudo itself when a host setup step needs it.

Install Barn 1.5.0 with Homebrew or the installer, or choose an archive or package below. Run barn version to verify the installed version. Build from source

Install

Install with Homebrew. This also installs QEMU, which Linux guests need:

brew install pgsty/infra/barn
barn version

On Apple Silicon the formula also installs Barn.app, signed with Developer ID and notarized by Apple; the CLI finds it automatically. To run macOS guests, continue with barn mac doctor in the macOS guide. Intel Macs run Linux guests only.

The installer script picks the amd64 or arm64 archive, verifies its SHA-256 against the release’s checksums.txt, and installs into ~/.local/bin without sudo:

curl -fLO https://github.com/pgsty/barn/releases/latest/download/install.sh
bash install.sh
export PATH="$HOME/.local/bin:$PATH"
barn version

Add the export PATH=… line to ~/.bashrc or ~/.zshrc. The script works on macOS too if you prefer not to use Homebrew. It installs versioned copies under ~/.local/bin/.barn-releases/; leave that layout as it is.

There is nothing else to set up now. The first interactive barn up checks for QEMU, firmware, and the host network, shows what it will install, and asks once before doing it. For a script or CI job, prepare the host up front with barn setup --yes, or preview the changes with barn setup --dry-run (details).

System requirements

GuestHostNeeds
LinuxmacOS on Apple Silicon or IntelQEMU 8.2.1 or later (HVF acceleration)
LinuxLinux on amd64 or arm64QEMU 6.2 or later, a usable /dev/kvm, and NetworkManager or systemd-networkd
macOS 27Apple Silicon running macOS 27 or later, with a logged-in desktop sessionBarn.app; no QEMU

A Linux VM defaults to 1 vCPU, 2 GiB of memory, a 64 GiB root disk, and a 128 GiB data disk. Disks are thin-provisioned and grow only as the guest writes data.

A new macOS VM defaults to 4 vCPUs and 8 GiB of memory. Its disk inherits the prepared base’s capacity. The first base defaults to 100 GiB. Allow about 65 GiB of free space to download Apple’s macOS 27.2.1 restore image and install the base. Later VMs share the base’s disk blocks through APFS cloning. See macOS requirements.

Download Barn 1.5.0

Released on 2026-12-03. Pick your host operating system and CPU architecture:

Host OSArchitectureArchiveDebian / UbuntuRHEL / Fedora
macOSApple Silicon (arm64)tar.gz——
macOSIntel (amd64)tar.gz——
Linuxx86-64 (amd64)tar.gzDEBRPM
LinuxARM64 (arm64)tar.gzDEBRPM

SHA-256 checksums · Detached signature · Release metadata · Installer script

Every archive and package has a matching .spdx.json software bill of materials on the GitHub release page.

FileWhat it isShipped in
barnThe CLI for Linux labs and macOS VMsEvery archive and package
barn-hosts-helperCompanion that edits /etc/hosts for barn hosts installEvery archive and package, paired with its CLI
Barn.appNative runner and desktop window for macOS guestsThe macOS arm64 archive and the Apple Silicon Homebrew install

Other installation methods

Linux packages

The DEB and RPM packages pull in QEMU, UEFI firmware, and OpenSSH as dependencies. On ARM64 hosts, replace amd64 with arm64:

Debian / Ubuntu
barn_release=https://github.com/pgsty/barn/releases/download/v1.5.0
curl -fLO "$barn_release/barn_1.5.0_linux_amd64.deb"
curl -fLO "$barn_release/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo apt install ./barn_1.5.0_linux_amd64.deb
barn version
RHEL / Fedora
barn_release=https://github.com/pgsty/barn/releases/download/v1.5.0
curl -fLO "$barn_release/barn_1.5.0_linux_amd64.rpm"
curl -fLO "$barn_release/checksums.txt"
sha256sum --check --ignore-missing checksums.txt
sudo dnf install ./barn_1.5.0_linux_amd64.rpm
barn version

Manual archives

Download barn_1.5.0_<os>_<arch>.tar.gz and checksums.txt, and verify the digest before extracting:

barn_release=https://github.com/pgsty/barn/releases/download/v1.5.0
curl -fLO "$barn_release/barn_1.5.0_darwin_arm64.tar.gz"
curl -fLO "$barn_release/checksums.txt"
shasum -a 256 -c checksums.txt --ignore-missing

Extract the archive and add its bin/ directory to PATH. Keep the files together: the CLI checks the helper’s embedded SHA-256 before running it, and looks for bin/Barn.app next to itself.

Build from source

To try unreleased changes or build Barn.app yourself, see Build from Source.

Upgrade Barn

In 1.5.0, the release owner signs checksums.txt. Use the public key from a trusted source to verify checksums.txt.sig before checking individual downloads. Verification command

When upgrading from 1.3.0 or earlier, update the CLI and check barn version before running barn update. Catalog 2026112601 uses a new Minisign key. Version 1.3.0 rejects that signature and keeps its previously active catalog.

Upgrade through the channel you installed with. With Homebrew:

brew update
brew upgrade pgsty/infra/barn
command -v barn
barn version

On Linux, run install.sh again or install the newer DEB/RPM package, then check command -v barn and barn version. If you have both a ~/.local/bin copy and a packaged one, PATH decides which runs; upgrade that one or remove the other.

Upgrades keep everything under ~/.barn: VM disks, SSH keys, state, and configuration. Before upgrading on a Mac, stop running macOS VMs (barn mac stop NAME), because the CLI, helper, and Barn.app are replaced together.

Some releases change defaults. Check these before running barn up on an existing lab, and run barn plan to see the effect:

Upgrading fromWhat changedTo keep the old behavior
1.4.0 to 1.5.0New labs default to Debian 13. Existing labs retain their saved image default for new peers.Use barn init -I u24 to start a new Ubuntu 24.04 lab.
1.2.xvm_image: rocky now means Rocky Linux 10 (el10) and vm_image: ubuntu means Ubuntu 26.04 (u26)Set vm_image: el9 or vm_image: u24
1.1.xNew nodes default to 1 vCPU / 2 GiB instead of 2 vCPU / 4 GiB; existing VMs keep their size until you change itSet vm_cpu: 2 and vm_mem: 4GiB

Upgrading Barn never changes the OS inside existing VMs. Guest images update separately:

To updateRunEffect on existing VMs
Barn itselfbrew upgrade, install.sh, or a newer packageNone; disks and state are kept
The Linux image catalogbarn update (or barn update --mirror)None; new and recreated nodes use the newer images
Cached Linux base imagesPreview with barn image update --dry-run, then run barn image updateExisting nodes keep their backing images
The macOS base imagebarn mac image updateNone; apply it to a VM with barn mac recreate NAME --update

The 1.5.0 release notes cover mirror upgrades and image defaults. For proxy or PATH issues, see Troubleshooting. To remove Barn, see Uninstall.

1.2 - 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.

1.3 - macOS Virtual Machines

Run macOS 27 virtual machines on Apple Silicon with barn mac — create, connect, share files and the clipboard, and clean up.

Use barn mac when you need a clean macOS machine to build, test, or reproduce a macOS-specific bug, and want to throw it away afterwards. Each VM gets an administrator account with passwordless sudo, SSH with pinned keys, a desktop window, shared host folders, and clipboard sharing. VMs run under your own user account through Apple’s Virtualization framework, so nothing needs sudo.

Mac VMs are separate from the Linux lab: they don’t read barn.yml, their state lives in $BARN_HOME/mac (default ~/.barn/mac), and Linux barn destroy or barn purge never touches them.

Requirements

  • An Apple Silicon Mac running macOS 27 or later, with a logged-in desktop session. Guests also run macOS 27.
  • About 65 GiB of free disk space for the first VM: the IPSW download (23.8 GiB for macOS 27.2.1) plus 40 GiB that Barn requires for the restore. Each VM is an APFS clone of the base image and uses more space as the guest writes to disk. The first base defaults to 100 GiB of capacity.
  • Barn.app, the native app bundle that runs the VMs, from the same release as the CLI. Homebrew and the Apple Silicon release archive include it.

Apple’s Virtualization framework runs at most two macOS VMs at a time on one Mac, counting VMs from every virtualization tool and an in-progress base-image install. You can keep more stopped VMs on disk and start any two of them, subject to the Apple software license.

Install

brew install pgsty/infra/barn
barn version
barn mac doctor

Homebrew installs the signed, notarized Barn.app together with the matching CLI and helper; you don’t need Go or Xcode. The installer and manual archive include the app on Apple Silicon too. Stop running Mac VMs before upgrading or replacing the app.

To develop Barn itself, see Build the Mac component.

Create your first machine

barn mac up

On a Mac with no prepared base, Barn 1.4.0 selects macOS 27.2.1 (26B131) and asks before downloading it:

info: macOS 27.2.1 (26B131) is not prepared on this Mac yet.
download:  23.8 GiB from Apple (updates.cdn-apple.com)
then:      install macOS once into a reusable base (about 20 minutes)
free:      551.2 GiB
Download macOS from Apple now? [Y/n]

After you confirm, Barn:

  1. Downloads the restore image from Apple (updates.cdn-apple.com), resuming any partial transfer and checking Apple’s published SHA-256.
  2. Installs macOS once into an unbooted base image. The install uses one of the two VM slots while it runs.
  3. Clones mac1 from the base with APFS copy-on-write, boots it, creates your account, and waits until SSH and passwordless sudo work.
NAME  ADDRESS      STATE    MESSAGE
mac1  10.10.20.10  running  created and ready; macOS 27.2.1 (26B131), user alice
ready: barn mac ssh mac1
desktop: barn mac open mac1

Later VMs clone the same base in seconds. If an earlier release prepared this Mac, run barn mac image update to prepare 27.2.1 for new VMs; existing VMs keep their current base.

If you already have Apple’s restore image, pass it with --ipsw to skip the download. On the same APFS volume Barn clones the file instead of copying it:

barn mac up --ipsw ~/Downloads/UniversalMac_27.2.1_26B131_Restore.ipsw

In scripts, pass --yes to allow the download, or run barn mac setup beforehand to prepare the base without creating a VM. A new VM started with --no-wait returns as soon as its process runs; run barn mac up NAME without --no-wait to finish SSH and sudo setup before using ssh or exec.

Work in the machine

Shell and commands

barn mac ssh                                  # interactive shell
barn mac exec -- sw_vers                      # run one program
barn mac ssh -- 'id; sudo -n true && echo sudo works'
ProductName:		macOS
ProductVersion:		27.2.1
BuildVersion:		26B131

The guest administrator account has your host username unless you set --user at creation. Put -- before the remote command. ssh passes a command string to the guest shell; exec runs the program with its arguments directly, so wrap pipelines and redirection in sh -c (see the SSH/exec contract). Both return the remote exit status, and --json captures stdout, stderr, and exit_code:

barn --json mac exec -- sh -c 'echo out; exit 3'
{
  "command": "exec",
  "node": "mac1",
  "host": "10.10.20.10",
  "arguments": ["sh", "-c", "echo out; exit 3"],
  "success": false,
  "exit_code": 3,
  "stdout": "out\n"
}

The full schema is in the Mac reference.

Desktop

barn mac open

barn mac open shows the guest desktop in a native window; the guest display follows the window size (View → Enter Full Screen for full screen). Closing the window leaves the VM running. Run barn mac open again to reopen it, or to boot a stopped VM and show its display.

While the guest window has focus, keyboard shortcuts go to the guest, so use the menu bar for host actions:

Menu itemAction
Machine → Share ClipboardToggle plain-text clipboard sync for this session
Machine → Restart…Restart macOS inside the guest
Machine → Shut Down…Shut the guest down cleanly (same as barn mac stop)
Window → Keep Running in BackgroundHide the window and keep the VM running
Barn → Quit Barn…Choose whether to keep the VM running in the background or shut it down

When you log out of or shut down the host, Barn asks the guest to shut down and powers it off if it misses the timeout.

Each VM has a random password for the lock screen and GUI administrator prompts. Copy it to the host clipboard without printing it:

barn mac password --copy

Clipboard

Clipboard sharing moves plain text over the VM’s SSH channel, so the guest needs no extra agent. Focusing the guest window brings in text copied on the host; switching back to a host app brings out text copied in the guest. Password-manager items marked concealed, images, and files are never transferred.

To turn clipboard sharing off for a VM from its next start, run barn mac configure mac1 --clipboard off.

Shared folders

Pass --share when creating a VM to mount host directories in the guest under /Volumes/My Shared Files/<name>:

barn mac up dev --cpu 8 --memory 16G --share ~/src --share docs=~/Documents:ro
barn mac exec dev -- ls "/Volumes/My Shared Files"

The share name defaults to the directory’s basename; append :ro for read-only. Each path must resolve to an existing directory (symlinks are fine), and Barn never creates or deletes the host directory. To change shares on an existing VM, stop it and use configure:

barn mac stop dev
barn mac configure dev --share data=/Volumes/Work/data --unshare docs
barn mac start dev

VirtioFS in macOS guests can briefly serve cached contents after a host-side edit. When a build needs the exact bytes immediately, copy files onto the guest disk with scp or rsync.

SSH from other tools

When the first Mac VM becomes ready, Barn adds a marked Include line to ~/.ssh/config, so ssh mac1, scp, rsync, and IDE Remote-SSH work with each VM’s own key and pinned host key:

ssh mac1 'uptime'
rsync -a ./project/ mac1:project/
barn mac ssh-config              # print the generated entries
barn mac ssh-config --remove     # remove Barn's Include and stop re-adding it
barn mac ssh-config --install    # add it back

If ~/.ssh/config is a symlink managed by a dotfile tool, Barn leaves it alone and prints the Include line for you to add. If your own config already has a Host alias with a VM’s name, Barn keeps yours and writes its entry by IP address only.

Multiple machines

VM names are lowercase letters and digits, start with a letter, and may contain inner hyphens. Creation flags (--cpu, --memory, --disk, --user, --share) apply when creating a VM. CPU and memory default to 4 vCPUs and 8 GiB. Without --disk, the VM inherits the default base’s capacity, or uses 100 GiB for the first base.

barn mac up dev --cpu 8 --memory 16G
barn mac ls
NAME  ADDRESS      STATE    SSH    USER   OS            CPU  MEMORY  DISK                 SHARED
dev   10.10.21.10  running  ready  alice  macOS 27.2.1  8    16 GiB  504.0 MiB / 100 GiB  src,data
mac1  10.10.20.10  running  ready  alice  macOS 27.2.1  4    8 GiB   4.7 GiB / 100 GiB
limit: 2 of 2 macOS VMs are running; stop one before starting another

Without a name, commands act on the only VM, or on mac1; when several exist, Barn asks you to name one. A --disk size different from the prepared base’s capacity makes Barn install a new base at that size first.

Each VM gets its own private /24, starting at 10.10.20.0/24 with the guest at .10. Barn skips subnets that overlap your LAN, VPNs, the Linux lab, or other Mac VMs.

Everyday lifecycle

barn mac stop dev               # clean shutdown; powers off after 2 minutes
barn mac start dev              # boot and wait for SSH
barn mac restart dev            # stop and start, applying pending configure changes
barn mac stop --all             # stop every running Mac VM

barn mac stop --force powers off at once; barn mac start --recovery boots macOS Recovery with the desktop window open.

barn mac up never changes an existing VM. Passing a different creation flag points you to configure:

error: dev already exists, so --cpu would not apply; its configuration and data were preserved
next: barn mac configure dev --cpu 4

Stop the VM before changing CPUs, memory, shared folders, or subnet (clipboard sharing can change while it runs):

barn mac stop dev
barn mac configure dev --cpu 6 --memory 12G --subnet auto
barn mac start dev

barn mac recreate replaces the disk with a fresh clone of the base and keeps the name, account, hardware settings, shares, and IP. barn mac destroy deletes the VM. Both ask for typed confirmation on a terminal; pass --yes in scripts.

barn mac recreate dev
barn mac destroy dev
OperationGuest disk and installed appsHardware settings, IP, and account
stop / start, restart, repeated upKeptKept
configureKeptUpdated as requested
recreateReplaced with a fresh macOS cloneKept; new login password and SSH keys
destroyDeletedDeleted; the base image stays

macOS versions and disk space

barn mac image ls
KIND           OS            BUILD   STATE  ON DISK   CAPACITY  USED BY
base           macOS 27.0    26A428  ready  26.7 GiB  100 GiB   mac1
base           macOS 27.2.1  26B131  ready  25.6 GiB  100 GiB   default
restore image  macOS 27.0    26A428  ready  24.8 GiB  -
restore image  macOS 27.2.1  26B131  ready  23.8 GiB  -

APFS clones share blocks with their base, so ON DISK and the per-VM disk figures overlap and don’t add up.

barn mac image update prepares the newest macOS 27 build Barn supports and makes it the default for new VMs. Existing VMs keep their disks and bases. To move a VM to the new base, back up its files and run barn mac recreate NAME --update. For a VM with a custom disk size such as 200G, first prepare a base of that size with barn mac setup --disk 200G.

barn mac image prune lists base images that no VM uses and aren’t the default; --installers adds downloaded .ipsw files, and --yes deletes them:

barn mac image prune --installers         # preview
barn mac image prune --installers --yes   # delete

Clean up

barn mac ls                                 # list Mac VMs
barn mac destroy mac1 dev                   # delete selected VMs
barn mac image prune --installers --yes     # delete cached IPSWs and unused bases

Destroying the last Mac VM removes its ~/.ssh/config entries and keeps the default base image. To remove all Mac VM state:

  1. Destroy every Mac VM (barn mac destroy ...) and run barn mac ssh-config --remove.
  2. Delete $BARN_HOME/mac (default ~/.barn/mac).
  3. Optionally delete ~/Library/Preferences/com.pgsty.barn.plist (io.pgsty.barn.mac-runner.plist in 0.9.0), which stores the desktop window geometry.

Troubleshooting

Start with barn mac doctor. It checks the host, Barn.app, base images, free space, and every VM, and exits 3 if any check fails. barn mac logs [name] shows startup, network, and Virtualization framework logs.

SymptomFix
dev and mac1 are running; macOS allows 2 macOS virtual machines at a timeRun the suggested barn mac stop NAME, or quit another tool’s macOS VM. See Requirements.
preparing macOS needs … GiB free on this volumeFree space, or run barn mac image prune --installers --yes.
… has a 200 GiB disk, but macOS … is prepared only at 100 GiBRun the printed barn mac setup --disk 200G, then barn mac recreate NAME --update.
network … overlaps route … on startA VPN or new route now covers the VM’s subnet. Run barn mac configure NAME --subnet auto.
ssh mac1 from another SSH client fails with No route to hostAllow your terminal or IDE in System Settings → Privacy & Security → Local Network, or use /usr/bin/ssh (barn mac ssh and exec use it).
mac_runner_missing or mac_runner_protocolThe CLI and Barn.app come from different builds. Reinstall Barn so they match; for a source build, use the bin/mac/barn from one make mac-build.
Starting a VM fails from a remote SSH sessionRun barn mac in a terminal on the Mac’s logged-in desktop session, with the login keychain unlocked.

Every error reason and exit code is listed in the Mac reference.

Apple Account sign-in is unreliable in macOS guests under Apple’s Virtualization framework. USB passthrough, snapshots, and suspend/resume aren’t supported.

1.4 - Daily Operations

The normal lifecycle for the one deployment: inspect, access, scale, change, stop, and destroy.

Once a lab is running, day-to-day work comes down to a few commands: check it, log in, stop it overnight, apply an inventory edit, and tear it down. This page covers them for the Linux lab; macOS VMs have their own lifecycle.

Inspect and access

barn status
barn ssh meta
barn exec node-1 -- hostname
barn logs meta --source serial

These commands read the deployment stored in BARN_HOME (default ~/.barn), so they work from any directory; if you set BARN_HOME yourself, use an absolute path. barn status shows each node’s image and resources and flags software emulation (tcg); barn status --verbose adds guest architecture, accelerator, loopback SSH port, and QEMU PID.

Every barn up, including one for a subset of nodes, refreshes the ~/.ssh/barn_config aliases for the whole deployment, so ssh meta keeps working. Run barn ssh-config --install to refresh them at any other time.

Commands that read an inventory (plan, up, reload, resize, recreate) use -f, else the first of barn.yml, barn.yaml, pigsty.yml, pigsty.yaml in the current directory, else the applied specification (Discovery). Pass -f pigsty.yml when a directory has both barn.yml and pigsty.yml.

Running barn up again on a healthy lab is safe: it retries unfinished guest setup and updates guest helper scripts without restarting running VMs. Anything it could not set up is listed under nodes[].warnings, and anything it repaired, such as a reset data disk, under nodes[].repairs.

Stop and start

barn stop
barn start
barn restart node-1
barn reload -f barn.yml
CommandReads the inventoryWhat it does
stopNoStops running nodes
startNoBoots stopped nodes, re-checks running ones, and updates SSH aliases if a loopback port had to move
restartNoStops and boots nodes with their applied definitions
reloadYesValidates the inventory, stops the selected nodes, then runs up; can add new nodes

Before stopping anything, reload refuses changes to an existing node’s definition (CPU, memory, image, disks, shares, addresses); apply those with resize or recreate.

--no-wait returns as soon as QEMU starts and skips readiness checks, guest recovery, the startup clock check, and /etc/hosts and control-node SSH updates until the next barn up.

Startup corrects guest clocks that drifted while the host slept. For a lab that keeps running, use barn time status, barn time sync, or the opt-in timer barn time auto enable (time reference).

Change the deployment

Editing the inventory never changes a VM on its own. barn plan shows what the edit means, and you apply it with the command the plan names:

barn plan
barn up                         # create or start nodes and refresh SSH aliases
barn resize node-1              # apply vm_cpu/vm_mem changes in place
barn recreate node-1            # rebuild a node whose definition changed
Plan reportsMeaningApply with
createNode is in the inventory but not provisioned yetbarn up
resizeNode CPU or memory changedbarn resize <node>
recreateNode image, disks, shares, or other VM definition changedbarn recreate <node>
missingProvisioned node is no longer in the inventoryRestore the YAML entry, or barn destroy <node>

With --json, start, create, resize, recreate, and missing are node lists, and action summarizes the plan as create, start, converge, resize, recreate, blocked-removal, repair, or none. blocked, when present, is a string explaining what blocks the plan, and whole_deployment: true means every node has to be recreated together; run the command the plan suggests so new nodes are included. Pigsty service variables that Barn does not read produce action: none. The full schema is in Planning.

Resize CPU, memory, or the root disk

Edit vm_cpu or vm_mem and run barn resize. Increases are hot-plugged where the backend supports it; decreases and other backends stop and start the VM, keeping its identity and disks. barn resize -D grows the root disk in place (root growth).

If an online resize is interrupted after hot-plugging, barn status reports reason: resize_incomplete. Run barn resize NODE again to finish, or barn restart NODE to return to the committed resources.

Recreate a node

recreate is the explicit way to replace a VM. Barn first validates the new image, network, shares, and persistent-disk layout, then destroys the selected VMs and boots fresh ones from the inventory. Root disks and non-persistent data disks are replaced, compatible persistent disks are reattached (what survives), and each new VM gets a new identity and refreshed SSH host-key state.

On a terminal, recreate and destroy list the affected nodes and ask you to type the command name; scripts pass --yes (or --force).

Without node names, recreate replaces every node. If the inventory no longer lists an existing node, it stops before touching any VM (exit 4, reason: nodes_removed): run barn destroy <node> or add the node back.

Apply changes to selected nodes

You can edit several nodes and roll the changes out one at a time:

barn plan node-1 -f barn.yml
barn recreate node-1 -f barn.yml
barn plan node-2 -f barn.yml

With explicit node names, plan, up, reload, recreate, and resize keep every unselected node’s applied definition, even if its YAML entry was edited or removed, and do not resolve images for unselected nodes that do not exist yet. The whole inventory must still parse, and the selected changes must not conflict with applied addresses, aliases, control-node roles, or deployment-wide settings.

Without node names, Barn evaluates the whole inventory: CPU and memory changes need resize, other changes to existing VMs need recreate, and missing nodes need their entry restored or an explicit destroy.

Concurrent commands

Within one command, --parallel/-p sets how many nodes are handled at once (default max(1, logical CPUs - 2); see lifecycle concurrency).

Commands that change the deployment (up, start, stop, restart, reload, resize, recreate, destroy, purge, provision) take a lock in BARN_HOME, so only one runs at a time. Another waits up to 10 minutes (or its shorter provision --timeout), showing the holder’s command, PID, and start time, then exits 4 with reason: deployment_busy. The lock is released when its process exits; never delete lock files by hand.

Read-only and access commands (status, ssh, exec, ssh-config, hosts) don’t wait. barn status shows the last committed state, with a note naming any operation in progress. For a command that was killed midway, see Troubleshooting.

Destroy

barn purge and barn destroy --yes --purge immediately power off running Linux VMs before deleting their disks. Run barn stop first to give databases and other guest services time to shut down.

Pick the scope to remove:

Single node
barn destroy node-3
Keep persistent disks
barn destroy
Delete persistent disks
barn destroy --delete-persistent
Purge lab & keys
barn purge
  • barn destroy <node> removes one node and refreshes SSH aliases for the rest. If it removes the control node, the first remaining node takes over, so ssh-config, hosts, exec, and provision keep working. Set admin_ip in the inventory to the new control node (and delete the old entry unless you want up to recreate it), then run barn up to install its control SSH access.
  • barn destroy removes every VM with its root disk and non-persistent data disks, plus the deployment state and Barn’s SSH aliases. It keeps persistent disks, deployment keys, cached images, and the host network, so barn up rebuilds the lab from the inventory.
  • barn destroy --delete-persistent also deletes persistent disks; --purge also deletes keys and deployment state. Both apply to the whole deployment only.
  • barn purge deletes the whole lab, persistent disks, keys, and deployment state immediately, keeping the image cache and host network. barn purge --ask shows the nodes and scope first and accepts y/yes; n/no, an empty line, or EOF cancels. purge accepts no --yes, -y, or --force.

Each command’s effect on data disks is summarized in What survives each operation. Once no Linux VM remains, you can remove the host network:

barn network uninstall --yes

To clear cached images, see Image Repositories; to remove Barn completely, see Uninstall.

1.5 - Storage, Files, and Service Access

Configure test data disks, understand retention, transfer files, and reach guest services through OpenSSH.

Each Linux node has a disposable root disk and separate data disks. The root disk is a copy-on-write layer over the base image, and recreate replaces it whenever the image or node definition changes. Data disks keep test data on their own devices, so the system can be rebuilt underneath them; with persistent: true, a data disk also survives recreate and destroy. This page covers disk layout and retention, then file transfer and service access, using the meta node at 10.10.10.10 from the Linux Quick Start.

Configure disks before creating the VM

By default each node gets a 64 GiB root disk and one 128 GiB non-persistent data disk mounted at /data. vm_disk sets the root size in GiB (64 or 64GiB); vm_disks replaces the whole data-disk list, and vm_disks: [] creates no data disks.

This single-node inventory keeps /data across rebuilds and adds a throwaway /scratch:

storage.yml
all:
  vars:
    admin_ip: 10.10.10.10
    vm_image: d13
  children:
    nodes:
      hosts:
        10.10.10.10:
          nodename: meta
          vm_cpu: 2
          vm_mem: 4096
          vm_disk: 64
          vm_disks:
            - {path: /data, size: 64, fs: auto, persistent: true}
            - {path: /scratch, size: 32, fs: ext4, persistent: false}

Create the VM and check the mounts:

barn validate -f storage.yml
barn plan -f storage.yml
barn up -f storage.yml
barn exec meta -- findmnt /data
barn exec meta -- findmnt /scratch
barn exec meta -- df -h / /data /scratch

Sizes (size: 64 or size: 64GiB) are thin-provisioned: the host file grows only as the guest writes. With fs: auto, Barn formats a new disk as XFS when the guest has mkfs.xfs and as ext4 otherwise. If findmnt shows nothing, the reason is in the barn up warnings.

If meta already exists with a different disk layout, barn up reports drift instead of changing it. Check barn plan, copy out anything you need, then run barn recreate meta, which replaces the root disk and non-persistent data disks.

What survives each operation

OperationRoot and non-persistent data disksPersistent data disks (persistent: true)
stop then start, restart, or reloadKeptKept
resize, including root growthKeptKept
Repeated up on a healthy nodeKeptKept
recreateReplacedKept and reattached
destroy (one node or the whole lab)DeletedKept
destroy --delete-persistent, destroy --purge, or purgeDeletedDeleted, including disks kept from earlier destroys

Newly formatted data filesystems are owned by root. To see /data survive a stop and start:

barn exec meta -- sudo -n sh -c \
  'printf "retention check\n" > /data/barn-retention.txt'
barn stop meta
barn start meta
barn exec meta -- cat /data/barn-retention.txt

Reattach a persistent disk

Barn matches a kept disk to its node by name and disk definition. To reattach it after recreate or destroy, keep the node name, mount path, size, and fs unchanged; fs: auto matches whichever filesystem the disk already has. A mismatched definition is refused rather than resized, renamed, or converted.

Removing a persistent disk from a node’s definition takes a whole-lab teardown: recreate refuses an inventory that drops an attached persistent disk, so run barn destroy --delete-persistent --yes or barn purge first. Disks kept from a node you removed stay on the host until one of those commands deletes them.

When Barn resets a data disk

Warning

Data disks are test storage, persistent: true included. Barn reformats a data disk when it finds the filesystem damaged. Keep anything valuable on the host.

Barn checks data disks when a VM first boots and whenever barn up (or reload, which runs it) finds a guest whose data disks are not mounted cleanly. --no-wait postpones the check to the next barn up.

What Barn findsWhat it doesReported in
A blank disk with no signatureFormats it with fsnodes[].repairs, unless this is the disk’s first format
A healthy ext4 or XFS filesystemMounts it unchanged—
An ext4 or XFS filesystem that will not mount, where e2fsck -fn or xfs_repair -n reports recognized corruptionReformats it, erasing its contentsnodes[].repairs
A partition table, a signature without a filesystem UUID, another filesystem type, features the guest tools do not support, or a checker failure Barn does not recognizeLeaves the data alonenodes[].warnings
A missing device, failed probe, busy mount, read-only device, or host I/O errorLeaves the data alonenodes[].warnings

Root disks and host shares are never formatted. After fixing the cause of a warning, run barn up again to mount the disk. barn up exits 0 in all of these cases, so scripts should check repairs and warnings.

Copy files over managed SSH

Export an OpenSSH configuration to use ssh, scp, or rsync directly:

barn ssh-config > barn-ssh.conf
ssh -F ./barn-ssh.conf meta hostname
scp -F ./barn-ssh.conf ./storage.yml meta:/tmp/storage.yml
scp -F ./barn-ssh.conf meta:/data/barn-retention.txt ./barn-retention.txt

The file points at the current loopback SSH port, the deployment key path, and a per-instance known_hosts; it does not contain the key itself. Export it again after you recreate a node or its loopback port changes, or run barn ssh-config --install so plain ssh meta and scp work without -F.

Reach services inside the guest

A service listening on the node’s fixed IP, such as PostgreSQL on 10.10.10.10:5432, is reachable from the host and from other nodes at that address, as long as the guest firewall allows it.

For a service bound to 127.0.0.1 inside the guest, forward a host port over SSH and connect host clients to 127.0.0.1:15432; Ctrl-C closes the tunnel:

ssh -F ./barn-ssh.conf -N \
  -L 127.0.0.1:15432:127.0.0.1:5432 meta

Management SSH uses its own loopback port, so barn ssh and -L tunnels work even when the fixed-IP network reports a limitation. The inventory has no vm_ports or vm_forwards setting; use the fixed IP or a tunnel.

SSH aliases such as ssh meta only help OpenSSH tools. For browsers, psql, and other host programs to resolve node names and vm_alias entries, preview and then apply the /etc/hosts integration:

barn hosts install --json
barn hosts install --yes

barn hosts install --yes edits the host’s /etc/hosts, using sudo when needed. Run it again after adding nodes or changing addresses.

Share a host directory

To edit code on the host and build it in the guest, mount a host directory with Virtio-9p (Linux and macOS hosts). Set vm_shares under all.vars or on a host before the first barn up:

barn.yml
vm_shares:
  - host: ./src
    guest: /workspace
    readonly: true

host may be relative to the inventory’s real location, start with ~/, or be a directory symlink. The directory must exist, be accessible to you, and not overlap BARN_HOME; you don’t need to own it. Several guests may write the same tree; coordinating those writes is up to you.

Host QEMU and the guest kernel must support 9p. If the guest user cannot write a writable share, Barn mounts it read-only with a warning and leaves host ownership alone. Changing shares on an existing node needs barn recreate <node>. The full schema is in Shares; macOS guests share folders with VirtioFS instead (see macOS shared folders).

1.6 - Image Repositories

Choose guest images, use a mirror, import a local qcow2, and prune the cache.

On first use of an official Linux image, Barn downloads the selected base image and verifies it against the signed catalog. New labs in 1.5.0 use d13:stable (Debian 13) for your host architecture. On Barn 1.4.0, use barn init -I d13 to start with Debian 13. Use this page to pick another distribution, download from the China mirror, bring your own qcow2, host a repository, or reclaim disk space.

Choose an image

barn image list
barn image info
FamilyDistributionShort aliasesNotes
d13Debian 13d, debian, trixieDefault for new labs in 1.5.0
d12Debian 12bookworm
u24Ubuntu 24.04 LTSnoble
u26Ubuntu 26.04 LTSu, ubuntu, resolute
u22Ubuntu 22.04 LTSjammydeprecated
el10Rocky Linux 10e, el, rocky
el9Rocky Linux 9rocky9
el8Rocky Linux 8rocky8deprecated; arm64 runs under TCG on Apple Silicon
el7CentOS Linux 7.9c7, centos7deprecated (EOL); amd64 only, native linux/amd64 hosts only

Append a to a family name (or to e, el, d, u) for arm64, or x/i for amd64: d13x, el10a, da. Deprecated images still boot and print a status warning. If you upgraded from Barn 1.2.0, note that rocky and ubuntu now point to el10 and u26; see Upgrade Barn. The full alias list is in the image reference.

Set the image for the whole lab in the inventory:

barn.yml
all:
  vars:
    vm_image: el9
    vm_version: "9.9"
  hosts:
    10.10.10.10: {nodename: meta}

A bare family such as el9 follows its stable channel; name:channel picks another channel, and name@full-version pins one build (a shorter numeric prefix can match several versions). vm_version is a numeric prefix matched on dot boundaries: "9.9" selects the newest 9.9.x build in the active catalog, "9" the newest 9.x. Quote it so YAML keeps it a string, and don’t combine it with a :channel or @version suffix.

To get the same build after future catalog updates, pin the full version that barn image info reports:

barn.yml
all:
  vars:
    vm_image: d13@20261123.2671.1
  hosts:
    10.10.10.10: {nodename: meta}

After changing vm_image or vm_version, run barn plan. Existing nodes keep their root disk until you run barn recreate <node>. barn update fetches, verifies, and activates the newest catalog; it changes only what new or recreated nodes get.

To refresh cached images, preview the downloads with barn image update --dry-run and then run barn image update. An empty cache refreshes only the catalog. Use barn image update d13i d13a for a first download of both Debian 13 architectures.

Override image or architecture for one command

barn plan -I d13 -A amd64
barn up -I d13 -A amd64

-I (--image) and -A (--arch) override the inventory for one command and leave the file as it is. Guests use the host architecture unless vm_arch or -A says otherwise, and -A native follows the host again. An architecture-suffixed alias such as -I d13x selects the family and architecture together. With such an alias, an explicit -A or BARN_ARCH must name the matching architecture. A different architecture or native fails validation.

To keep an override, set vm_image and all.vars.vm_arch in the inventory (removing a superseded vm_version), or generate a new inventory with barn init -I d13 -A amd64 or barn init -I d13x. Existing nodes need recreate to change image or architecture, and an architecture change must include every existing node. Precedence rules and architecture spellings are in Image and architecture overrides.

For a bare alias, standalone barn image info and barn image pull default to the host architecture. Use an architecture-suffixed alias or pass -A to select another. These commands ignore both vm_arch and BARN_ARCH. If the image has no build for that architecture, the command fails. Barn runs only amd64 and arm64 guests. A guest whose architecture differs from the host runs under TCG emulation; on Linux, install the emulator first (see HVF, KVM, or an emulator is unavailable).

Download from the China mirror

Release builds download from https://repo.pigsty.io/barn. Add --mirror to use the China mirror, https://repo.pigsty.cc/barn:

barn update --mirror
barn up -I d13 --mirror
barn image pull d13 --mirror

Downloads from either official repository retry transient errors, resume partial transfers, and switch to the other official repository if an artifact is unreachable.

To use your own repository, pass --repo with a URL or local directory, or export BARN_REPO for the shell session:

barn update --repo https://mirror.example/barn
barn image pull d13 --repo https://mirror.example/barn
barn up -I d13 --repo https://mirror.example/barn

export BARN_REPO=https://mirror.example/barn
barn update
barn up -I d13

The precedence is --repo → --mirror → BARN_REPO → https://repo.pigsty.io/barn. A custom --repo downloads only from that root, with no fallback. Barn reads a built local directory’s catalog.json on first use. For a custom HTTPS server, activate its catalog with barn update --repo <url> first. Use the same --repo for later commands.

The official repositories and any plain http:// repository must serve a valid ML-DSA-87 signature (catalog.json.sig); a local directory or custom https:// endpoint may serve an unsigned catalog.json. Either way, each download must match the catalog’s byte size and SHA-256 and pass qemu-img checks; see Trust and verification.

Import a local qcow2

To use one custom image without running a repository, import it under a local- alias and set vm_image: local-mybase in the inventory:

barn image import --name local-mybase --boot uefi \
  --source-user debian /path/to/debian-13-generic.qcow2
  • --name (must start with local-), --boot (uefi or bios), and --source-user go together. Without them, Barn caches the verified qcow2 by content digest but creates no alias.
  • The image must already include cloud-init, which Barn uses for first-boot provisioning.
  • local-* aliases are immutable. Register a new name each time you rebuild the image.
  • The recorded architecture defaults to the host. -A (which requires --name) records a different one, for example barn image import /path/to/debian-13-generic-arm64.qcow2 --name local-arm64 --boot uefi --source-user debian -A arm64. Barn records the declaration without converting the image or detecting its guest CPU, so set the inventory’s vm_arch or the command’s -A to match.

See Prune the cache to check which images Barn can reclaim.

Build a static repository

A repository lets several hosts or a team share the same images, or work offline. It is a plain directory that you can serve over HTTP or HTTPS, copy with rsync, or read from a local path:

/srv/barn

  • barn/
    • repo.yamlOptional metadata
    • catalog.jsonGenerated catalog with SHA-256 and file sizes
    • catalog.json.sigRequired for official and plain HTTP repositories
    • images/
      • d13-1-arm64.qcow2Verified cloud-init qcow2 base image

With images/d13-1-arm64.qcow2 in place, run barn repo build /srv/barn and barn repo verify /srv/barn. Use the directory immediately with barn image info d13 --repo /srv/barn. To specify the upstream login user and mark the image as testing, add this optional file before building:

/srv/barn/repo.yaml
schema: 1
revision: 1
defaults: { image: d13, channel: stable, arch: native, boot: uefi }
images:
  d13:
    channels: { stable: "1" }
    versions:
      "1":
        status: testing
        variants:
          arm64:
            source_user: debian

Put the cloud-init-capable image at /srv/barn/images/d13-1-arm64.qcow2 (relative roots, directory symlinks, and shared writable directories all work). Then, on a host with qemu-img, generate and check the catalog:

barn repo scan /srv/barn
barn repo build /srv/barn
barn repo verify /srv/barn

barn repo scan inspects the layout. barn repo build checks the image files and records their SHA-256, size and virtual capacity. If you set revision in repo.yaml, increase it when the contents change. Publish the images before the catalog and its signatures. Signing an official mirror

To cache the local catalog and test a download, run the following commands.

barn update --repo /srv/barn
barn image info d13 --arch arm64 --repo /srv/barn
barn image pull d13 --arch arm64 --repo /srv/barn

Pass --repo /srv/barn (or export BARN_REPO=/srv/barn) to plan, up, and recreate, and set vm_image: d13@1 in the inventory. To switch /srv/barn back to the binary’s built-in catalog while keeping its anti-rollback high-water mark, run barn image reset --repo /srv/barn. The file formats are in Static repository format.

Prune the cache

barn image prune reclaims disk space from cached images that nothing references and from interrupted download staging files. Preview first, then delete:

barn image prune --dry-run
barn image prune --yes

Pruning needs qemu-img. It keeps every image in the selected repository’s active catalog, every base image used by a node in BARN_HOME, and every registered local-* alias. Use the same --repo for the preview and the deletion. Details are in Pruning; to build new base images from upstream cloud releases, see Image Pipeline.

1.7 - Automation and Guest Scripts

Prepare an unattended lab, check JSON results, and run repeatable scripts inside selected guests.

Barn commands print JSON with --json and return documented exit codes, so CI jobs and AI agents can drive a lab without a terminal. This page starts with a complete unattended run, then covers what a script needs to check and how to run commands inside guests. Run every command as the Unix user who owns the deployment, with the same BARN_HOME and -f <inventory> each time.

Run a lab end to end

Run this example under a dedicated CI account with one lab job at a time on the host. BARN_HOME isolates VM state. Jobs on the same host share the lab network, and jobs under the same account share its SSH aliases.

ci-lab.sh
#!/usr/bin/env bash
set -euo pipefail
export BARN_HOME="$HOME/.barn-ci"      # reserved for this CI lab
trap 'barn purge' EXIT                 # discard the lab when the job ends, even on failure

barn validate -f barn.yml              # committed inventory with a pinned vm_image
barn setup -f barn.yml --yes           # install host packages and the Barn network
barn up -f barn.yml --json > up.json   # non-zero exit if any node failed
jq -e '
  ((.warnings // []) | length == 0) and
  (.nodes | length > 0 and all(.ready and
    ((.warnings // []) | length == 0) and
    ((.repairs // []) | length == 0)))
' up.json

barn exec meta -- hostname
barn provision --script ./check-lab.sh --json > provision.json
  1. barn setup --yes accepts the host-preparation plan without asking. It needs sudo that works without a password prompt (cached credentials or a NOPASSWD rule); what it installs is described in barn setup.
  2. barn up exits non-zero when a node fails. Barn verifies each ready marker over management SSH. Optional guest warnings can accompany a successful run, so the example checks command-level warnings as well as each node’s warnings and repairs.
  3. barn exec and barn provision run commands and scripts in the guests; see below.
  4. barn purge deletes the deployment in this BARN_HOME, persistent disks and keys included, without asking. The image cache stays, so the next run does not download again. Use barn destroy --yes instead to keep persistent disks.

Prepare a predictable lab

Commit the inventory and pin vm_image to an exact version, such as vm_image: d13@20261123.2671.1; a channel like d13:stable can move to a new image after barn update. Always pass -f; it also stops first-run setup from moving an unedited generated template to a different subnet. With a custom image repository, run barn update --repo URL first and pass the same --repo to setup and up.

To write and check an inventory, then preview the host changes:

mkdir -p ~/barn-lab
cd ~/barn-lab
release=$(barn --json image info d13 | jq -er '.entry.release')
barn init dual -I "d13@$release"
barn version
barn validate -f barn.yml
barn plan -f barn.yml
barn setup -f barn.yml --dry-run

barn init [template] --image <reference> writes all.vars.vm_image, so every node uses the same image; the reference can be an alias (el9), a channel (d13:stable), or a version (d13@20261123.2671.1). barn init full -I d13 -A amd64 saves both image and architecture. barn setup [template] --image works the same way, but only when it generates the template.

On validate, plan, up, reload, recreate, and resize, --image/-I, --arch/-A, --cpu/-C, --mem/-M, --scale/-S, and --disk/-D override the inventory for one invocation. Values come from the flag, then a nonempty BARN_* variable, then the inventory, then the default, so give plan and the command that applies it the same flags and environment: barn plan -f barn.yml -I d13 -A arm64 --json, then barn up -f barn.yml -I d13 -A arm64. Existing VMs need recreate to change image or architecture (Image and architecture).

Without a terminal, up, start, restart, and reload never prepare the host themselves; they report what is missing and fail. Run barn setup --yes before them.

Validate JSON output alongside the exit code

Barn writes JSON or YAML results to stdout and diagnostics to stderr. With the default wait, barn up checks each selected node’s readiness marker over management SSH. It can exit 0 even if an optional stage such as a secondary data disk, a Virtio-9p share, or peer SSH configuration reported a limitation (nodes[].warnings), or Barn reformatted a damaged test disk (nodes[].repairs). A script that needs a fully working lab checks both:

up-check.sh
#!/usr/bin/env bash
set -euo pipefail

if barn up -f barn.yml --json > up.json 2> up.stderr; then
  jq -e '
    (.nodes | type == "array" and length > 0) and
    all(.nodes[];
      .state == "running" and .ready == true and
      ((.warnings // []) | length == 0) and
      ((.repairs // []) | length == 0)) and
    ((.warnings // []) | length == 0)
  ' up.json || exit 1
else
  barn_exit=$?
  cat up.stderr >&2
  cat up.json
  exit "$barn_exit"
fi

Don’t pass --no-wait when a later step needs ready guests. barn status --json reports the recorded state without probing guest SSH again.

Exit codes and command-specific payloads

The full table and the JSON failure object are in Exit codes and Structured failures. The codes scripts most often branch on:

ExiterrorTypical cause in automation
2usageMissing inventory on first run, invalid flags, unknown image alias, or destroy/recreate without --yes when stdin is not a terminal
4conflictDrift that needs an explicit command (reason: recreate_required or nodes_removed), state changed during a recreate preflight (deployment_changed), or another command held the deployment lock for 10 minutes (deployment_busy)
5partialSome nodes of a multi-node up or provision failed; read nodes[] or results[] before retrying
7integrityA digest, signature, or identity check failed, including reason: catalog_signature or catalog_equivocation

A few commands report success differently:

  • barn doctor --json exits 0 when host compute checks pass, even if a class: network check reports an error. Read checks[] and barn network status --json before relying on the fixed-IP network.
  • barn ssh and barn exec exit with the remote command’s status (255 can also mean an OpenSSH transport failure); with --json they return success, exit_code, stdout, and stderr.
  • barn network and barn hosts install/uninstall only print their plan and exit 0 when --yes is missing and stdin is not a terminal or output is --json/--yaml. Pass --yes, or check applied in the result.

Run single commands or batch scripts

Put -- between the node and the remote command, and Barn flags such as --json before it:

barn exec meta -- hostname
barn exec node-1 -- sh -c 'id; df -h /data'
barn exec meta --json -- uname -a > uname.json

barn exec passes the program and each argument separately, so use sh -c for pipes, redirection, or variables (Remote commands).

For anything longer, write a local Bash script (a regular file, or a symlink to one, up to 4 MiB):

check-lab.sh
#!/usr/bin/env bash
set -euo pipefail
hostname
id
findmnt /data
test -d /data

Run it on selected nodes, or on every node when you name none; all targets must be running:

barn provision --script ./check-lab.sh meta node-1
barn provision --script ./check-lab.sh --parallel 2 --timeout 5m --json > provision.json

Barn streams the script to Bash over SSH, so no copy is left in the guest, and records its SHA-256 in the event log and in the result (script.sha256).

Option or limitBehavior
--parallelPositive integer; default 1 (serial). Workers never exceed the number of selected nodes
--timeoutDeadline for the whole operation; default 1h, any positive duration
--sudoRuns the script through non-interactive sudo -n
OutputUp to 1 MiB each of stdout and stderr per node; stdout_truncated / stderr_truncated mark a cut
Exit code5 when some nodes succeed and others fail; a single target’s own positive exit code other than 255; 1 otherwise

A failed run does not undo what already ran in the guests, so write scripts that are safe to run again.

Pair the lab with Pigsty

Barn reads the same Ansible inventory that Pigsty uses, so the VMs come up with the names and fixed IPs Pigsty expects to deploy to. Let Pigsty write the inventory, then create the VMs from it:

cd pigsty                 # your Pigsty checkout
./configure -c full       # writes the four-node pigsty.yml
barn validate -f pigsty.yml -I d13
barn plan -f pigsty.yml -I d13
barn up -f pigsty.yml -I d13
barn ssh

barn up creates the admin account in every guest and gives the control node at admin_ip the deployment key and an SSH configuration that reaches every peer on its fixed IP, which is what Ansible needs (Security and Trust). barn ssh logs in to that control node; run Pigsty’s playbooks from there.

1.8 - Use Barn with an AI Agent

Give Claude Code, Codex, or another coding agent the Barn skill so it can bring up Linux labs and macOS VMs for you.

Barn publishes an agent skill, Barn VMs (barn): one Markdown file that teaches a coding agent to create, use, change, and clean up Barn VMs. It gives the agent Barn’s mental model, an index of this documentation, starting points for common scenarios (one Debian machine, a multi-node lab, a Pigsty sandbox, replacing Vagrant, distribution matrices, CI, macOS VMs), and the boundaries it must respect. For command details, it sends the agent back to these pages.

Start with a prompt

Paste this prompt into the agent and replace the brackets with your requirements:

Use Barn to run virtual machines on this computer, following the Barn skill: https://barn.pgsty.com/v1.5/skill.md
Check commands and configuration against the Barn docs (https://barn.pgsty.com/v1.5/docs/). Use Debian 13 (d13) unless I say otherwise.
What I need: [purpose, nodes and sizes, OS and architecture, working directory, Pigsty or not, macOS VMs…]

The last line carries the task, for example:

  • What I need: one VM to test the install script in ~/src/app.
  • What I need: a four-node Pigsty sandbox from the full template in ~/pigsty.
  • What I need: replace the Vagrantfile in this repository with a barn.yml that keeps the node names and IPs.
  • What I need: a macOS VM named build with 8 CPUs and 16 GiB of memory, sharing ~/src.

Install the skill

To load the skill in every session, save it to the agent’s skill directory and start a new session:

Claude Code
mkdir -p ~/.claude/skills/barn
curl -fsSL https://barn.pgsty.com/v1.5/skill.md -o ~/.claude/skills/barn/SKILL.md
Codex
mkdir -p ~/.codex/skills/barn
curl -fsSL https://barn.pgsty.com/v1.5/skill.md -o ~/.codex/skills/barn/SKILL.md

Agents without a skill directory read the URL directly. Use skill.zh.md for the Chinese edition. Download the file again to update it; its header names the Barn version it matches.

What the agent asks first

Most Barn commands run as your user without prompts. The skill tells the agent to ask before it:

  • changes an existing Linux lab, because each user has one deployment;
  • prepares the host with barn setup --yes, which installs packages, creates the private network, and uses sudo; when sudo needs a password, the agent gives you the command to run;
  • downloads a macOS restore image of about 24 GiB;
  • runs destroy, recreate, or purge, or deletes VM disks in any other way.

When it finishes, the agent reports the nodes it created, how to connect, any warnings from barn up, the changes it made to the host, and how to stop or remove the VMs.

1.9 - Troubleshooting

Short, safe runbooks for setup, networking, images, drift, interrupted state, and SSH.

Linux lab problems in the order you are likely to hit them. Each entry gives the Symptom, a Check to confirm it, and the Fix. For macOS VMs, see macOS troubleshooting.

Run barn doctor first

barn doctor
barn network status
barn status

barn doctor probes the host without changing it: platform, QEMU and qemu-img, required QEMU devices, a short HVF or KVM boot, UEFI firmware, /dev/kvm on Linux, the OpenSSH client, deployment state and free space under BARN_HOME, and the host network. Each problem prints a detail: line and, when Barn knows one, a fix: line.

A failed compute check exits 3. Network problems show as blocked without changing the exit code, so read barn network status too. barn status also reconciles interrupted VM state when no other command holds the lock. Add --json to any of the three for scripts and bug reports.

Install fails or barn is not found

Symptom: The installer can’t reach GitHub, or after installing, the shell says barn: command not found or barn version shows an older release.

Check:

command -v barn
barn version
echo "$PATH"

Fix:

  • Download fails: the installer downloads from GitHub Releases (--mirror changes only the guest image repository). If you need a proxy, export HTTPS_PROXY or ALL_PROXY in the shell; CLI tools don’t pick up proxies from macOS System Settings.

  • Not found or old version: the user-scoped installer puts binaries in ~/.local/bin. Add it to PATH and run the check again:

    export PATH="$HOME/.local/bin:$PATH"

    With two installs (for example ~/.local/bin and Homebrew), update the one PATH selects; see Upgrade Barn.

  • Keep barn and barn-hosts-helper from the same release, in their packaged directory layout.

barn up finds no inventory

Symptom: plan, up, or validate fails with no inventory found in this directory (exit 2, reason: no_inventory), or barn status reports no deployment state found.

Check:

ls barn.yml barn.yaml pigsty.yml pigsty.yaml
barn status

Fix: Run the command where the inventory is, pass -f /path/to/file, or create one with barn init. In a terminal, barn up writes a starter barn.yml itself; without one, run barn setup --yes and then barn up.

Without -f, plan, up, reload, resize, and recreate look for barn.yml, barn.yaml, pigsty.yml, and pigsty.yaml, in that order, and fall back to the applied inventory in BARN_HOME only when none exists. A syntax error in the first match stops the command; pass -f pigsty.yml when an old barn.yml sits beside it. no deployment state found means the active BARN_HOME is new or was purged. See Discovery.

First barn up or barn setup stops at sudo

Symptom: The first barn up or barn setup asks for your password, or fails with sudo needs a password, but stdin is not a terminal (exit 3, reason: sudo_unavailable).

Check: Preview the host changes without applying them:

barn setup --dry-run

Fix: Run the command in a terminal. Barn prints the exact host change, then hands the terminal to sudo; one password covers the whole command. --yes accepts Barn’s plan but can’t answer sudo, so automation needs cached sudo credentials or a NOPASSWD sudoers rule. On macOS, barn setup downloads and verifies the pinned socket_vmnet package before asking for sudo, so a failed download never prompts. All setup options are in barn setup.

barn init won’t write through a symlink

Symptom: barn init --force reports will not overwrite …: it is a symlink.

Check:

readlink -f barn.yml

Fix: Barn never writes through an output-file symlink. Pass the link’s target instead:

barn init -o "$(readlink -f barn.yml)" --force

Directory symlinks are fine, and barn init -o ./lab/config/barn.yml creates missing parent directories.

HVF, KVM, or an emulator is unavailable

Symptom: barn doctor reports an error for hvf-real-smoke or kvm-real-smoke, accelerator, kvm, qemu, or firmware; or a foreign-architecture guest fails with QEMU is not installed (… not found in PATH) (exit 3, reason: qemu_missing).

Check:

barn doctor
ls -l /dev/kvm      # Linux hosts

Fix:

  • KVM on Linux: enable KVM and give your user read/write access to /dev/kvm.
  • QEMU or firmware missing: run barn setup to install the host packages.
  • Foreign architecture on Linux: barn setup installs only the host-native emulator. Install the matching qemu-system-* binary and UEFI firmware before running a guest with a different vm_arch. Homebrew’s qemu on macOS includes both the arm64 and amd64 emulators.

Barn runs native guests only with HVF (macOS) or KVM (Linux) and never falls back to TCG software emulation when they fail. TCG is used only for a foreign vm_arch or a built-in compatibility rule such as el8 arm64 on Apple Silicon; see Runtime policy.

Host network is stopped, partial, or invalid

Symptom: barn doctor shows network-* checks as blocked and warns the Barn network is not ready; run barn setup to prepare it, or barn network status reports partial or invalid.

Check:

barn network status --json --verbose

Fix:

  • Stopped but intact: in a terminal, barn up adds the restart to its host plan and asks once. Without a terminal, run barn setup --yes.

  • partial or invalid: let Barn remove what it owns instead of deleting system network files by hand. Stop the deployment first; uninstall refuses while any node is running. Then prepare the network again:

    barn network uninstall --json     # show the removal plan
    barn network uninstall --yes
    barn setup --yes
  • Linux bridge test failed during setup: Barn rolls the network changes back automatically. Clean up by hand only when it reports automatic rollback failed.

  • macOS /var/log/barn-vmnet: barn setup fixes a missing or too-restrictive directory (root:wheel 0755) but won’t touch a symlink, a directory with a foreign owner, or a group- or world-writable one. Run the exact command barn network status prints.

Linux bridge helper is not usable

Symptom: barn doctor flags bridge-helper, for example … is not yet usable by this user or … the invoking user is not in group ….

Check:

id
stat -c '%U:%G %a %n' /usr/lib/qemu/qemu-bridge-helper
dpkg-statoverride --list /usr/lib/qemu/qemu-bridge-helper

Fix:

  • Debian and Ubuntu: the helper should be root:<group> 4750, with a group your user belongs to. barn setup sets this through dpkg-statoverride, and barn network uninstall restores the original. If another user installed the Barn network, uninstall it as that user, then run barn setup as yourself.
  • RPM-family hosts: the packaged mode is 4755 and Barn doesn’t change it. If the mode differs, reinstall the distribution’s QEMU packages.

A node did not become ready

Symptom: barn up exits 5 with N of M node(s) failed: <node> (<stage>: <error>), or it exits 0 but lists warnings under nodes[].warnings.

Check:

barn status
barn logs <node>                  # guest serial console
barn logs <node> --source qemu    # QEMU stderr and diagnostics
barn logs --source events         # host setup and deployment events

Fix: Barn reads /var/lib/barn/ready.json over management SSH. The node name, generation, and configuration hash (spec_hash) must match the host’s expected values. Fix the cause the logs show, then run barn up again. It retries only the unfinished stages and doesn’t restart healthy VMs. Add --rollback to remove the artifacts of a failed first preparation in the same run.

Optional guest setup stages record warnings. When all selected nodes pass readiness, barn up can exit 0 with these warnings.

WarningFix
Data disk unavailableFix the missing device, missing filesystem tool, busy mount, or host I/O error, then run barn up. A disk with a partition table, a signature without a UUID, or unsupported filesystem features keeps its data and stays unmounted; see what survives each operation.
Shared directory is read-onlyCheck write permissions on the host and in the guest, then run barn up.
Guest hosts or control-node SSH incompleteRun barn up to rewrite the managed files in the guest.
Private interface unavailableCheck barn network status, repair the host bridge or vmnet, then run barn up.

Linux shared folders need 9p support in both QEMU and the guest kernel, on macOS and Linux hosts alike. If the guest kernel lacks 9p, copy files with SSH, scp, or rsync instead.

SSH to a node fails

Symptom: ssh meta or barn ssh meta fails, or barn up reports a control-ssh warning.

Check:

barn status
barn ssh-config
barn logs <node>

Fix:

What you seeFix
barn ssh meta works but ssh meta doesn’t~/.ssh/config is a symlink or hard link, so Barn wrote ~/.ssh/barn_config and printed an Include line instead. Add that line to your config.
The deployment’s private SSH key is missingRestore it from a backup. Barn never generates a replacement key for existing VMs. A missing .pub file is rebuilt from the private key automatically.
control-ssh warningThe control node’s copy of the private key is missing; host-to-guest SSH still works. Run barn up to restore it.
A remote command is parsed as Barn flagsPut -- between the node name and the command: barn exec meta -- hostname. See Remote commands.

Two cases need no action: if another process takes a stopped VM’s loopback SSH port, the next barn start or barn up picks a free port and updates ~/.ssh/barn_config; and host keys are pinned per VM instance UUID, so a recreated node causes no stale known_hosts error.

barn plan says recreate or missing

Symptom: barn plan or barn up lists a node as recreate or missing, or barn recreate fails with exit 4 and reason: nodes_removed.

Check:

barn plan
barn --json plan

Fix:

  • recreate: the node’s definition changed in a way that needs a new root disk. After barn update, this also happens to nodes whose image channel or version prefix now resolves to a newer build. Back up data on the root disk and any non-persistent data disks (what survives), then run barn recreate <node> (--yes in scripts).
  • missing: a node with a VM was removed from the inventory. Restore its entry, or delete the VM with barn destroy <node>. While any node is missing, barn recreate without node names stops before touching any VM.

To rebuild one node, name it: barn plan node-1 and barn recreate node-1 keep the applied definitions of unselected peers, so their unrelated edits can wait. Conflicts in addresses, aliases, control-node roles, or deployment-wide settings must still be resolved. See Apply changes to selected nodes.

Catalog or image verification fails

Symptom: barn update, barn image pull, or barn up exits 7 (error: integrity) with reason: catalog_signature or catalog_equivocation, or an image fails its size, SHA-256, or qcow2 check.

Check:

barn --json update
barn image info <image>      # also verifies a cached copy with qemu-img

Fix: Barn rejects unknown signers, catalog revision rollbacks, size or SHA-256 mismatches, and malformed qcow2 files. Pull from a validly signed repository, such as the default or --mirror. Register your own images with barn image import --sha256 ... rather than copying files into ~/.barn/images. A permission or I/O error while reading a cached signature exits 1 (runtime), not 7; fix the file’s permissions and retry. Trust rules are in Trust and verification.

A command was interrupted

Symptom: Ctrl-C or SIGTERM stopped a command, which exits 130 (cancelled), or the host rebooted in the middle of an operation.

Check:

barn status

If another Barn process holds the deployment lock, status shows a note; wait for that command to finish. Otherwise status checks each recorded QEMU process by PID and start time and repairs the state.

Fix:

Interrupted stateWhat barn status does / what to run
Host rebooted, or an unrelated process reused the QEMU PIDMarks the VM stopped; run barn start
barn stop was interrupted while QEMU kept runningRestores running; run barn stop again if you still want it stopped
Online barn resize was interrupted after changing the live guestReports resize_incomplete; run barn resize <node> again or barn restart <node>
First barn up failed during preparationFix the inventory and run barn up -f barn.yml; Barn rolls back the journaled unfinished artifacts
barn destroy was interruptedRun the same barn destroy or barn purge again to finish

When cancelled, Barn sends SIGTERM to the processes it started (sudo forwards it to privileged commands) and waits at most 10 seconds. A descendant that ignores SIGTERM keeps running until you stop it.

If Barn can’t confirm that a recorded process belongs to the node, or QEMU is alive but its QMP socket is gone, it refuses further changes rather than risk killing an unrelated process. Keep the state directory and the logs (barn logs <node> --source qemu --verbose); don’t delete PID or lock files by hand.

Report a bug

Include the exact command and its exit code, barn version, the host OS and architecture, the QEMU version, and the JSON output of barn doctor, barn network status, and barn status.

1.10 - Build from Source

Build the Barn CLI and the native Barn.app from source to try unreleased changes on main or to reproduce a release.

Build Barn yourself to try changes on main before they are released, or to rebuild a release from its tag. To simply use Barn, install a release instead: it needs neither Go nor Xcode, and the Apple Silicon release already includes a signed Barn.app.

Check out the source

git clone --branch v1.5.0 https://github.com/pgsty/barn.git
cd barn

This checks out the source for Barn 1.5.0. Omit --branch v1.5.0 to follow development on main.

Build the CLI

You need Go 1.27.4 (pinned in go.mod), Git, Make, and Bash. Compiling needs no QEMU and no host network setup.

make build
export PATH="$PWD/bin:$PATH"
barn version

An unstamped build reports version dev, and its commit reads uncommitted if the working tree has changes. On the release tag, use BARN_VERSION=1.5.0 make build to stamp the version.

make build writes the CLI and its matching barn-hosts-helper into bin/.barn-releases/ and links them as bin/barn and bin/barn-hosts-helper. Use it instead of go build ./cmd/barn: the CLI embeds the helper’s SHA-256 and runs only a helper that matches. If you move the build, keep bin/.barn-releases/ next to the two links.

To build all four targets (darwin_amd64, darwin_arm64, linux_amd64, and linux_arm64) into bin/<os>_<arch>/, run make cross.

Build the Mac component

On an Apple Silicon Mac running macOS 27 or later, with Xcode 27 or later selected for xcrun, stop any Mac VMs that use a previous local build, then run:

make mac-build
export PATH="$PWD/bin/mac:$PATH"
barn mac doctor

make mac-build puts a matched set in bin/mac/, namely barn, barn-hosts-helper, the standalone barn-mac-runner, and Barn.app, and also writes bin/barn-mac-darwin-arm64.tar.gz. BARN_VERSION stamps it the same way as make build. Run the CLI from bin/mac so it uses the Barn.app built with it.

The build is ad-hoc signed, which is all you need to run VMs on your own Mac. Developer ID signing and notarization are part of the release procedure. Continue with the macOS guide to create a VM.

Run the tests

make test

Before opening a pull request, run the full make check gate with the pinned linters. Contributing lists the tools and what each target covers.

1.11 - Uninstall and Clean Up

Remove Linux and macOS VMs deliberately, then clean up integrations, images, networking, and the application.

Use this page to remove part of what Barn created, or all of it. Linux labs and macOS VMs are managed separately, so barn purge never touches Mac VMs. Keep the barn CLI installed until the last step, because the cleanup commands need it.

Choose what to remove

RemoveRunWhat is kept
Nothing yet, just stop the VMsbarn stop; barn mac stop --allEverything, disks included
One Linux nodebarn destroy <node>The other nodes, that node’s persistent disks, keys, images, host network
The Linux labbarn destroyPersistent disks, deployment keys, cached images, host network
The Linux lab, its persistent disks, and keysbarn purge (deletes immediately; --ask to confirm first)Cached images, host network
Named Mac VMsbarn mac destroy <name...> (asks you to confirm)Other Mac VMs, cached macOS images
Barn’s SSH, /etc/hosts, and clock-sync integrationsStep 2Your own ~/.ssh/config and /etc/hosts entries
Cached imagesbarn image prune --yes; barn mac image prune --installers --yesImages a VM still uses, and the default macOS base
The Linux host networkbarn network uninstall --yes (after all Linux VMs are gone)—
Barn itselfStep 5~/.barn, until you delete it

Before destroying anything, check names with barn status (Linux) and barn mac ls (Mac), and copy files you want to keep to the host. What survives each operation has the per-command detail for data disks.

Full teardown steps

  1. Destroy Linux and Mac virtual machines

    Discard the whole Linux lab, persistent disks and deployment keys included:

    barn purge

    It deletes immediately. To review the VM list and scope first, run barn purge --ask and answer y/yes or n/no; purge accepts no --yes, -y, or --force. Then list and destroy any macOS VMs by name:

    barn mac ls
    barn mac destroy mac1 dev
  2. Remove SSH, /etc/hosts, and timer integrations

    Destroying the whole Linux deployment already removes the default ~/.ssh/barn_config integration. Remove anything else you installed: a custom-named SSH fragment, /etc/hosts entries, Mac SSH aliases, or the clock-sync user timer:

    barn ssh-config --remove --name lab
    barn hosts uninstall --json
    barn hosts uninstall --yes
    barn mac ssh-config --remove
    barn time auto disable

    Each command removes only the block Barn wrote.

  3. Prune cached images

    Preview, then delete, cached Linux and macOS images:

    barn image prune --dry-run
    barn image prune --yes
    barn mac image prune --installers
    barn mac image prune --installers --yes
  4. Uninstall Linux host networking

    The shared Linux host network can be removed only while no Linux VM is running. Mac VM networks go away by themselves when each VM stops.

    barn network uninstall --json
    barn network uninstall --yes

    On hosts that use systemd-networkd, the uninstall leaves networkd’s global unit state alone when other links exist or Barn cannot confirm it is the only user; the plan reports preserve_networkd, and the result explains the decision in checks.networkd.

  5. Uninstall the Barn application and remaining state

    If a package manager installed Barn, remove the package:

    Homebrew
    brew uninstall barn
    Debian / Ubuntu
    sudo apt remove barn
    RHEL / Fedora
    sudo dnf remove barn
    • User-scoped install.sh: remove barn, barn-hosts-helper, .barn-current, .barn-releases/, and .barn-install.lock from ~/.local/bin, and the PATH line from your shell rc file.
    • Manual archive or source build: with all Mac guests stopped, remove the extracted release directory, bin/mac, or any copied Barn.app (Barn Mac.app in 0.9.0), plus ~/Library/Preferences/com.pgsty.barn.plist (io.pgsty.barn.mac-runner.plist in 0.9.0).
    • Manually installed hosts helper: if you installed /opt/barn/libexec/barn-hosts-helper by hand and no other user on the host uses Barn, remove it after barn hosts uninstall --yes.
Warning

Delete ~/.barn (or your custom BARN_HOME) only after both Linux and Mac VMs are destroyed. It holds VM state, keys, persistent disks, and base images for both. If a VM is still running or a destroy failed, resolve it with barn status / barn mac ls before deleting the directory.

2 - Reference

Exact syntax, options, defaults, output formats, and file layouts for every part of Barn.

Look things up here once you know what you want to do. The Guides explain how to do it.

  • Command Reference — Every Linux and macOS command with its options, defaults, examples, and the version that added it.
  • Linux Configuration — The inventory format, every vm_* variable and default, data disks, shares, and drift rules.
  • CLI Contracts — Output modes, the JSON envelope, lifecycle results, and exit codes shared by all commands.
  • Mac Runtime Reference — The barn mac machine model, networks, JSON schemas, failure reasons, and files on disk.
  • Linux Images — The image catalog, aliases, signature checks, local imports, and cache pruning.
  • Image Pipeline — Contributor tooling for validating and normalizing new qcow2 images.

Barn’s public interface is the barn command; Go packages under internal/ may change between releases. barn COMMAND --help shows the options of the build you have installed.

2.1 - Command Reference

Every Barn command with syntax, all local options, defaults, examples, and version availability.

Find a command below for its arguments, complete local option table, examples, and effects. This reference follows the command-index and command-family organization of PIG. Barn’s CLI contracts describe structured output and exit codes; Configuration defines inventory fields.

Version baseline

This reference covers the Barn 1.5.0. Its command names and flags remain compatible with 1.4.0. Release notes

LabelAvailabilityBehavior
1.1.0Options available across 1.1.0–1.5.01.1.0 used 2 vCPUs / 4 GiB by default and accepted CPU/memory resize through the inventory
1.2.0Added in 1.2.0Resource flags and environment overrides, vm_scale, root-disk growth, lifecycle --parallel, vm_hosts, and hosts install -f; defaults are 1 vCPU / 2 GiB
1.3.0Added in 1.3.0barn time manual, startup, and scheduled guest clock synchronization; shorthand family and architecture-suffixed image aliases (el10a, d13x); embedded catalog 2026112101; macOS 27.2.1 base and macOS network setup/repair fix
1.4.0Added in 1.4.0barn image update, catalog signing key rotation, Debian 13.8 on both architectures, and immediate power-off during Linux purge
1.5.0Changed in 1.5.0New labs use d13. repo build can infer image metadata from filenames, and official catalogs use catalog.json.sig.

To preserve the 1.1.0 resource defaults when upgrading from 1.1.0, set vm_cpu: 2 and vm_mem: 4GiB explicitly and inspect barn plan. Existing applied VMs keep their resources until a resource-changing operation is requested. Use barn version and barn COMMAND --help to check an installed build. See the release notes and release acceptance.

Command index

TaskCommands and detailed reference
Preparesetup, init, validate, doctor
Plan and createplan, up
Start and stopstart, stop, restart, reload
Change and inspectresize, recreate, status
Deletedestroy, purge
Access Linux guestsssh, exec, logs, provision, ssh-config
Publish host nameshosts install, hosts uninstall
Synchronize clockstime status, sync, auto
Refresh catalogupdate, image sync, image reset
Manage Linux imagesimage list, info, pull, update (1.4.0), import, prune
Maintain a repositoryrepo scan, build, verify
Host networknetwork status, install, uninstall
Native macOS VMsmac ls, up, start, stop, restart, configure, recreate, destroy
Mac accessmac open, ssh, exec, password, ssh-config, logs
Mac preparationmac setup, doctor, image ls, image update, image prune
CLI utilitiesversion, completion, help

Global options

barn [--json|--yaml] [-v|--verbose] COMMAND [arguments] [local options]
OptionMeaning
-h, --helpHuman-readable help for the selected command; exits 0
--jsonStructured JSON on stdout; progress and diagnostics stay on stderr
--yamlStructured YAML on stdout; mutually exclusive with --json
-v, --verboseBounded diagnostics on stderr
--versionRoot-command shortcut to display build identity; use barn version --json for a structured report

Global output options can appear before or after a subcommand, but must precede the remote-command -- separator used by ssh and exec. -f, -I, -A, -p, and --yes are local options: consult the selected command’s table. -f means follow for logs; -n means line count for mac logs. Long boolean options accept =true or =false.

BARN_OUTPUT and BARN_VERBOSE set presentation defaults. BARN_HOME selects private state (default ~/.barn); use an absolute path when changing directories. Linux and Mac machines share that data root but have independent lifecycles. See environment variables and exit codes.

barn and help

barn
barn --help
barn help resize
barn image pull --help
barn --json

With no arguments, text mode prints complete help and exits 0; JSON/YAML mode returns suggested actions[]. Explicit help always prints human-readable text. Groups image, repo, network, hosts, time, time auto, and mac image require a subcommand and exit 2 without one. The mac group is the exception: it defaults to mac ls. It is hidden from root help on Linux and Intel Macs, while explicit Mac help remains available.

Short aliases are scoped to their parent. barn im ls is barn image list; barn mac st is barn mac ls. The per-command pages list each alias. There is no rm alias for purge.

2.1.1 - Preparation and Utilities

Prepare the host with barn setup, write and validate inventories, diagnose the host, and print the version or completion scripts.

barn setup prepares a host to run Linux VMs: it installs QEMU and UEFI firmware, creates the fixed-IP network the nodes share, and writes an inventory if you have none. This page also covers init, validate, doctor, version, and completion. Every command accepts the global options; Available in shows availability from the 1.1.0 baseline onward (version baseline).

barn setup

barn setup [meta|dual|trio|full] [flags]

On a terminal, the first barn up runs this preparation itself and asks once. Run barn setup directly to preview the changes, to prepare a host from a script or CI job, or to get ready before the first up. It creates no VMs and downloads no base images; barn up does that.

barn setup --dry-run              # print the plan, change nothing
barn setup                        # print the plan, ask, then apply
barn setup full -I el9 --yes      # generate a four-node EL9 lab without asking
barn setup -f pigsty.yml --yes    # prepare the host for an existing inventory
barn up

Aliases: s.

What setup changes

Setup skips steps that are already satisfied and prints the whole plan before the first change:

StepWhat it doesRoot
dependenciesInstalls missing QEMU, qemu-img, UEFI firmware, and OpenSSH: brew install qemu on macOS (Homebrew required), apt-get or dnf on LinuxLinux only
capabilitiesRuns the host checks of barn doctorNo
networkInstalls or repairs the fixed-IP network: socket_vmnet as a root service under /opt/barn on macOS, the barn0 bridge through NetworkManager or systemd-networkd on LinuxYes
verifyRe-checks the installed networkNo
configWrites the generated inventory, or uses the existing oneNo

The network step needs root because it changes host networking; in return, QEMU itself runs as you. /etc/hosts is not part of setup: the first barn hosts install installs its root-owned helper, which is why setup reports the hosts-helper step as on-demand.

On macOS, socket_vmnet comes from the first of BARN_VMNET_ARCHIVE, Barn’s cache, Homebrew, or a SHA-256-pinned download from the selected repository or github.com/lima-vm; --mirror and --repo change the download source. Behind a proxy, setup passes HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY (either case) through sudo to apt-get and dnf. On Linux, setup installs only the host-architecture emulator; for foreign-architecture guests, install the other qemu-system-* package and its UEFI firmware yourself.

sudo and confirmation

Run setup as your normal user. It asks for your password at most once, at the first root step, after printing why; Homebrew runs as you. On a terminal, setup shows the plan and asks Continue with this setup? [Y/n], unless nothing needs to change.

  • --yes skips that question and is required without a terminal, where setup otherwise exits 2. It cannot answer sudo: without a terminal, sudo must work without a password, or setup exits 3 with reason sudo_unavailable (troubleshooting).
  • --dry-run prints the plan and changes nothing; its next: line is the command that applies it. It cannot be combined with --yes.
  • barn --json setup reports ready, blocked, steps[], dependencies (with missing[] and the exact package-manager commands[]), network, and next/next_argv.

Which inventory it prepares

With no template and no -f, setup reuses the first discovered inventory or writes the meta template to ./barn.yml. A template (meta, dual, trio, or full, with 1 to 4 nodes) generates that lab; -f prepares an existing file and cannot be combined with a template. -c and the specification flags shape generated templates only: setup rejects them for an existing inventory and ignores the matching BARN_* variables when it reuses one.

If the default subnet is taken and the inventory is a fresh, unedited template, setup picks a free private /24 and keeps the original as barn.yml.before-network-change. An inventory you wrote or edited keeps its subnet, and a conflict stops setup.

Options

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-c, --cidr stringgenerated template network as a canonical RFC1918 IPv4 /241.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-d, --dry-runshow the resolved setup plan without changing anything1.1.0
-f, --file stringInventory to prepare; mutually exclusive with a template argument1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-m, --mode stringmacOS fixed-IP network backend: host or shared (default “host”)1.1.0
-r, --repo stringimage repository URL or local directory, also used for socket_vmnet; overrides --mirror and $BARN_REPO1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
-y, --yesaccept the one-time setup plan (required without a terminal)1.1.0

barn init

barn init [meta|dual|trio|full] [flags]

Write an editable, Pigsty-compatible inventory without touching the host. The default is the one-node meta template in ./barn.yml, with the control node at .10; dual, trio, and full add .11, .12, and .13. Existing files are kept unless you pass --force, and -o - prints to stdout.

In 1.5.0, all four templates write vm_image: d13 and vm_arch: native by default. On Barn 1.4.0, pass -I d13 when generating a template to select Debian 13.

Generated nodes get 1 vCPU, 2 GiB of memory, a 64 GiB root disk, and a 128 GiB /data disk, written out as all six specification fields including vm_scale (specification overrides). Barn 1.1.0 templates used 2 vCPUs and 4 GiB (upgrade notes).

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-c, --cidr stringrebase the generated template to a canonical RFC1918 IPv4 /241.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
--forceOverwrite the destination inventory; default preserves existing files1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
-o, --output stringwrite to this path instead of ./barn.yml; ‘-’ writes to stdout1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn init -I d13
barn init full -I d13 -A amd64 -o lab.yml
barn init dual -I d13 -c 10.20.30.0/24 -o -

barn validate

barn validate [flags]

Check an inventory before up. validate checks every field Barn reads and prints the resolved nodes, or the full resolved specification with --json. It requires an inventory file, either -f or the first of barn.yml, barn.yaml, pigsty.yml, and pigsty.yaml in the current directory. In 1.5.0, a readable deployment supplies the same image default as plan. It takes no node names, and overrides apply to this check only. To compare an inventory with the running deployment, use barn plan.

Aliases: v.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringInventory to validate; otherwise use local discovery, with no applied-state fallback1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
-r, --repo stringimage repository whose catalog checks the images; overrides $BARN_REPO1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn validate -f lab.yml
barn --json validate -f lab.yml -I d13 -A arm64

barn doctor

barn doctor [flags]

Check whether this host can run Linux VMs: QEMU, native acceleration, firmware, OpenSSH, a short accelerated boot, and host networking. A missing compute capability exits 3 and prints a fix: line for each problem. A missing network is only a warning, because setup installs it. For network detail, run barn network status; for macOS guests, run barn mac doctor.

Aliases: dt. No options of its own.

barn doctor
barn --json doctor
barn doctor --verbose

barn version

barn version [flags]

Print the version, source commit, build time, OS, and architecture to include in a bug report; barn --version prints the same line. --json returns name, version, commit, built, os, and arch. Source builds without a release stamp report dev.

Aliases: ver. No options of its own.

barn version
barn --json version

barn completion

barn completion [bash|zsh|fish|powershell] [flags]

Print one shell’s completion script to stdout, then install it as shown below. It completes commands, flags, templates, image aliases, and, on a best-effort basis, node names. Regenerate it after upgrading Barn. Use text mode: with --json or BARN_OUTPUT=json, the script arrives wrapped in a {shell, script} object.

No options of its own.

source <(barn completion bash)
barn completion zsh > "${fpath[1]}/_barn"
barn completion fish > ~/.config/fish/completions/barn.fish
barn completion powershell

Implementation

See cmd/barn/command_setup.go for the CLI and internal/setup/ for host preparation. cmd/barn/command_misc.go and cmd/barn/command_root.go define the diagnostic and root commands.

2.1.2 - Linux Lifecycle

Plan, create, start, resize, inspect, and explicitly remove Linux virtual machines.

These commands take a Linux lab from an inventory to running VMs, change it, and tear it down. The Available in column of each option table names the release that introduced the option (version baseline).

Choosing a command

You want toRunWhat happens to disks
See what a change would doplanNothing; read-only
Create the lab, or bring it back after a stop or rebootupKept
Boot, shut down, or reboot existing nodes as they arestart, stop, restartKept
Restart nodes and re-apply the inventory (stop, then up)reloadKept; nodes new in the inventory are created
Change CPU or memory, or grow the root diskresizeKept
Change image, architecture, data disks, network, or sharesrecreateRoot and non-persistent data disks replaced
Remove some nodes, or the whole lab but keep persistent datadestroyDeleted, except persistent data disks
Start over from nothingpurgeEverything deleted, persistent data disks included

The full retention rules are in What survives each operation.

Selecting nodes

Node arguments are resolved node names such as meta and node-1; omit them to select every node the command covers. IP addresses, groups, and vm_alias are not selectors.

plan, up, reload, resize, and recreate read the desired inventory from -f, then the current directory’s inventory, then applied state. The other lifecycle commands work from applied state only, so they run from any directory that uses the same BARN_HOME.

All commands accept the global options. Specification overrides (-I, -A, -C, -M, -S, -D) and their environment variables are defined in Configuration. --parallel appears only in the tables that list it; plan, resize, and status do not accept it. Structured results and exit codes are in CLI contracts.

barn plan

Run plan before up, resize, or recreate to see what they would change. It changes no VM and downloads nothing.

barn plan [node...] [flags]

The plan compares the effective desired inventory with applied state and reports exact images, resources, per-disk actions, and the nodes that need creation, resize, recreation, start, or explicit removal. Catalog images need only local metadata; inspecting a named local image also needs qemu-img.

Exit 0 means a plan was produced, including a plan blocked by nodes missing from the inventory, so automation must inspect action, blocked, and the change arrays (planning output). Explicit selectors keep the applied definitions of unselected peers.

Aliases: pl.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringdesired inventory; defaults to the discovered inventory, then the applied state1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
-r, --repo stringimage repository URL or directory; overrides $BARN_REPO1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn plan
barn plan -f pigsty.yml meta
barn --json plan -I d13 -A amd64

barn up

up is the everyday command: it creates missing nodes, starts stopped ones, and finishes any guest setup left undone, while healthy running VMs keep running.

barn up [node...] [flags]

Unless --no-wait is set, up verifies each guest’s readiness marker over management SSH, corrects guest clock offsets greater than two seconds against the host, and refreshes host SSH aliases and the guests’ host and control-node entries. Non-fatal guest setup or clock-sync problems appear in warnings; ready nodes still succeed.

On an interactive first run, up prepares missing host dependencies and generates meta when no inventory or applied deployment exists. Scripts run setup --yes first.

up never applies a changed node definition: use resize for CPU, memory, or root growth and recreate for anything else. Nodes removed from the inventory stay until you destroy them. --rollback removes only safe, uncommitted artifacts left by preparation failures in this run.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringdesired inventory; defaults to the discovered inventory, then the applied state1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-n, --no-waitreturn once QEMU is running, without waiting for the guest to boot1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
-r, --repo stringimage repository URL or directory; overrides --mirror and $BARN_REPO1.1.0
--rollbackremove safe artifacts from nodes that fail to prepare1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn up
barn up -f pigsty.yml meta
barn up --mirror --rollback
barn up meta --no-wait

barn start

Use start to boot nodes that already exist, from any directory: it reads applied state, not the inventory, and never creates nodes.

barn start [node...] [flags]

Unless --no-wait is set, start waits for SSH and corrects guest clock offsets greater than two seconds. It refreshes SSH access; to retry unfinished guest setup on a VM that is already running, use up. An unavailable host share fails only its node, and independent nodes continue.

OptionMeaning / defaultAvailable in
-n, --no-waitreturn once QEMU is running, without waiting for the guest to boot1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
barn start
barn start meta --no-wait

barn stop

Use stop to shut nodes down and free host CPU and memory; root disks, data disks, keys, and deployment state all stay.

barn stop [node...] [flags]

stop identifies each VM by its recorded process identity. With no names it stops the whole Linux deployment; macOS VMs and the host network keep running.

OptionMeaning / defaultAvailable in
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
barn stop meta
barn stop

barn restart

Use restart to reboot nodes exactly as they were created. Inventory edits are ignored; use reload to pick them up.

barn restart [node...] [flags]

restart stops and starts existing nodes from applied state, then waits for SSH and checks guest clocks unless --no-wait is set.

OptionMeaning / defaultAvailable in
-n, --no-waitreturn once QEMU is running, without waiting for the guest to boot1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
barn restart
barn restart meta --no-wait

barn reload

Use reload to restart nodes after editing the inventory: Barn re-reads it, stops the selected nodes, and runs up, so nodes you added are created in the same step.

barn reload [node...] [flags]

reload validates the desired specification and startup dependencies before it stops anything. Changes that need resize or recreate, and applied nodes missing from the inventory, fail this preflight while every VM keeps running. To reboot with the recorded configuration only, use restart.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringdesired inventory; defaults to the discovered inventory, then the applied state1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-n, --no-waitreturn once QEMU is running, without waiting for the guest to boot1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
-r, --repo stringimage repository URL or directory; overrides --mirror and $BARN_REPO1.1.0
--rollbackremove safe artifacts from nodes that fail to prepare1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn reload -f pigsty.yml
barn reload meta --mirror

barn resize

Use resize to change CPU or memory, or grow the root disk, without losing anything on the VM: its identity, disks, and SSH keys stay.

barn resize [node...] [flags]

Desired resources come from the inventory, environment variables, or CLI overrides; CLI overrides do not rewrite the inventory. Supported CPU and memory increases are hot-plugged; decreases and changes the VM cannot take live fall back to a stop and start. Image, architecture, data-disk, network, and share changes need recreate; new nodes need up, and removed nodes need destroy.

-D 128GiB grows the existing root to 128 GiB. Barn stops QEMU, expands the image, boots the guest to grow and verify its last plain ext4/XFS root partition, and returns a VM that was stopped to stopped. The target can only grow the disk and must align to 512 bytes. After an interruption, repeat the same target. Shrinking, LVM, encrypted roots, and roots that are not the last partition are unsupported; see root growth and recovery.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringdesired inventory; defaults to the discovered inventory, then the applied state1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
barn plan -f pigsty.yml meta
barn resize -f pigsty.yml meta
barn --json status meta

barn recreate

Use recreate for changes resize cannot make, such as a new image, architecture, data-disk layout, network, or shares: Barn rebuilds the selected VMs from the desired inventory.

Warning

recreate deletes the selected nodes’ root disks and non-persistent data disks, and everything stored on them. Only compatible persistent data disks are reattached. Run barn plan first to see which nodes it replaces; What survives each operation has the full rules.

barn recreate [node...] [flags]

On a terminal you type recreate to confirm; scripts pass --yes or --force (there is no -y).

Without selectors recreate applies the whole inventory, and fails before stopping any VM if the inventory omits an applied node: destroy that node explicitly or add it back. Selected recreation keeps unselected peers as they are. A successful recreate also refreshes SSH access.

Aliases: rc.

OptionMeaning / defaultAvailable in
-A, --arch stringoverride deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.01.1.0
-C, --cpu stringBase vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU1.2.0
-D, --disk stringAbsolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK1.2.0
-f, --file stringdesired inventory; defaults to the discovered inventory, then the applied state1.1.0
--forcerecreate without the interactive confirmation (required without a terminal)1.1.0
-I, --image stringoverride vm_image/vm_version for selected nodes; environment overrides require 1.2.01.1.0
-M, --mem stringBase memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM1.2.0
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-n, --no-waitreturn once QEMU is running, without waiting for the guest to boot1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
-r, --repo stringimage repository URL or directory; overrides --mirror and $BARN_REPO1.1.0
-S, --scale stringInteger 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE1.2.0
--yessame as --force1.1.0
barn plan meta
barn recreate meta
barn recreate -f pigsty.yml meta --yes

barn status

Use status to check what is running and how each node is configured, from any directory.

barn status [node...] [flags]

status shows recorded node configuration and live QEMU process identity. running means a verified VM process, not a successful SSH probe. --verbose adds runtime details; --json exposes node records, notes on active operations, and failures. A degraded node makes the command exit 5 while healthy peers are still listed. Text output shows compact SPEC values such as 2c4g.

Aliases: st.

No local options beyond --help; global presentation options still apply.

barn status
barn status meta --verbose
barn --json status

barn destroy

Use destroy to remove nodes you no longer need, or the whole Linux lab while keeping persistent data disks for a later rebuild.

Warning

destroy deletes the root disks and non-persistent data disks of the selected nodes, or of every node when you pass no names. Persistent data disks are kept unless you add --delete-persistent; --purge also deletes them along with SSH keys and deployment state. See What survives each operation.

barn destroy [node...] [flags]

On a terminal you type destroy to confirm; scripts pass --yes or --force (there is no -y). --delete-persistent and --purge work only on the whole deployment. The image cache, the host network, and native Mac VMs remain.

Removing the control node makes the first remaining node the control node; update admin_ip and run up to configure its control SSH access.

Aliases: de.

OptionMeaning / defaultAvailable in
--delete-persistentalso delete owned persistent data disks1.1.0
--forcedestroy without the interactive confirmation (required without a terminal)1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
--purgeterminal disposal: also delete persistent disks, keys, and deployment state1.1.0
--yessame as --force1.1.0
barn destroy meta
barn destroy --yes
barn destroy --yes --purge

barn purge

barn purge and barn destroy --yes --purge immediately power off running Linux VMs before deleting their disks. Run barn stop first to give databases and other guest services time to shut down.

Use purge to start over: it deletes the entire Linux deployment in one step, without reading an inventory. It is also how you remove retained persistent data disks once no deployment state is left.

Caution

purge deletes immediately, with no confirmation unless you pass --ask: every node’s root disk, all persistent data disks, SSH keys, deployment state, and the default SSH fragment. See What survives each operation.

barn purge [flags]

purge takes no node names and has no --yes, -y, or --force. --ask shows the deletion scope first and proceeds only on y or yes; Enter cancels. Cached images, host networking, and Mac VMs remain. Without an applied deployment, purge still removes leftover deployment data under BARN_HOME, such as retained persistent data disks and keys, and succeeds when nothing is left; artifacts whose ownership Barn cannot verify block deletion. --parallel controls node work during disposal.

OptionMeaning / defaultAvailable in
--askshow the deletion scope and ask for y/yes before purging1.1.0
-p, --parallel intNode concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit1.2.0
barn purge --ask
barn --json purge

Implementation

See cmd/barn/command_lifecycle.go for lifecycle commands and TestPlanKeepsAnExistingLabsImageDefault in cmd/barn/lifecycle_overrides_test.go for upgrade behavior.

2.1.3 - Guest Access and Hosts

Open a shell on Linux guests, run commands and scripts, read logs, and publish SSH aliases and /etc/hosts names.

These commands reach running Linux guests from the host: ssh and exec run a shell or one command, provision streams a script to several nodes, and logs shows what a node printed. ssh-config and hosts publish node names so other host tools can reach the nodes too. Every command accepts the global options; Available in shows availability from the 1.1.0 baseline onward (version baseline).

Remote commands and --

barn ssh and barn exec share one argument rule: Barn flags and at most one node name, then --, then the remote command. They differ in what the guest receives:

barn ssh  [node] [-- command...]   # words joined into one line for the guest shell
barn exec [node] -- command...     # program and arguments passed separately
barn ssh meta -- …barn exec meta -- …
Guest receivesOne string, parsed by the guest shell, as with plain sshThe program and its arguments, with no shell
Pipes, ;, $VARWork; quote them so your local shell leaves them aloneWrap the command in sh -c '…'
Spaces, quotes, empty argumentsRe-parsed by the guest shellPreserved exactly
No commandOpens an interactive login shellFails: exec requires -- and a command
  • Before --: Barn flags such as --json, plus an optional node name. It must be a resolved node name, not an IP address, alias, or group; an unknown name exits 2. Without one, Barn picks the prepared control node, or else the first prepared node.
  • After --: everything goes to the guest, including a second -- and anything that looks like a Barn or OpenSSH flag. The first word must not be empty. For compatibility, exec also accepts one quoted string and hands it to the guest shell.
  • Exit status: Barn exits with the remote command’s status, so exit 17 in the guest makes barn exit 17. Check whether a nonzero code came from the guest before reading it as a Barn error class.
barn ssh meta -- 'df -h /data; id'           # a shell line, quoted like plain ssh
barn exec meta -- printf '<%s>\n' 'a b' ''   # 'a b' stays one argument; '' is kept
barn exec meta -- sh -c 'uptime; id'         # shell features through sh -c

barn ssh

barn ssh [flags] [node] [-- command...]

Open an interactive shell on a node, or run a shell line there (argument rules). With --json, session output goes to stderr and the final report to stdout.

No options of its own.

barn ssh
barn ssh meta
barn ssh meta -- 'df -h /data; id'

barn exec

barn exec [flags] [node] -- command...

Run one command on a node with no shell in between (argument rules); scripts and agents should use this form. Text mode passes the guest’s output and exit status straight through. With --json, the report has success, exit_code, stdout, and stderr.

Aliases: ex. No options of its own.

barn exec meta -- hostname
barn exec meta -- printf '<%s>\n' 'a b' ''
barn --json exec meta -- sh -c 'echo out; exit 17'

barn logs

barn logs [node] [flags]

Read a node’s log; start here when a node does not become ready (troubleshooting). --source serial (the default) reads the guest serial console and qemu reads QEMU diagnostics, with the QEMU argv shown only under --verbose. Both take one node and default to the prepared control node, or else the first prepared node. events reads the deployment-wide, bounded Barn event log, including setup; it takes no node and works before any deployment exists.

--follow keeps streaming: raw bytes in text mode, NDJSON with --json, and a YAML document stream with --yaml. Here -f means --follow, not --file.

Aliases: l.

OptionMeaning / defaultAvailable in
-f, --followcontinue streaming appended log data1.1.0
-s, --source stringlog source: serial, qemu, or events (default “serial”)1.1.0
barn logs meta
barn logs meta --source qemu
barn logs --source events --follow
barn --json logs meta --follow

barn provision

barn provision [node...] [flags]

Run a local Bash script on running nodes, for example to bootstrap or check several at once; with no node names, it runs on all of them. Barn streams the script over the deployment’s verified SSH connection, so no copy stays on the guest, and records its SHA-256. It never creates or starts VMs.

--script is required. Nodes run one at a time unless you raise --parallel, which must be positive: unlike lifecycle commands, provision rejects 0. --timeout bounds the whole operation. --sudo runs the script through sudo -n, so the guest user needs passwordless sudo, as official images provide. --json returns script.sha256 and per-node results[] with node, success, exit_code, stdout, and stderr; if only some nodes fail, the exit code is 5.

OptionMeaning / defaultAvailable in
-p, --parallel intPositive concurrency limit; default 1; zero is invalid1.1.0
-s, --script stringlocal Bash script to stream to each selected guest1.1.0
--sudorun the guest script through sudo -n1.1.0
-t, --timeout durationhard deadline for the operation (default 1h0m0s)1.1.0
barn provision --script ./check.sh meta
barn provision --script ./bootstrap.sh --sudo --parallel 2 --timeout 30m

barn ssh-config

barn ssh-config [node...] [flags]

Print the deployment’s OpenSSH config fragment, which lets plain ssh, scp, and other OpenSSH tools reach nodes by name (ssh meta). Lifecycle commands such as barn up keep the default fragment, ~/.ssh/barn_config, current, so you rarely need this by hand. Use it to inspect the fragment, to limit it to some nodes, or to install another one with --name.

--install writes the fragment and adds one Include line to ~/.ssh/config. --remove removes only the fragment and Include installed under that name; it needs no deployment, takes no node names, and cannot be combined with --install. If ~/.ssh/config cannot be edited safely, for example because it is a symlink, Barn writes the fragment and prints the Include line for you to add.

Aliases: sc.

OptionMeaning / defaultAvailable in
-i, --installinstall the deployment fragment and one Include in ~/.ssh/config1.1.0
--name stringSSH Host and fragment prefix (default “barn”)1.1.0
--removeremove the Include and fragment Barn installed1.1.0
barn ssh-config
barn ssh-config --install meta
barn ssh-config --install --name lab
barn ssh-config --remove --name lab

barn hosts install

barn hosts install [flags]

SSH aliases help only OpenSSH tools. To let browsers, psql, and other host programs resolve node names and aliases, publish them in a Barn-owned block of /etc/hosts; barn up does not do this.

By default, the block lists the applied nodes’ names and aliases. Since 1.2.0, -f pigsty.yml publishes the inventory’s nodes plus all.vars.vm_hosts instead, even before the VMs exist (local service names). Each run replaces the whole block, so a later run without -f drops names that came only from the inventory.

On a terminal, Barn shows the change and asks Apply this /etc/hosts change? [Y/n]. Without a terminal, or with --json or --yaml, it only prints the plan; --yes applies it without asking, though sudo may still want a password. Barn edits the file through a root-owned helper, /opt/barn/libexec/barn-hosts-helper, which it installs on first use and verifies by digest. A block that is already current needs no privilege.

Aliases: i.

OptionMeaning / defaultAvailable in
-f, --file stringInventory nodes, aliases and vm_hosts; usable before VM creation1.2.0
-y, --yesapply the displayed privileged plan without confirmation (sudo may still ask for a password)1.1.0
barn hosts install --json
barn hosts install --yes
barn hosts install -f pigsty.yml --yes

barn hosts uninstall

barn hosts uninstall [flags]

Remove the Barn-owned block from /etc/hosts, keeping every other line. It needs no inventory or deployment. Confirmation works as for hosts install, except that the terminal question, Remove the Barn block from /etc/hosts? [y/N], defaults to no.

Aliases: u.

OptionMeaning / defaultAvailable in
-y, --yesapply the displayed privileged plan without confirmation (sudo may still ask for a password)1.1.0
barn hosts uninstall --json
barn hosts uninstall --yes

Implementation

command_root.go · command_access.go · main.go

2.1.4 - Guest Time Synchronization

Measure Linux guest clocks against the host, correct them, and enable optional scheduled checks.

While the host sleeps or a VM is paused, the guest does not run, so its clock falls behind the host’s; in an offline lab, guest NTP has no source to correct it. barn time measures each Linux guest against the host clock and sets it over management SSH, so it works without guest Internet access. Barn checks clocks on demand with barn time sync, when up, start, restart, reload, or recreate brings guests to ready, and, if you opt in, every minute from an OS timer.

The guest side needs Python 3.6 or later and passwordless sudo. barn time is new in 1.3.0 (version baseline), acts on the deployment that BARN_HOME selects, and accepts the global options.

Measure and correct clocks

barn time status
barn --json time status meta node-1
barn time sync
barn time sync meta node-1 --timeout 30s

status measures; sync sets each guest clock to the host’s, forward or backward, and measures again. Without node names, both cover the whole applied deployment and skip stopped, exited, and uncreated nodes, which is not a failure. Results show the offset (positive means the guest is ahead), its uncertainty (half the round trip), and the guest’s NTP synchronization state, service, and source before any change.

A backward step moves application wall time backward too, so choose the moment deliberately when time-sensitive workloads run in the guest.

CommandOptionDefaultMeaningAvailable in
time status [node...]--timeout1mTotal deadline, from 1s to 10m1.3.0
time sync [node...]--timeout1mTotal deadline, from 1s to 10m1.3.0

Barn checks the VM process, the instance SSH identity, and the guest readiness marker, takes three samples, and uses the one with the shortest round trip, compensating for transport time with the guest’s monotonic clock. A measurement fails if all three round trips exceed 250 ms, and a sync fails if more than 500 ms of offset remains afterwards. Nodes fail independently, each with its own error, and any failure makes the exit code nonzero.

Startup checks

up, start, restart, reload, and recreate check the guests they bring to ready and correct offsets above two seconds before returning, so a barn provision that follows sees the corrected time; services already enabled in the guest may start earlier during boot. A failed check does not fail the command: it appears in the lifecycle result’s top-level warnings[] with code time_sync, and its next suggests barn time sync for the affected nodes. --no-wait skips the check.

Scheduled checks

Enable the timer when the host sleeps often or VMs stay paused between sessions:

barn time auto enable
barn time auto status
barn --json time auto status
barn time auto disable

enable installs a timer for the invoking Unix user that records the executable path, BARN_HOME, and PATH. Run it from an installed binary, and again after moving Barn or switching BARN_HOME. The timer checks every running Linux guest of the recorded BARN_HOME, whatever the current directory or inventory.

HostSchedulerJob files
macOSlaunchd calendar job~/Library/LaunchAgents/com.pgsty.barn.time.plist
Linuxsystemd user timer and oneshot service${XDG_CONFIG_HOME:-~/.config}/systemd/user/barn-time-sync.{timer,service}

A check runs every minute for at most 45 seconds, corrects offsets above two seconds, and skips the deployment while another barn command holds its lock. Missed checks run after the host resumes, but the timer never wakes the host, and it needs the user’s launchd session or systemd user manager to be running.

If drift returns within ten minutes of a correction while the guest ran continuously and its NTP reports synchronized, the guest’s NTP source disagrees with the host. Barn reports source-conflict and stops correcting that node automatically, so the two do not keep pulling the clock apart. Host sleep, VM pause, and guest reboots do not count; the guest’s monotonic clock tells them apart. To clear the conflict, align the guest’s NTP source with the host or run barn time sync; an offset back within the threshold or a guest reboot also clears it.

status shows whether the job files are installed and the scheduler has them active, plus the latest result from $BARN_HOME/time-last.json, which each run replaces. Correction history lives in $BARN_HOME/time-sync.json; Barn prunes it when nodes or deployments are destroyed, and barn purge removes it with time-last.json. disable stops the timer and removes its job files; manual and startup checks keep working.

Host NTP and offline Pigsty

barn time corrects the clock but gives the guest no NTP source, so Pigsty’s node_timex_sync_status need not become 1. For continuous synchronization in an offline lab, serve time from the host: macOS ships sntpd, disabled by default, and Linux can use chronyd. Let the server fall back to its local clock when no upstream source is reachable, and allow only the lab network. Pigsty rewrites the Chrony configuration when it deploys NODE, so point the guests at the host’s .1 address on the lab /24 through node_ntp_servers in the Pigsty inventory. Once Chrony keeps the guests synchronized, you can disable the Barn timer and keep barn time sync for manual corrections.

Implementation

command_time.go · timesync · timejob

2.1.5 - Image Commands

Refresh signed catalogs, inspect or download images, import local files, and prune caches.

Refresh signed catalogs, inspect or download images, import local files, and prune caches.

barn image update is available from 1.4.0. Version baseline · Global options

Official repositories and HTTP sources require a trusted detached signature. An explicitly selected custom HTTPS repository or local directory can be unsigned, provided the source is exactly that repository’s catalog.json. Any supplied signature must verify. See catalog trust.

barn update

barn update [flags]

Fetch catalog.json and its signature when required by repository policy, verify trust and revision rules, then atomically activate the catalog. Ordinary commands read local metadata. A newly built local repository can be read directly before its first explicit update. Remote catalogs require an explicit refresh. This updates image metadata, not the Barn executable. Repository precedence is --repo > --mirror > BARN_REPO > the global official repository. See repository selection and trust.

OptionMeaning / defaultAvailable in
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-r, --repo stringimage repository URL or directory; overrides --mirror and $BARN_REPO1.1.0
barn update
barn update --mirror
barn --json update --repo /srv/barn

barn image list

barn image list [flags]

List every catalog architecture and registered local image. It has no image selector or architecture filter. The active local catalog is used; run barn update explicitly to refresh it. Aliases barn images and barn im select the same image command group.

Aliases: ls.

OptionMeaning / defaultAvailable in
-r, --repo stringimage repository URL or directory; overrides $BARN_REPO1.1.0
barn image list
barn --json image list
barn image list --repo /srv/barn

barn image info

barn image info [image[:channel]|image@version-prefix] [flags]

Inspect metadata and verified cache state for one image, using the catalog default if omitted. Select a family (d13), shorthand family alias (e/el/rocky → el10, u/ubuntu → u26, d/debian → d13), architecture-suffixed alias (el10a, d13x, da), channel (d13:stable), or numeric version prefix (el9@9). Architecture defaults to native; an explicit -A arm64 agrees with d13a, while -A amd64 or -A native conflicts with it (exit 2). The compatibility spelling --architecture/-a is also accepted for --arch/-A. It does not download the artifact. Supported aliases and exact embedded versions are in Linux images.

Aliases: in.

OptionMeaning / defaultAvailable in
-A, --arch stringartifact architecture (defaults to native): native, amd64 (x86_64, x64), or arm64 (aarch64, a64)1.1.0
-r, --repo stringimage repository URL or directory; overrides $BARN_REPO1.1.0
barn image info
barn image info el10a
barn image info d13 -A arm64
barn --json image info el9@9

barn image pull

barn image pull [image[:channel]|image@version-prefix] [flags]

Download the selected artifact and verify its SHA-256, byte size, qcow2 structure, and virtual capacity before activating the cache entry. Omitted image and architecture select the catalog default and native host architecture. Shorthand family and architecture-suffixed aliases such as el10a and d13x work here as well (a matching -A is accepted, a conflicting architecture or explicit native exits 2). Existing valid cached bytes are reused. The catalog’s upstream URL is provenance, not a download fallback. --architecture/-a remains a compatibility alias. A foreign artifact does not install the corresponding QEMU emulator.

Aliases: p.

OptionMeaning / defaultAvailable in
-A, --arch stringartifact architecture (defaults to native): native, amd64 (x86_64, x64), or arm64 (aarch64, a64)1.1.0
--mirroruse the China official repository at repo.pigsty.cc; overridden by --repo1.1.0
-r, --repo stringimage repository URL or directory; overrides --mirror and $BARN_REPO1.1.0
barn image pull
barn image pull d13 --mirror
barn image pull d13 -A amd64 --repo /srv/barn

barn image update

barn image update [image[:channel]...] [flags]

Barn refreshes the selected repository’s catalog under its trust policy, then downloads and verifies the selected files. With no arguments, it updates the image families and architectures already in the cache. An empty cache results in a catalog refresh only.

To fetch a specific build into an empty cache, name an architecture alias such as d13i (amd64) or d13a (arm64). A bare family such as d13 updates its cached architectures and uses the host architecture for its first download. The default channel is stable. Use image pull for a pinned version such as d13@20261123.2671.1. Existing VMs keep their original base images.

The command alias is u.

OptionEffectAvailable in
-A, --arch stringSelect one architecture, including native, amd64 or arm641.4.0
-d, --dry-runVerify the candidate catalog and preview downloads and requested cleanup without writing local state1.4.0
--pruneAfter successful downloads, remove files eligible under the normal pruning rules1.4.0
--mirrorSelect the China official repository1.4.0
-r, --repo stringSelect a repository URL or directory. Takes precedence over --mirror and BARN_REPO1.4.0
barn image update --dry-run
barn image update d13i d13a
barn image update --mirror --prune --dry-run

--prune applies to the whole cache, including when you name individual images. The active catalog, applied VMs and registered local aliases protect the files they reference. Pruning rules

barn image import

barn image import <path> [flags]

Copy a local regular qcow2 image into the private cache and validate its container, optionally against an expected digest. Relative paths, ~/, and symlinks to regular files are accepted. qemu-img is required; importing does not boot the image, add cloud-init, or change credentials.

A local-* name registers an immutable inventory reference and requires boot mode plus the source login user. Named imports can record a foreign architecture with -A; qcow2 metadata does not identify CPU architecture, and unnamed imports cannot use -A. Set both vm_image and a matching vm_arch when using it. See import and cache rules.

Aliases: i.

OptionMeaning / defaultAvailable in
-A, --arch stringGuest architecture recorded with --name; defaults to native; does not convert the image1.1.0
-b, --boot stringrequired with --name: bios or uefi1.1.0
--name stringImmutable local-* alias; requires --boot and --source-user1.1.0
-s, --sha256 stringoptional expected SHA-2561.1.0
-u, --source-user stringrequired with --name: source image login user1.1.0
barn image import ./base.qcow2
barn image import ./debian-13-generic-arm64.qcow2 --name local-dev --boot uefi --source-user debian -A arm64

barn image sync

barn image sync <url|path> [flags]

Activate a catalog from one exact URL or local file, reading its adjacent .sig signature under the trust policy above. This is the recovery/import path; use update for the configured repository’s normal endpoint. --repo chooses which repository’s active metadata to replace. An unsigned custom source must be exactly <repo>/catalog.json; an arbitrary recovery file requires a trusted signature.

Older revisions require --allow-downgrade. For custom repositories that allow unsigned catalogs, switching from a previously signed catalog to an unsigned one also requires this flag. It never permits an invalid signature or bypasses the official-repository signature requirement and revision-content checks. Future downgrade protection still remembers the highest revision.

Aliases: sy.

OptionMeaning / defaultAvailable in
--allow-downgradeactivate a catalog older than the newest revision seen so far1.1.0
-r, --repo stringRepository whose active catalog is replaced1.1.0
barn image sync /srv/barn/catalog.json
barn image sync --repo /srv/barn /srv/recovery/catalog.json
barn image sync --allow-downgrade /srv/recovery/catalog.json

barn image reset

barn image reset [flags]

Reactivate the catalog embedded in the current binary for the selected repository. It keeps the highest accepted revision used by downgrade protection. Cached images and VM disks are retained; this is not a cache deletion command.

OptionMeaning / defaultAvailable in
-r, --repo stringRepository whose active catalog is reset to the embedded catalog1.1.0
barn image reset
barn --json image reset --repo /srv/barn

barn image prune

barn image prune [flags]

List reclaimable cache files by default. Use --yes to delete the candidates or --dry-run to preview them. The selected active catalog, applied node base-image digests, and registered local aliases protect their referenced images. Recognized staging files and read-only quarantine files such as *.qcow2.corrupt-<timestamp> are also eligible for removal.

Preview with the same repository selection you will use for deletion. Deletion is sequential; an error on a later file does not restore files already removed. See pruning rules.

Aliases: pr.

OptionMeaning / defaultAvailable in
-d, --dry-runshow unreferenced images and stale staging files without deleting1.1.0
-r, --repo stringimage repository URL or directory; overrides $BARN_REPO1.1.0
-y, --yesDelete the listed unreferenced files; mutually exclusive with --dry-run1.1.0
barn image prune --dry-run
barn image prune --repo /srv/barn --dry-run
barn image prune --repo /srv/barn --yes

Implementation

The 1.5.0 image commands are in cmd/barn/command_image.go and cmd/barn/images.go. Catalog verification is covered by internal/image/manifest_test.go.

The version baseline lists changes through 1.5.0.

2.1.6 - Repository Commands

Scan, build and verify a repository of qcow2 images, with optional metadata in repo.yaml.

A static repository has a flat images/ directory and a generated catalog.json. In 1.5.0, barn repo build reads names, versions and architectures from filenames. Add repo.yaml for aliases, channels, nonstandard names or different boot settings. Build a static repository · Repository format

barn repo scan /srv/barn     # inspect the files under images/
barn repo build /srv/barn    # write catalog.json
barn repo verify /srv/barn   # compare the catalog with the images and optional metadata

All three have been available since 1.1.0. Each takes one repository root and has no options beyond the global options.

barn repo scan

barn repo scan <root> [flags]

Report the state of every qcow2 file without changing anything or needing qemu-img:

StateMeaning
trackedSelected by filename inference or repo.yaml, and present
missingReferenced by repo.yaml but absent from images/
untrackedPresent in images/ but not referenced by repo.yaml
unsafeNot a safe regular qcow2 file

--json returns root and the four arrays. The scan exits 0 whenever it completes, even with findings, so a script must check missing and unsafe itself:

barn --json repo scan /srv/barn | jq -e '(.missing + .unsafe) | length == 0'

barn repo build

barn repo build <root> [flags]

Inspect selected images with qemu-img and atomically write catalog.json with the final digests and sizes. A supplied repo.yaml controls selection. A missing or unsafe declared artifact fails the build.

With an explicit revision, increase it when the catalog changes. With the revision omitted, Barn assigns it automatically and preserves the previous bytes on an unchanged rebuild. Upload immutable images before publishing the catalog. Signing and trust rules

barn repo build /srv/barn
barn --json repo build /srv/barn

barn repo verify

barn repo verify <root> [flags]

Rebuild the catalog in memory from the filenames, optional repo.yaml and actual image bytes, and require a byte-for-byte match with the existing catalog.json. Requires qemu-img. Run it before publishing or after copying a repository. It checks consistency only; clients check signatures when they activate the catalog.

barn repo verify /srv/barn
barn --json repo verify /srv/barn

Implementation

The self-hosted repository guide gives a two-command example.

2.1.7 - Host Network Commands

Inspect, install, repair, and remove the fixed-IP network that lets Linux nodes reach each other.

Every Linux node gets two NICs: one reaches the Internet through QEMU’s built-in NAT, and one sits on a fixed /24 where the host and the other nodes reach it at the address your inventory names (why two NICs). These commands manage the host side of that second network, socket_vmnet on macOS and the barn0 bridge on Linux. barn setup and the first interactive barn up install it for you (host preparation); use these commands to check, repair, reconfigure, or remove it.

One network serves all Linux guests on the host; native Mac VMs have their own. install and uninstall print a privileged plan first and, on a terminal, ask before applying it. Without a terminal, or with --json or --yaml, they only print the plan; --yes applies it without asking, though sudo may still want a password.

barn network also answers to n and net. Every command accepts the global options; Available in shows availability from the 1.1.0 baseline onward (version baseline).

barn network status

barn network status [flags]

Show the backend, installed CIDR, ownership, health, and the preflight findings that lifecycle commands check before changing anything. It is read-only. --cidr checks against an expected subnet; without it, status inspects the installed one. For partial or invalid results, see troubleshooting.

On Linux, 1.5.0 checks KVM access, bridge prerequisites and the configured private network. Run barn doctor for the full QEMU capability check.

Aliases: st.

OptionMeaning / defaultAvailable in
-c, --cidr stringOptional expected private /24; otherwise inspect the installed subnet1.1.0
barn network status
barn --json network status --cidr 10.10.10.0/24

barn network install

barn network install [flags]

Install or repair the backend for --cidr: socket_vmnet on macOS in host or shared vmnet mode, or barn0 through the active Linux network manager, which accepts only host. An existing network must match the chosen subnet and mode, so check status before changing either.

On a fresh Mac, run barn setup instead. A first install needs a pinned socket_vmnet archive and a new vmnet interface UUID, which setup supplies; without both --archive and --interface-id, network install exits 3 with reason network_absent and suggests barn setup. Both flags are macOS-only.

Aliases: i.

OptionMeaning / defaultAvailable in
-a, --archive stringmacOS: pinned socket_vmnet archive1.1.0
-c, --cidr stringnetwork: an RFC1918 IPv4 /24 (default “10.10.10.0/24”)1.1.0
-i, --interface-id stringmacOS: persistent vmnet UUID1.1.0
-m, --mode stringmacOS vmnet mode: host or shared (default “host”)1.1.0
-y, --yesapply the displayed privileged plan without confirmation (sudo may still ask for a password)1.1.0
barn network install --json
barn network install --cidr 10.10.10.0/24 --yes

macOS Internet Sharing

Install and repair work while Internet Sharing is on, as long as its vmnet preferences set neither a custom subnet address nor a mask. If the preview cannot read those preferences, it says so, and Barn checks them after you approve, before writing network files or restarting socket_vmnet. A subnet that conflicts with a live interface, route, or node address blocks the plan at preview. Preferences that turn out unreadable, conflicting, or only half set stop the operation before the host changes.

barn network uninstall

barn network uninstall [flags]

Remove Barn-owned network configuration and restore the host settings recorded at install. Stop the Linux nodes first; uninstall refuses while any node is running. The terminal question, Remove the Barn network? [y/N], defaults to no. VM disks and native Mac VM networks stay in place.

Aliases: u.

OptionMeaning / defaultAvailable in
-y, --yesapply the displayed privileged plan without confirmation (sudo may still ask for a password)1.1.0
barn stop
barn network uninstall --json
barn network uninstall --yes

Implementation

The 1.5.0 status checks are in cmd/barn/command_network.go and internal/doctor/network.go.

2.1.8 - macOS Commands

Syntax, options, and examples for every barn mac subcommand.

Syntax, options, and examples for every barn mac subcommand. The machine model, networks, JSON results, and failure reasons these commands share are defined in the Mac Runtime Reference; a guided first run is in macOS Virtual Machines.

Common rules

  • Host. The commands need an Apple Silicon Mac on macOS 27 or later with the matching Barn.app, run as the logged-in desktop user (requirements). At most two macOS VMs run at a time per Mac; starting a third fails with mac_vm_limit.
  • Machine names. A command with an optional [name] uses the only existing machine, or mac1. With several machines and none named mac1, pass a name. configure, recreate, and destroy always need one. start and stop take several names or --all, not both.
  • Sizes. --memory and --disk are binary even when written GB: 16G, 16GiB, and 16GB all mean 16 GiB, and a bare number is bytes. Linux inventory GB is decimal.
  • Confirmation. recreate and destroy print what they will delete and ask you to type the command name. --yes or --force skips the question and is required without a terminal; neither command has a -y shorthand. Commands that download macOS from Apple (up, setup, image update) ask first; -y/--yes skips that question and is required without a terminal.
  • State. Machines live under $BARN_HOME/mac, separate from the Linux inventory. These commands ignore the Linux BARN_IMAGE/BARN_ARCH/BARN_CPU/BARN_MEM/BARN_SCALE/BARN_DISK overrides.

Every option below has been available since 1.1.0.

barn mac ls

Start here to see what exists: every machine with its state, address, SSH readiness, macOS build, resources, and shares.

barn mac ls [flags]

It reads local records and queries running machines; it never creates, downloads, or starts anything. barn mac without a subcommand runs ls. The JSON shape is in ls output.

Aliases: list, status, st.

No local options beyond --help; global presentation options still apply.

barn mac ls
barn --json mac ls

barn mac up

Use up to get a machine running: it creates the machine the first time, starts it afterwards, and returns once SSH and passwordless sudo work.

barn mac up [name] [flags]

The default name is mac1. On a Mac without a prepared macOS base, up first downloads the restore image from Apple after you confirm and installs it once; later machines clone that base in seconds. A --disk size that differs from the prepared base’s capacity installs a matching base first.

Creation options apply only to a new machine. On an existing machine up just starts it; an option that differs from the recorded setting fails with mac_configuration_conflict, and the next: line prints the command to use instead. --share names default to the folder’s last path component, and ~/ expands to your home directory.

--no-wait returns once the VM is running. On a first boot, provisioning may still be in progress; run barn mac up NAME again to wait for SSH and finish initialization before using ssh or exec.

OptionMeaning / defaultAvailable in
--clipboard on|offon/off, true/false, or yes/no; default on, active while the desktop window is focused1.1.0
--cpu intvCPUs, default 4; minimum 2, maximum host logical CPU count1.1.0
--disk sizeBase capacity, minimum 32 GiB; default uses the prepared base, or 100 GiB initially1.1.0
--ipsw stringinstall macOS from this restore image instead of downloading from Apple1.1.0
--memory sizeMemory, default 8 GiB; a whole MiB from 4 GiB to host RAM1.1.0
-n, --no-waitreturn once the VM runs; first boot may still be initializing1.1.0
--openshow the desktop as soon as the VM runs1.1.0
--share [name=]path[:ro]Repeatable [name=]path[:ro|:rw]; default writable, mounted under /Volumes/My Shared Files1.1.0
--subnet stringCanonical private /24, or auto; default selects the first free subnet1.1.0
--user stringGuest administrator; default is the host username, or barn if that name is invalid1.1.0
-y, --yesdownload macOS from Apple without asking (required without a terminal)1.1.0
barn mac up
barn mac up dev --cpu 8 --memory 16G --share ~/src --open
barn mac up build --yes --no-wait

barn mac start

Use start to boot machines that have already completed their first up. It waits for SSH and never creates a machine or downloads anything.

barn mac start [name...] [flags]

Select names or --all, not both. A machine that has not finished its first boot fails with mac_not_initialized: if it is running, watch its first boot with barn mac open NAME; if it is stopped, continue with barn mac up NAME --open. --recovery boots macOS Recovery with its desktop shown and does not wait for SSH.

OptionMeaning / defaultAvailable in
--allstart every machine1.1.0
-n, --no-waitreturn once the VM runs, without waiting for SSH1.1.0
--openshow the desktop as soon as the VM runs1.1.0
--recoveryboot macOS Recovery and show its desktop1.1.0
barn mac start mac1
barn mac start --all
barn mac start mac1 --recovery

barn mac stop

Use stop to shut machines down cleanly through macOS; disks and settings stay as they are.

barn mac stop [name...] [flags]

A machine that has not stopped after two minutes is powered off, and the result says so ("forced": true). --force powers off at once, like holding the power button; unsaved work in the guest is lost.

OptionMeaning / defaultAvailable in
--allstop every machine1.1.0
--forcePower off immediately instead of requesting shutdown; unsaved guest work is lost1.1.0
barn mac stop dev
barn mac stop --all
barn mac stop dev --force

barn mac restart

Use restart to apply settings saved with configure, or to reboot a guest that misbehaves.

barn mac restart [name] [flags]

It shuts the machine down normally and starts it again. It takes at most one name and has no --all.

OptionMeaning / defaultAvailable in
-n, --no-waitreturn once the VM runs, without waiting for SSH1.1.0
--openshow the desktop as soon as the VM runs1.1.0
barn mac restart dev
barn mac restart dev --open

barn mac configure

Use configure to change a machine’s CPUs, memory, shared folders, network, or clipboard setting without touching its disk or account.

barn mac configure <name> [flags]

CPUs, memory, shared folders, and the subnet change only while the machine is stopped; otherwise the command fails with mac_running. The clipboard setting can change anytime. Saved configuration, including a clipboard change, applies at the next start; to toggle clipboard sharing for the current session, use the menu bar.

Omitted options keep their values. --share adds a share or replaces the share of that name; --unshare removes one. --subnet auto moves the machine to the first free subnet, which is the fix for mac_subnet_in_use.

OptionMeaning / defaultAvailable in
--clipboard on|offon/off, true/false, or yes/no; omitted retains the setting1.1.0
--cpu intvCPUs, minimum 2 and maximum host logical CPU count; omitted retains current value1.1.0
--memory sizeMemory, a whole MiB from 4 GiB to host RAM; omitted retains current value1.1.0
--share [name=]path[:ro]Add or replace a named share; repeatable, writable by default, optional :ro or :rw1.1.0
--subnet stringmove to this private /24 network, or auto for the first free one1.1.0
--unshare stringArraystop sharing the named folder (repeatable)1.1.0
barn mac stop dev
barn mac configure dev --cpu 8 --memory 16G --share ~/src
barn mac configure dev --unshare src --clipboard off
barn mac start dev

barn mac recreate

Use recreate to get a clean disk from the base image while keeping the machine’s name and settings, or, with --update, to move the machine to the newest prepared macOS.

Warning

recreate erases the machine’s disk: files, apps, and settings inside the guest are lost. Shared folders on the host are untouched. Copy anything you need off the guest first.

barn mac recreate <name> [flags]

The new machine keeps its name, account, CPUs, memory, disk capacity, shared folders, clipboard setting, and address, and gets a new login password and new SSH keys.

--update clones the default base that barn mac image update prepared, at the machine’s own disk capacity. If the new macOS build is prepared only at another capacity, prepare it first, for example barn mac setup --disk 200G.

OptionMeaning / defaultAvailable in
--forceskip the confirmation (required without a terminal)1.1.0
-n, --no-waitreturn once the VM runs, without waiting for SSH1.1.0
--updateuse the newest prepared macOS base1.1.0
--yesSame as --force; no -y shorthand1.1.0
barn mac recreate dev
barn mac image update --yes
barn mac recreate dev --update --yes

barn mac destroy

Use destroy to delete machines you no longer need.

Warning

destroy powers each named machine off and deletes its disk, SSH keys, password, and settings. The shared macOS base, other machines, and shared folders on the host are kept.

barn mac destroy <name...> [flags]

Explicit names are required. Run barn mac image prune afterwards to remove bases that no machine uses.

OptionMeaning / defaultAvailable in
--forceskip the confirmation (required without a terminal)1.1.0
--yesSame as --force; no -y shorthand1.1.0
barn mac destroy dev
barn mac destroy mac1 mac2 --yes

barn mac open

Use open to see and use the machine’s desktop; it starts a stopped machine first.

barn mac open [name] [flags]

Closing the window keeps the machine running in the background, and the clipboard is shared while the window is focused. A running machine that has not finished its first boot can be watched here; for a stopped one, use barn mac up NAME --open.

No local options beyond --help; global presentation options still apply.

barn mac open
barn mac open dev

barn mac ssh

Use ssh for an interactive shell in the machine, or to run a shell command line in it.

barn mac ssh [flags] [name] [-- command...]

Without a command, ssh opens an interactive session. A command after -- is joined into one line for the guest shell, as plain ssh does, and its exit status is returned. Argument rules are in SSH and exec.

No local options beyond --help; global presentation options still apply.

barn mac ssh dev
barn mac ssh dev -- 'sw_vers; id'

barn mac exec

Use exec in scripts: it runs one program with its arguments passed exactly as given and returns the program’s exit status.

barn mac exec [flags] [name] -- command...

A command after -- is required. Use sh -c explicitly for pipelines and other shell expressions. With --json the result carries exit_code, stdout, and stderr. Argument rules are in SSH and exec.

No local options beyond --help; global presentation options still apply.

barn mac exec dev -- sw_vers
barn mac exec dev -- printf '<%s>\n' 'a b' ''
barn --json mac exec dev -- sh -c 'echo out; exit 3'

barn mac password

Use password when the guest desktop asks for the login password, at the lock screen or an administrator prompt.

barn mac password [name] [flags]

The password is stored next to the machine’s SSH key with the same protection. --copy puts it on the clipboard instead of printing it.

OptionMeaning / defaultAvailable in
-c, --copycopy to the clipboard instead of printing1.1.0
barn mac password dev
barn mac password dev --copy

barn mac ssh-config

Use ssh-config to let ssh, scp, rsync, and editors reach each machine by name, with its own key and pinned host key.

barn mac ssh-config [flags]

Without options it prints the OpenSSH fragment. The first machine to become ready installs the fragment as one Include in ~/.ssh/config, and lifecycle commands keep it current. --remove deletes only what Barn installed and keeps it out until --install. A name that ~/.ssh/config already uses for another host is published by address only. If ~/.ssh/config is a symlink or hard link, the command fails with ssh_config_linked and prints the Include line for you to add.

--install and --remove are mutually exclusive. This command takes no machine names.

OptionMeaning / defaultAvailable in
-i, --installinstall the entries as one Include in ~/.ssh/config1.1.0
--removeremove the entries Barn installed1.1.0
barn mac ssh-config
barn mac ssh-config --install
barn mac ssh-config --remove

barn mac logs

Use logs when a machine fails to start, loses its network, or does not shut down: it shows the last lines of the machine’s runtime log, including Apple Virtualization errors.

barn mac logs [name] [flags]

--lines/-n must be positive and defaults to 100. Here -n means lines, not no-wait. There is no follow option.

OptionMeaning / defaultAvailable in
-n, --lines intnumber of recent lines (default 100)1.1.0
barn mac logs dev
barn mac logs dev --lines 200

barn mac setup

Use setup to prepare the macOS base ahead of time, for example in a provisioning script, so the first up only has to clone it.

barn mac setup [flags]

It downloads macOS from Apple after you confirm, or reads --ipsw, and installs it once into the unbooted base that every machine is cloned from. up does the same automatically when no base is prepared.

OptionMeaning / defaultAvailable in
--disk sizeBase capacity, at least 32 GiB. Defaults to the current base capacity or 100 GiB for the first base1.1.0
--ipsw stringinstall macOS from this restore image instead of downloading from Apple1.1.0
-y, --yesdownload macOS from Apple without asking (required without a terminal)1.1.0
barn mac setup --yes
barn mac setup --ipsw ~/Downloads/restore.ipsw --disk 200G

barn mac image ls

Use image ls to see which restore images and bases take up disk space, and which machines use them.

barn mac image ls [flags]

It lists each restore image and base with its state and disk usage. It reads local state only and does not start the native runner.

Aliases: list.

No local options beyond --help; global presentation options still apply.

barn mac image ls
barn --json mac image ls

barn mac image update

Use image update to move to Apple’s newest macOS 27 build.

barn mac image update [flags]

It asks Apple for the newest macOS 27 restore image, downloads it after you confirm, and installs it as the default base for new machines. Existing machines keep their base until you run barn mac recreate NAME --update.

OptionMeaning / defaultAvailable in
--ipsw stringuse this restore image instead of downloading from Apple1.1.0
-y, --yesdownload without asking (required without a terminal)1.1.0
barn mac image update --yes
barn mac image ls

barn mac image prune

Use image prune to reclaim disk space from bases that no machine uses.

barn mac image prune [flags]

It lists unused bases other than the current default. --installers adds downloaded restore images and partial downloads. Nothing is deleted without --yes.

OptionMeaning / defaultAvailable in
--installersinclude downloaded restore images and partial downloads1.1.0
-y, --yesDelete the listed unused images; otherwise only list candidates1.1.0
barn mac image prune
barn mac image prune --installers --yes

barn mac doctor

Run doctor first when something goes wrong, and after installing or upgrading Barn.

barn mac doctor [flags]

It checks macOS and Apple Silicon support, the Mac component’s signature, free disk space, the prepared base, and every machine: its files, keys, shared folders, network, and SSH. It changes nothing and starts nothing, and exits 3 if any check fails.

No local options beyond --help; global presentation options still apply.

barn mac doctor
barn --json mac doctor

Implementation

command_mac.go

2.2 - Configuration

The inventory file that defines a Linux lab — its shape, the variables Barn reads, their defaults, and how flags and environment variables override them.

A Linux lab is one YAML file that lists each node under its fixed IPv4 address. This page defines the file’s shape, every variable Barn reads with its default, and how command-line flags and environment variables override them.

barn.yml
all:
  vars:                                  # applies to every host below
    admin_ip: 10.10.10.10                # the control node
    vm_image: d13                        # Debian 13
  children:                              # ordinary Ansible groups; they may nest
    lab:
      vars:
        vm_mem: 4GiB                     # group default, overrides all.vars
      hosts:
        10.10.10.10: { nodename: meta }  # key = the node's address on the lab /24
        10.10.10.11: { nodename: node-1 }
        10.10.10.12: { nodename: node-2, vm_cpu: 2 }  # host value wins over groups

This is an ordinary Ansible inventory. Barn reads the vm_* variables and a few Pigsty fields and ignores everything else, so the same file can also drive Pigsty or Ansible: add vm_* variables to a Pigsty pigsty.yml, and Barn creates exactly the nodes its playbooks target.

Check the file and preview its effect before starting anything:

barn validate -f barn.yml
barn --json validate -f barn.yml
barn plan -f barn.yml

validate checks YAML syntax, field rules, and image references against the local catalog without starting VMs or downloading images. Its JSON output includes valid, source, spec_hash, and resolved; if the catalog cannot be read, it warns and leaves image selectors unresolved. To check against another repository’s catalog, pass --repo, for example --repo https://repo.pigsty.cc/barn for the China mirror (validate has no --mirror). up later verifies what validate cannot: local-* image bytes, host capabilities, shared directories, networking, and guest SSH.

To start from a template, barn init [meta|dual|trio|full] writes a 1-, 2-, 3-, or 4-node inventory: meta at .10, then node-1, node-2, and node-3 at .11–.13. Templates define VMs only; Pigsty service roles stay in your playbook. --cidr moves the template to another /24 while keeping the host octets, and barn init full -o - prints it instead of writing a file.

Discovery

Commands that need a desired state look for an inventory in this order and use the first one that exists:

  1. The path given with -f.
  2. barn.yml, barn.yaml, pigsty.yml, then pigsty.yaml in the current directory. All four use the same format. A parse or validation error in the first match stops the command; Barn does not try the next name.
  3. The applied specification stored in BARN_HOME — only for plan, up, reload, recreate, and resize.
CommandsDesired state comes from
plan, up, reload, recreate, resize-f, then discovery, then the applied specification
validate-f, then discovery; an error if neither exists, even when a deployment exists
setup [template]-f, then discovery, otherwise a generated meta; a template argument and -f are mutually exclusive
init [template]Writes a new inventory without reading any state; --force overwrites an existing file
hosts installUses applied node names by default. An explicit -f reads that inventory and its vm_hosts mappings
start, stop, restart, status, destroy, purgeOperate on the applied deployment in BARN_HOME

The inventory must resolve to a regular file of at most 4 MiB; symlinks are followed, and relative share paths resolve beside the real file.

One Linux deployment per BARN_HOME

Barn keeps exactly one Linux deployment per BARN_HOME (default ~/.barn). The inventory is the desired state; BARN_HOME holds what is actually applied. Because a lab is defined by its fixed addresses rather than by the directory you work in, renaming or moving the inventory does not create a second deployment, and commands that use applied state (status, ssh, stop, start, destroy, …) work from any directory. Set BARN_HOME to an absolute path if you set it at all, so every working directory reaches the same deployment. The design rationale is in Design.

What Barn reads

An inventory needs a top-level all: group. Barn walks its hosts and nested children, and reads only node IPv4 keys, nodename, admin_ip, pg_cluster, pg_seq, node_admin_username, node_admin_uid, and the vm_* variables. It parses static YAML: Ansible inventory plugins, Jinja expressions, group_vars, and host_vars are not evaluated.

  • Other fields: Variables outside that list, such as pg_role, pg_version, repo_*, and node_packages, are ignored and never cause VM drift.
  • Inheritance: Values inherit all.vars → nested children.<group>.vars → host variables, deepest wins. A host-level list such as vm_disks replaces the inherited list entirely. If two sibling groups at the same depth give one node different values, set the variable on the host.
  • Repeated hosts: An IPv4 address listed in several groups is one node; its inherited variables merge.
  • Control node: admin_ip in all.vars names the control node. If it is omitted or matches no managed node, Barn picks the first managed node in traversal order (each group’s hosts before its children). Set admin_ip so reordering groups cannot move the control role.
  • Login account: All nodes share one login user matching [a-z_][a-z0-9_-]{0,31}, default dba. With dba, an explicit node_admin_uid must be 88; with a custom user, node_admin_uid only has to be an integer and the guest assigns the UID.
  • Skipped hosts: vm_skip: true marks a physical or external host. It may use a hostname or IPv6 key and does not count toward the managed /24; at least one managed node must remain. Skipping an existing node shows it as missing in plan without destroying it.
  • Strict vm_* namespace: Unknown vm_* keys (with a spelling suggestion), wrong types, Jinja templates, duplicate keys, and multi-document YAML fail with the line number and the rule violated. YAML anchors and << merge keys work: explicit keys win, then the first mapping in a merge sequence.

VM variables

VariableDefaultMeaning
vm_skipfalseSkip virtualization for this physical or external host
vm_imaged13 (new lab in 1.5.0)Image family, :channel reference, or image@version selector; see Image and architecture
vm_versionunsetNewest numeric version matching this prefix, such as 9 or 9.7
vm_archnativeDeployment-wide guest architecture; follows the host unless set to amd64 or arm64
vm_cpu1Base vCPU count; the effective count after scaling must be 1–256
vm_mem2048Base memory: bare integer in MiB, or a size string such as 8GiB (minimum 512MiB)
vm_scale1Positive integer multiplying CPU and memory only
vm_hosts[]Extra host /etc/hosts mappings, declared only in all.vars
vm_disk64Root disk capacity: bare integer in GiB, or a size string such as 64GiB
vm_disks[{path: /data}]Extra data disks; the default is one 128 GiB non-persistent disk at /data
vm_alias[]Extra names for guest /etc/hosts, SSH config, and optionally host /etc/hosts
vm_shares[]QEMU 9p host-directory shares on Linux and macOS hosts

An empty host mapping (10.10.10.10: {}) defines a complete VM with these defaults.

Bare integers mean MiB for vm_mem and GiB for disks. Size strings take a positive integer and a case-insensitive unit: 8G, 512m, 4gib, and 64GB all work. K/M/G/T and KiB/MiB/GiB/TiB are binary; KB/MB/GB/TB are decimal. Fractions (1.5GiB) and unitless strings ("8192") are invalid. up checks that the root disk is at least the base image’s virtual size.

Names and addresses

Each node’s name is the first of: explicit nodename, <pg_cluster>-<pg_seq>, or node-<last-octet>. Names must be unique, 1–63 characters of lowercase letters, digits, and hyphens, and must not start or end with -. vm_alias adds lowercase DNS names (dots allowed) that must differ from every node name and other alias. Keep an explicit nodename on every host: otherwise renaming pg_cluster turns an existing node into a missing old node plus a new one.

Every node gets two NICs: one for internet access through QEMU’s built-in NAT, and one on a fixed /24 so nodes reach each other at the addresses the inventory names. All managed nodes must share one RFC1918 /24: .1 is the host gateway, .2–.8 are reserved, and .9–.254 are available to nodes. Inside the guest, ip -br addr shows the inventory address on the fixed-IP NIC.

Resource scaling

vm_scale multiplies CPU and memory so you can size a whole lab up or down with one number. Barn resolves vm_cpu, vm_mem, and vm_scale independently through inheritance, then multiplies once:

CPU    = resolved(vm_cpu, default=1) × resolved(vm_scale, default=1)
Memory = resolved(vm_mem, default=2048 MiB) × resolved(vm_scale, default=1)
SettingsEffective CPUEffective memory
None12 GiB
vm_scale: 336 GiB
vm_cpu: 2, vm_scale: 366 GiB
vm_mem: 4GiB, vm_scale: 3312 GiB
vm_cpu: 2, vm_mem: 4GiB, vm_scale: 3612 GiB

Scales do not compound: a host’s vm_scale: 1 replaces a group’s vm_scale: 3. Scale is an integer from 1 to 256, subject to the 256-vCPU limit and memory overflow checks; quoted numbers, fractions, booleans, null, zero, and negative values fail. Base memory must still be at least 512 MiB. Root disks, data disks, and shares do not scale. The keys are exactly vm_cpu and vm_mem (vm_memory is not an alias).

Preview CPU or memory changes with barn plan -f pigsty.yml and apply them with barn resize -f pigsty.yml. These defaults changed in 1.2.0; inventories that omit them read differently after an upgrade from 1.1.0 (see Upgrade Barn). Commands that use applied state without an inventory keep the recorded resources.

Specification overrides

Six fields can also be set per command, so scripts and one-off experiments can change a lab without editing the file (1.2.0+; 1.1.0 has only --image and --arch, without environment variables).

Inventory fieldCLIEnvironment variableDefault
vm_image--image/-IBARN_IMAGEd13 (new lab in 1.5.0)
vm_arch--arch/-ABARN_ARCHnative
vm_cpu--cpu/-CBARN_CPU1
vm_mem--mem/-MBARN_MEM2048 MiB
vm_scale--scale/-SBARN_SCALE1
vm_disk--disk/-DBARN_DISK64 GiB
barn init full -C 2 -M 4GiB -S 2 -D 128GiB
barn plan -f barn.yml -S 3
BARN_SCALE=2 barn validate -f barn.yml -S 1

Each field resolves per node; the first source that sets it wins:

  1. CLI flag
  2. Non-empty environment variable
  3. Host variable
  4. Deepest child group
  5. Parent groups
  6. all.vars
  7. Default
  • CPU and memory are always bases, multiplied once by the final scale. -S 3 replaces the scale rather than multiplying it; add -S 1 to set exact CPU and memory.
  • CLI and environment values override host values on the selected nodes. Put common defaults in all.vars when host exceptions should stay in effect.
  • The inventory itself must still be valid: syntax, field types, and inheritance conflicts are checked as usual.
  • Whitespace-only environment values count as unset, and an invalid environment value shadowed by a flag is ignored: BARN_CPU=bad barn plan -C 2 uses 2. Suggested follow-up commands repeat effective environment overrides as explicit flags.
CommandOverridesEffect
init, template-generating setupAll sixWritten into the new inventory, defaults included; CPU and memory as bases plus scale
up that generates an inventory interactivelyAll sixSaved in the generated inventory
validate, plan, up, reload, recreateAll sixChange this run’s desired specification only; the YAML is not rewritten, so the next run against the file reports drift
resizeAll sixApplies CPU and memory changes and grows the root disk; -I/-A are only checked for consistency
setup reusing an inventoryNoneFlags are rejected and environment variables ignored
start, stop, restart, status, destroy, purgeNoneApplied state is used; environment variables are ignored

Image commands and barn mac also ignore the six variables; image info and image pull take their own -A. With no inventory, only applied state, --scale or BARN_SCALE requires -f; -C and -M then set absolute values with an implicit scale of 1.

--disk sets the absolute root capacity, which must be at least the base image’s virtual size: plan checks catalog metadata and creation checks the actual image again. It applies on creation, on explicit recreate, and to in-place growth with resize -D (BARN_DISK with resize only grows). Growth supports a last plain ext4/XFS root partition and never shrinks; see root disk growth. The default 128 GiB /data disk is separate.

Image and architecture

vm_image chooses the guest OS per node; vm_arch chooses one CPU architecture for the whole deployment. New labs in 1.5.0 default to Debian 13 (d13) on the host architecture. On Barn 1.4.0, barn init -I d13 writes the same image to a new inventory.

barn plan -I d13                 # Debian 13 using the environment, inventory, or host architecture
barn up -I d13 -A amd64          # amd64 Debian 13 for this invocation
barn plan -A native              # override the inventory architecture with the host's
barn init full -I d13 -A arm64   # save both choices in a new inventory

Precedence

OrderImage (per node)Architecture (whole deployment)
1--image/-I, on the selected nodes--arch/-A
2BARN_IMAGEBARN_ARCH
3vm_image and vm_version: host, then groups, then all.varsvm_arch
4Saved deployment default, or the embedded default for a new labnative: the host architecture

-I and BARN_IMAGE replace both vm_image and vm_version. A bare family name such as d13 leaves the architecture alone; -A native overrides the environment and inventory and follows the host again.

ArchitectureAliasesMeaning
native—Follow the current host; the default
amd64x86_64, x64x86-64 guest
arm64aarch64, a64ARM64 guest

Architecture-suffixed aliases

An image alias ending in a (arm64) or x/i (amd64), such as el10a, d13x, d12i, ea, ua, or da, carries its own architecture. For inventory commands:

  • From -I or BARN_IMAGE, the suffix sets the deployment architecture, overriding vm_arch.
  • In vm_image, the suffix takes precedence over vm_arch: native, the value generated templates write. A concrete vm_arch that names the other architecture fails validation, as do nodes whose suffixes disagree.
  • -A and BARN_ARCH must agree with every suffix still in effect: naming the other architecture, or native, fails with exit 2. A matching value such as el10a -A arm64 is accepted.

Image selection details

  • vm_arch belongs to the whole deployment: set it once in all.vars. Every managed node must resolve to the same architecture.
  • The catalog must offer the requested architecture. A missing variant is an error; Barn never substitutes another architecture.
  • When vm_image is omitted, existing labs use their saved default for existing and added nodes. A lone vm_version selects a version of that family. A new lab uses the binary’s embedded default even when a custom repository declares another default.
  • Built-in aliases are normalized while parsing the inventory: ubuntu → u26, rocky → el10, debian → d13. With a custom repository, write canonical family names in vm_image rather than reassigning built-in aliases.

vm_version keeps the family and the version prefix in separate fields:

barn.yml
vm_image: el9
vm_version: "9.9"

An exact catalog version wins; otherwise Barn matches dot-separated numeric prefixes and picks the highest (9.9 selects the latest 9.9.* build, 9 the latest 9.x release, and 9.10 sorts after 9.9). Use vm_version only with a bare family name in vm_image, without :channel or @version.

Keep or change a choice

  • Overrides on up, plan, reload, recreate, resize, and validate apply to that invocation only. To keep them, set all.vars.vm_arch and the node or group vm_image, and remove any superseded vm_version. init and template-generating setup write both into the new inventory; setup rejects -I/-A with an existing inventory.
  • Without an inventory file, lifecycle commands apply overrides on top of the saved specification. start and restart always use applied state.
  • Existing VMs are never converted. After you edit vm_arch or omit -A, up reports drift; switching the architecture requires recreate with all existing nodes selected. resize cannot change the image or architecture.
  • A guest whose architecture differs from the host runs under QEMU TCG emulation. On Linux, barn setup installs only the native emulator: install the target qemu-system-* binary and UEFI firmware first. See Runtime policy.

Data disks

Each node gets one 128 GiB /data disk by default, separate from the root disk, so test data has its own device and, with persistent: true, can outlive destroy and recreate. vm_disks replaces that list; vm_disks: [] creates a node with no data disks.

barn.yml
vm_disks:
  - path: /data
    size: 128
    fs: auto
    persistent: false
FieldDefaultMeaning
pathrequiredAbsolute mount path, normalized; spaces, Unicode, and shell punctuation are allowed. Simple paths keep their existing disk names; other paths get stable digest-based names. Identities must be unique per node; system directories and overlapping mounts are rejected
size128Capacity: GiB integer or size string
fsautoauto, xfs, or ext4. A blank auto disk gets XFS when the guest has mkfs.xfs, otherwise ext4; explicit xfs or ext4 requires that tool and never falls back. Healthy existing filesystems are mounted as-is
persistentfalseWhen true, ordinary destroy and recreate keep the disk image on the host, and the recreated node reattaches it while its identity and definition stay compatible

Data disks are test storage: up can reset a corrupted ext4 or XFS filesystem, persistent disks included. When Barn resets a data disk lists the exact rules.

Shares

vm_shares mounts host directories into Linux guests through QEMU Virtio-9p, for source code and build artifacts you edit on the host. It works on Linux and macOS hosts. For a native macOS guest, use the --share option of barn mac up or barn mac configure to mount a directory through VirtioFS.

barn.yml
vm_shares:
  - host: ./src
    guest: /src
    readonly: true
FieldDefaultMeaning
hostrequiredAbsolute path, ~/, a path relative to the inventory, or a directory symlink. Must exist, be accessible to the invoking user (ownership not required), and not overlap BARN_HOME
guestrequiredAbsolute mount point, normalized; spaces, Unicode, and shell punctuation are accepted, control characters are not
readonlytrueSet false for a writable share
  • Host QEMU and the guest kernel must support 9p; backend device limits apply.
  • Shares use the invoking user’s real filesystem permissions. Host sources may overlap and may have several readers or writers; coordinating concurrent writes is up to you.
  • Guest mount points must not overlap each other, data-disk mounts, system directories, or the login user’s .ssh directory. Do not put PostgreSQL data directories on 9p.
  • If the guest user cannot write a readonly: false share, Barn mounts it read-only with a warning and leaves host ownership alone; fix host permissions and re-run barn up to upgrade the mount.
  • Changing vm_shares on an existing node requires barn recreate. A missing host directory during up or start fails only that node; restart, reload, and recreate verify share paths before stopping any running VM.

Local service names

all.vars.vm_hosts (1.2.0+) publishes extra names, such as Pigsty service domains, in the host’s /etc/hosts alongside node names and vm_alias:

pigsty.yml
all:
  vars:
    vm_hosts:
      - {address: 10.10.10.10, names: [i.pigsty, m.pigsty]}
      - {address: 10.10.10.100, names: [pg-dns-service]}
  hosts:
    10.10.10.10: {nodename: meta}
barn hosts install -f pigsty.yml --json  # preview, including before VM creation
barn hosts install -f pigsty.yml --yes  # publish; sudo may ask for a password
barn hosts uninstall --yes
  • Each entry needs an address and a non-empty names list. Addresses must be canonical IPv4 in the inventory’s /24, within .9–.254 (.1–.8 are reserved for the host and DHCP).
  • Identical name/address pairs deduplicate. Names compare case-insensitively; one name with two addresses fails validation, as does a conflicting name already present outside the Barn-owned block.
  • The mappings touch only the host’s /etc/hosts: they do not change the VM spec hash, configure guest DNS, set up a VIP, or cause drift. up never publishes them.
  • hosts install without -f publishes only names and aliases from applied state and replaces the whole Barn block, dropping these service names; repeat the -f command to keep them.
  • An unchanged block needs no sudo. Wildcards, SRV records, and live primary discovery need a real DNS service.

Pigsty’s development bin/sandbox-dns extracts its portal, node, PostgreSQL, VIP, and MinIO names for this interface; see the migration audit.

Drift

Barn hashes each node’s resolved definition and compares it with applied state, so editing the inventory never changes a VM until you run the command that applies that kind of change:

ChangeApply with
New nodebarn up
CPU or memory, including vm_scalebarn resize <node>; keeps identity and disks
Larger vm_diskbarn resize <node>, or barn resize -D <size> <node> without editing; grow-only
Image, data disks, shares, or other VM definitionbarn recreate <node>
vm_arch, login user, or the /24barn recreate of the whole deployment
Node removed or set to vm_skip: trueShown as missing in plan; remove it with barn destroy <node>

barn up also starts stopped nodes and retries unfinished guest provisioning on running nodes without restarting QEMU. After barn update, a node whose definition is unchanged keeps its recorded base image. Creating or explicitly recreating a node resolves its selector against the active catalog.

Node selectors limit a command to the named nodes: plan node-1, up node-1, reload node-1, recreate node-1, and resize node-1 keep the applied definitions of unselected peers, even if the inventory edits or omits them. The whole inventory must still parse, and conflicts with applied addresses, aliases, control-node roles, or deployment-wide settings are still rejected; images for uncreated, unselected nodes are not resolved.

2.3 - CLI Contracts

Output modes, the JSON/YAML envelope, exit codes, prompts, lifecycle results, and recovery rules shared by every Barn command.

Every barn command follows the same output, prompt, and exit-code rules, so a script can handle all of them the same way. This page defines those rules; per-command syntax and flags are in the Command Reference, and native Mac VM contracts in Mac Reference.

barn [--json|--yaml] [-v|--verbose] <command> [flags] [node...]

Each command page lists its short aliases (barn st is barn status); the network group also answers to n and net.

Output modes

Results go to stdout and everything else to stderr, so redirecting stdout captures only the result.

Modestdoutstderr
Text (default)Results and follow-up hints (connect:, retry:, next:)Live progress, prompts, error: lines
--json or --yamlOne JSON or YAML document: the command’s report or a failure objectProgress and diagnostics
-v, --verboseUnchangedAdds bounded diagnostic logs

In text mode, an operation that runs for a second or longer on a terminal redraws one live table on stderr (NAME ADDRESS STATE MESSAGE, ITEM STATE MESSAGE, or IMAGE STATE MESSAGE) above a completion line ending in [DONE], [FAILED], or [CANCELLED]. When stdout and stderr are both terminals and --verbose is off, the finished table stays in place and stdout adds only the follow-up hints.

Two cases differ: logs --follow streams NDJSON with --json or a YAML document stream with --yaml, and structured interactive ssh sends the session to stderr and only its final report to stdout.

--json and --yaml are long-form only and mutually exclusive; BARN_OUTPUT sets the default. Presentation flags may come before or after the command but must precede the -- that starts a remote command. barn --json with no command returns suggested next commands in actions[].

Exit codes

Check the exit code first, then parse the output.

CodeerrorMeaning
0Success (including ready guests with non-fatal warnings[] or repairs[])
1runtimeOperation executed and failed (external tool, download, or guest failure)
2usageInvalid CLI syntax, missing inventory file, or invalid configuration/image selector
3capabilityHost lacks a required dependency, active Barn network, or privilege
4conflictOperation conflicts with current deployment state or another active barn process
5partialNode-level batch failure; inspect failures[] (successful peer nodes remain intact)
6resourceHost IP address, port, subnet, or disk path is already in use
7integrityDigest, catalog signature or signed revision, instance identity, or file ownership verification failed
130cancelledInterrupted by SIGINT/SIGTERM or interactive confirmation declined
  • ssh and exec return the remote command’s exit code verbatim, so text output, JSON exit_code, and the process status agree. 255 can mean either an OpenSSH transport failure or a remote command that exited 255.
  • Deployment lock: When another barn process holds the deployment, mutating commands wait up to 10 minutes while naming the holder, then exit 4 with reason: "deployment_busy". Read-only and access commands (status, ssh, exec, ssh-config, hosts) do not wait; status shows the last committed state and names the active operation in note.
  • Catalog trust: A missing or invalid catalog signature fails with reason: "catalog_signature"; a catalog that reuses an accepted or embedded revision number with different bytes fails with reason: "catalog_equivocation". Permission and I/O errors while reading a cached signature are runtime failures (exit 1).

Structured failures

With --json or --yaml, commands that have their own report schema — doctor, network, provision, lifecycle commands, and ssh/exec — write that report even when they fail; exec, for example, returns success, exit_code, stdout, and stderr. A command that fails before it has a report writes one failure object instead:

FieldPresentMeaning
errorAlwaysError class from the exit code table
messageAlwaysHuman-readable summary
reasonWhen knownStable snake_case cause for automation
nextWhen knownSuggested next command
operation_idWhen assignedCorrelates with barn logs --source events
commandAn external program failedname, argv, exit_status, signal, timed_out, stderr
failures, rolled_backExit 5 from a lifecycle batchFailed nodes and rolled-back preparations, as in Lifecycle results

Common reason values on Linux commands:

reasonerrorCause and usual next step
no_inventoryusageNo inventory in the current directory: barn init, or pass -f
unknown_nodeusageA selector is not a node name in the inventory or deployment
unknown_imageusageThe image selector is not in the active catalog
qemu_missingcapabilityQEMU is missing or unusable; next names the fix
network_absentcapabilityThe Barn network is not installed: barn setup
sudo_unavailablecapabilitysudo failed, or needs a password while stdin is not a terminal
no_deploymentconflictBARN_HOME holds no applied deployment: barn up
node_not_runningconflictThe node is stopped: barn start <node>
resize_requiredconflictDrift that barn resize applies
recreate_requiredconflictDrift that needs barn plan, then barn recreate <node>
nodes_removedconflictThe inventory omits existing nodes; see Lifecycle results
deployment_changedconflictApplied state changed during recreate preflight; review and retry
deployment_busyconflictAnother command held the lock for 10 minutes
interrupted_transitionconflictA node is still mid-transition after an interrupted command; run the next command
hosts_name_takenconflict/etc/hosts maps a Barn name outside the Barn-owned block
disk_fullresourceThe host disk ran out of space
image_integrityintegrityA cached or downloaded image failed verification

Errors in the command line itself, such as an unknown flag or a command group without a subcommand (barn image), exit 2 with error: "usage".

In text mode, a failure prints error: <message> on stderr, then the last stderr lines of any failed external program and a next: command when one is known. When a remote command under ssh or exec fails, only its own output appears, without an error: line. The design rationale is in CLI contracts.

Prompts and scripts

Commands that change the host or delete data ask for confirmation when stdin is a terminal, and never wait for input in a script:

Commandstdin is a terminalstdin is not a terminal
recreate, destroyLists the nodes to replace or remove and asks you to type the command name; anything else cancels with exit 130. --yes or --force skips the promptExit 2 unless --yes or --force is given (there is no -y)
setupShows the plan and asks onceRequires --yes, else exit 2; --dry-run previews and cannot be combined with --yes
network, hosts install/uninstallShows the privileged plan and asks (install defaults to yes, uninstall to no); with --json/--yaml it only previewsPrints the plan and exits 0 without applying; pass --yes, or check applied in the report
up, start, restart, reload with a host dependency or the network missingShows the host-preparation plan and asks once, as setup does; an interactive up with neither an inventory nor a deployment also generates metaReports what is missing; run barn setup --yes first

Privileged steps run through sudo, which may still ask for your password; when it needs one and stdin is not a terminal, the command fails with sudo_unavailable. On Linux, network uninstall keeps the global networkd unit state when other host links exist or exclusive Barn use cannot be established: the plan reports preserve_networkd, and the applied report explains the decision in checks.networkd.

barn purge never asks unless you pass --ask, which shows the nodes and deletion scope and accepts y/yes; n/no, an empty line, or EOF cancels with exit 130. It accepts no --yes, -y, or --force. With no deployment, purge and whole-deployment destroy succeed cleanly, and purge still removes retained persistent disks whose Barn ownership metadata is intact; unverifiable retained directories block deletion. If deployment state is missing, destroy --force --delete-persistent and destroy --force --purge direct you to barn purge.

Flag conventions

  • On Linux commands, -f means --file (except barn logs -f, which is --follow), -n means --no-wait (barn mac logs -n sets the line count), and -d means --dry-run.
  • Safety and repository flags are long-form only: --ask, --mirror, --force, --rollback, --remove, --allow-downgrade, --sudo, --delete-persistent, --purge.
  • -y exists only where a command’s option table lists it; on destroy and recreate, --yes is the same as --force.
  • Path arguments such as -f, --script, a local --repo, image import sources, and repo roots accept relative paths, ~/, and symlinks.
  • Specification flags (-I, -A, -C, -M, -S, -D) and their environment variables follow Specification overrides.

Lifecycle results

Without node arguments, lifecycle commands act on every managed node; ssh, exec, and per-node logs default to the prepared control node, or the first prepared node if the control node is not ready. Selectors are resolved node names such as meta, not IP addresses, group names, or vm_alias entries. Which inventory a command reads is defined in Discovery.

Lifecycle commands (up, start, stop, restart, reload, resize, recreate, status, destroy, purge) return one report:

FieldContents
nodes[]Per node: name, address, state (such as running or stopped), ready, image, cpus, memory_bytes, root_disk_bytes, runtime, guest_arch, accelerator, ssh_host, ssh_port, pid, error
nodes[].warnings[]Non-fatal guest problems, each with stage and detail
nodes[].repairs[]Recovery actions Barn completed, such as resetting a corrupted data disk
warnings[]Deployment-level warnings with code (ssh_config, time_sync, guest_metadata, event_log), message, detail, next
failures[]Failed nodes with node, stage, error, and optional reason
rolled_back[]Nodes whose uncommitted preparation files --rollback removed
resources[]Per node: base_cpu, base_memory_bytes, scale, root_disk_bytes, effective cpus and memory_bytes, and each value’s sources
operation_id, spec_hash, note, ssh_configEvent-log correlation, applied specification hash, concurrent-operation note, SSH fragment result

What each command changes is in Linux Lifecycle, and which change needs which command in Drift. When drift needs a destructive change, up and reload exit 4 (conflict) and point to barn plan and then barn recreate <node> or barn destroy <node>. A whole-deployment recreate refuses an inventory that omits an existing node before any VM stops (reason: "nodes_removed", exit 4): remove the node with barn destroy <node> or add it back. Barn checks the scope again under the destruction lock; if applied state changed meanwhile, recreate exits with reason: "deployment_changed".

Destroying the control node makes the first remaining node the control node. Point admin_ip at it and run barn up to install its control SSH access (--no-wait defers this); until then, an inventory that still names the deleted node as control is role drift, which up refuses. To bring the old node back, add it as a regular node. Barn refuses, before deleting anything, to destroy the control node when the successor has an unfinished prepare record that cannot be completed, and names the successor.

Planning

barn plan is read-only and exits 0 even when its action is resize, recreate, or blocked-removal. Scripts should read action, the create, resize, recreate, start, and missing arrays, and the optional blocked explanation. Plans never download images; catalog images need only local metadata, while local-* images are also checked with qemu-img.

Readiness

Barn reads /var/lib/barn/ready.json over management SSH. A Linux guest is ready when its node name, generation and spec hash match the expected values. During startup on up, start, restart, reload, and recreate, Barn also corrects guest clocks more than 2 seconds off the host, reporting a failure as a time_sync warning. Non-fatal problems go to nodes[].warnings and completed recovery actions to nodes[].repairs; the command still exits 0. Re-running barn up retries unfinished guest setup on running VMs without restarting them, and gives existing guests the current recovery helper.

--no-wait returns once QEMU is running and defers SSH readiness, clock correction, data-disk recovery, and guest /etc/hosts updates to the next barn up. Which disk problems Barn repairs and which it only reports is described in Storage.

Node failures

When some nodes fail in a batch, Barn keeps the nodes that succeeded, exits 5, and summarizes each failure as N of M node(s) failed: <node> (<stage>: <error>); .... Stages include prepare, start, readiness, bootstrap, guest-setup, stop, and status. For readiness or bootstrap failures, read barn logs <node> and see A node did not become ready.

Status

barn status reads recorded state plus live QEMU process identity: running means the process is alive, not that guest SSH answers. It flags TCG emulation, and on Apple Silicon appends mac: <names>; barn mac ls when Mac VMs exist. --verbose adds forwarded SSH ports, architecture, accelerator, and QEMU PID. A degraded node, including an online resize interrupted after hot-plugging (stage: "resize", reason: "resize_incomplete"), still lists its healthy peers, fills failures[], and exits 5.

SSH configuration

up and recreate rewrite Barn’s host SSH fragment (~/.ssh/barn_config), guest /etc/hosts, and control-node SSH entries; start and restart refresh SSH aliases; per-node destroy removes that node’s entry; whole-deployment destroy removes the fragment. If ~/.ssh/config cannot be updated, or is a symlink or hard link (which Barn never edits), Barn still writes ~/.ssh/barn_config, prints the Include line to add yourself, records an ssh_config warning, and exits 0; barn ssh keeps working. On the control node, Barn-managed entries accept replacement host keys without writing known_hosts, so recreated nodes stay reachable, and your own SSH entries are kept.

Lifecycle concurrency

up, start, stop, restart, reload, recreate, destroy, and purge work on up to max(1, logical CPUs - 2) nodes at once (1.2.0+; 1.1.0 used at most four workers). --parallel/-p changes that for one invocation:

barn up -p 0                      # all selected nodes at once
barn up --parallel 8
barn start -p 1                   # serial
barn restart meta node-1 -p 2

The limit applies to disk preparation, startup, and shutdown; state commits and artifact removal keep their order, and disk preparation finishes before startup begins. A startup worker stays busy until its guest passes SSH readiness, or with --no-wait until QEMU starts and its process identity is verified. Values above 16 are accepted, values above the node count add no workers, negative values are rejected, and suggested retry commands keep the value, including 0. provision --parallel has its own default of 1.

Root disk growth

barn resize -D 128GiB meta
BARN_DISK=128GiB barn resize meta

-D is an absolute target. Growth needs downtime: running nodes return to running, and stopped nodes boot temporarily for checks and expansion, then stop again. Repeating a completed target changes nothing and does not restart the VM; a smaller target fails. The root must use 512-byte logical sectors and a last plain ext4/XFS partition in a GPT or primary MBR layout; LVM, encrypted devices, later partitions, and missing guest tools fail before the image is modified. Root data, VM UUIDs, and SSH keys are kept; data disks are not resized.

Barn records recovery stages and checks image, guest disk, partition, and filesystem sizes before finishing. After a failure, status shows a root-resize warning: fix the reported problem and repeat the same resize -D target. A grown image is never shrunk to undo an incomplete expansion. Update vm_disk to keep the new size, or the next run reports drift. Implementation and measurements: root growth acceptance.

SPEC display

Node tables show effective CPU and memory in a SPEC column such as 1c2g, 2c4g, or 8c16g: c is vCPUs and g is GiB, so 1536 MiB is 1.5g and 512 MiB is 0.5g. Memory that is not a whole number of MiB shows its exact byte count with b, and an unknown specification shows -. Plans show changes as 2c4g → 4c8g and root capacity in a separate ROOT column.

status and completion results show applied resources; plan, validate, and setup show desired ones. When scale is not 1, output explains the base, multiplier, result, and sources; --verbose explains it at scale 1 too. JSON keeps numeric CPU counts and byte sizes in resources[], so scripts never parse SPEC. The flags that set these values are in Specification overrides.

Interruption and recovery

  • Cancellation: On cancellation Barn sends SIGTERM to the external program it is running (sudo forwards it to the privileged command) and waits at most 10 seconds for that process and its inherited output pipes. Descendants that ignore SIGTERM need outside supervision.
  • Fault isolation: During up or start, a missing host share or a failed new-node preparation affects only that node; independent stopped nodes still start, and the command exits 5 with a retry command that keeps your -f, --repo, and other flags.
  • Interrupted transitions: A QEMU PID reused by an unrelated process marks the node stopped; a stop interrupted while the VM kept running marks it running. After an online resize interrupted mid-change, status reports resize_incomplete: retry barn resize <node> or run barn restart <node>. Other interrupted transitions print the recovery command (destroy resolves them directly), and the next run after a failed initial up rolls back uncommitted journal artifacts automatically.
  • Event log: setup and the lifecycle run that follows share one operation_id. Even if setup fails before a deployment exists, barn logs --source events --json shows the bounded phase log, without sensitive arguments or credentials; setup --dry-run writes none.
  • Retained persistent disks: Disks left by a previously removed node do not block destroying the remaining nodes; delete them with destroy --delete-persistent or purge.
  • macOS setup: setup finishes Homebrew discovery or installation and the pinned socket_vmnet download before asking for administrator privileges, so a slow download cannot expire an earlier sudo token and a failed download never prompts for a password.

Logs and environment

barn logs reads the guest serial console by default; --source qemu selects QEMU diagnostics and --source events the deployment-wide event log. --follow streams raw bytes in text mode, NDJSON with --json, and YAML documents with --yaml. QEMU argv appears only with --verbose.

Environment variablePurpose
BARN_HOMEPrivate state directory (default ~/.barn), one Linux deployment each; accepts relative paths, ~/, and directory symlinks, but not / or the home root. Prefer an absolute path across working directories
BARN_IMAGE/BARN_ARCH/BARN_CPU/BARN_MEM/BARN_SCALE/BARN_DISKVM specification overrides; CLI takes priority. Read only by commands accepting each field; see specification overrides
BARN_REPODefault image repository URL or path; overridden by --mirror and --repo
BARN_OUTPUTDefault output format (text, json, or yaml); overridden by --json/--yaml
BARN_VERBOSEBoolean default for diagnostic output; overridden by -v/--verbose
BARN_VMNET_ARCHIVEPath to a local pinned socket_vmnet archive for macOS setup; accepts relative paths, ~/, and symlinks (SHA-256 verification still applies)
NO_COLORAny non-empty value disables ANSI color output

An invalid BARN_OUTPUT or BARN_VERBOSE makes every command exit 2 (usage) unless the matching flag overrides it; --help always works.

SSH passthrough and completion

barn ssh and barn exec take Barn flags and an optional node name, then --, then the remote command, and exit with the remote command’s status. ssh hands the guest shell one string; exec passes the program and its arguments unchanged. The full rule, with examples, is in Remote commands and --.

barn completion bash|zsh|fish|powershell prints a completion script (for Bash, reload it after upgrades with source <(barn completion bash)). It completes commands, aliases, templates, image aliases, enumerated flag values, YAML files for -f, and node names from the current inventory or applied state, and stops suggesting Barn flags after --.

2.4 - Mac Runtime Reference

What a barn mac machine owns, how it is networked, and the JSON results, failure reasons, and files that scripts rely on.

barn mac runs named macOS virtual machines on an Apple Silicon Mac, alongside the Linux lab but separate from it. This page defines what scripts and agents depend on: what each machine owns, how it is networked, what the commands return, how they fail, and where state lives.

Per-command syntax and options are in the macOS Command Reference; the walkthrough is macOS Virtual Machines.

barn [--json|--yaml] [-v|--verbose] mac <command> [flags] [name...]

Host and runner

Barn drives Apple’s Virtualization framework through Barn.app, the native macOS app bundle that ships with the Apple Silicon release and the Homebrew formula (install). The CLI and the app must come from the same build: before any VM operation the CLI checks that the app’s runner speaks protocol 2, and barn mac doctor also verifies the runner’s local code signature.

  • Run barn mac as the logged-in desktop user. Commands that talk to the runner reject root with mac_root, and a host that is not Apple Silicon on macOS 27 or later with mac_host_unsupported. Disk space and the two-VM limit are under requirements.
  • On Linux and Intel Macs, barn --help hides mac. Commands that only read local state, such as barn mac image ls, work without the runner.
  • barn mac with no subcommand runs barn mac ls.
  • The CLI looks for the runner relative to its own resolved binary path, covering the app bundle (Barn.app/Contents/MacOS/barn-mac-runner), the pkg installer, and Homebrew libexec layouts. BARN_MAC_RUNNER overrides the search with an absolute, relative, or ~/ path.

Machines

A machine is a named macOS VM with its own copy-on-write disk cloned from a shared base image, its own private network and fixed address, an administrator account with passwordless sudo, and its own SSH keys. Machines never join the Linux lab or read its inventory, and Linux destroy and purge leave them alone.

Names are 1–32 characters: lowercase letters, digits, and internal hyphens, starting with a letter (mac1, dev, build-2). mac1 is the default name.

SettingNew machine defaultChange it with
CPUs4configure --cpu, while stopped
Memory8 GiBconfigure --memory, while stopped
Shared foldersnoneconfigure --share / --unshare, while stopped
Subnetfirst free /24configure --subnet, while stopped
Clipboard synconconfigure --clipboard, anytime; applies at the next start
Disk capacitythe prepared base’s capacity, or 100 GiB for the first basefixed
Administrator accountyour host macOS username, or barn if that is not a valid account namefixed
macOS buildthe default baserecreate --update (erases the disk)

Disk capacity and the administrator account are fixed for the machine’s lifetime and survive recreate; create a new machine to change them. Value ranges and syntax are in barn mac up and barn mac configure.

  • Administrator account: passwordless sudo, Ed25519 SSH key authentication, automatic desktop login, and Remote Login enabled. SSH password authentication is off. A random local password, needed at the lock screen and in GUI administrator prompts, is saved in the machine’s password file (mode 0600) and printed by barn mac password.
  • Hostnames: the guest ComputerName is <name> and LocalHostName is barn-<name> (reachable as barn-<name>.local).
  • Shared folders: one VirtioFS device mounts every share at /Volumes/My Shared Files/<name> in the guest. Each host source must resolve to an existing directory; symlinks are followed. Share names may contain spaces and Unicode and must be valid UTF-8 of 1–255 bytes, other than . or .., without / or ASCII control characters. configure --share with an existing name replaces that share’s path and mode.
  • Clipboard sync: plain text up to 1 MiB is synced over the machine’s SSH connection whenever its desktop window gains or loses focus. Pasteboard items marked concealed are skipped.
  • Host limit: Apple runs at most two macOS VMs at a time per Mac, counted across all apps and including an in-progress base installation (requirements). Starting a third fails with mac_vm_limit and names a machine to stop.

Networks

Each machine gets its own private /24, so its address stays the same across restarts and does not collide with another machine or the Linux lab. The machine’s runner creates the network with Apple’s shared-mode vmnet API when the machine starts and tears it down when it stops, without root or a background daemon.

ItemValue
SubnetFirst free /24 from 10.10.20.0/24 through 10.10.59.0/24 that overlaps neither a host route nor another machine, or an explicit --subnet
Gateway.1, on the Mac host
Guest IP.10, a vmnet DHCP reservation for the machine’s MAC address
ReachabilityHost-to-guest routing and outbound NAT; no LAN bridging and no inbound port forwards

If a route added later, such as a VPN, overlaps a machine’s saved subnet, start refuses with mac_subnet_in_use. Run barn mac configure NAME --subnet auto to move it to a free subnet. SSH trust survives the move because Barn pins the guest host key to barn-mac-<instance_id>, not to the IP address.

macOS Local Network privacy can block a third-party terminal or IDE from reaching the guest subnet, usually as No route to host. Allow that app under System Settings → Privacy & Security → Local Network. barn mac ssh and exec are unaffected: they run /usr/bin/ssh, and Barn’s own SSH transport goes through /usr/bin/nc, both Apple system binaries.

SSH and exec

barn mac ssh and barn mac exec connect with the machine’s own key and pinned host key and return the remote command’s exit status. They differ in how they hand the command to the guest:

  • ssh joins the arguments after -- into one command string for the guest shell, as plain ssh does. Without a command it opens an interactive shell.
  • exec passes the program and each argument separately, so spaces, quotes, and empty arguments arrive intact. It requires a command. Wrap pipelines, redirection, and compound commands in sh -c '...'. For compatibility exec also accepts a single command string as shell shorthand; new scripts should pass separate arguments or an explicit sh -c.
barn mac ssh dev
barn mac ssh dev -- 'sw_vers; id'
barn mac exec dev -- sw_vers
barn mac exec dev -- printf '<%s>\n' 'a b' ''
barn mac exec dev -- sh -c 'sw_vers; id'
barn --json mac exec dev -- sh -c 'echo out; exit 3'

Argument rules for both commands:

  • A remote command always follows --, and its first argument must not be empty. Interactive barn mac ssh dev needs no separator.
  • Before --, pass Barn flags (--json, -v, --help) and at most one existing machine name; omit the name to select the default machine. Everything after -- belongs to the guest command.
  • An unknown machine name or invalid arguments exit 2 (usage) before any connection is attempted, with barn mac ls as the next step.
  • --json needs a remote command; an interactive shell has no JSON form.

JSON output

Every barn mac command except interactive ssh supports --json and --yaml. The result goes to stdout; progress goes to stderr.

ls

In this sample, barn mac image update has made 27.2.1 the default base (base), while mac1 still runs the 27.0 base it was cloned from (machines[0].image).

{
  "schema_version": 2,
  "root": "/Users/alice/.barn/mac",
  "prepared": true,
  "base": {"version": "27.2.1", "build": "26B131", "base_id": "26B131-c8269f7cdc99451b71db4104"},
  "machines": [
    {
      "name": "mac1",
      "kind": "macos",
      "state": "running",
      "ready": true,
      "ssh": "ready",
      "address": "10.10.20.10",
      "address_stable": true,
      "ssh_host": "10.10.20.10",
      "ssh_port": 22,
      "user": "alice",
      "image": {"version": "27.0", "build": "26A428", "base_id": "26A428-e16af589f4b705ca397f5b21"},
      "cpus": 4,
      "memory_bytes": 8589934592,
      "disk": {"capacity_bytes": 107374182400, "allocated_bytes": 1202647040},
      "network": {"subnet": "10.10.20.0/24", "gateway": "10.10.20.1", "address": "10.10.20.10"},
      "shares": [{"name": "src", "host": "/Users/alice/src", "guest": "/Volumes/My Shared Files/src", "readonly": false}],
      "clipboard": true,
      "pid": 2545,
      "instance_id": "b1482ffc-2da7-45d9-ace5-c5f3193a9172",
      "warnings": []
    }
  ],
  "running": 1,
  "limit": 2
}
FieldValues
baseThe default base for new machines
machines[].imageThe base this machine was cloned from
stateprepared (created, first boot not completed), starting, running, stopping, stopped, unknown
readytrue when this check verified guest SSH and passwordless sudo
sshready, pending (first boot in progress), unavailable, offline, unchecked
observedPresent when the running guest reports a macOS build different from its base
window_visiblePresent while the desktop window is open
error, warningsThe last failure recorded for the machine, and SSH issues found during this check
running, limitMachines running in this BARN_HOME, and Apple’s per-host limit; the limit itself is enforced across the whole Mac

Lifecycle results

Single-machine commands (up, restart, open, recreate, configure) return one result object. Batch commands (start, stop, destroy) return {"machines": [...]}, even for one name. When a batch partly fails, the result lists both the machines that succeeded and the failures, and the command exits 5.

{"name": "mac1", "action": "created", "state": "running", "ready": true,
 "address": "10.10.20.10", "user": "alice", "version": "27.2.1", "build": "26B131"}
FieldValues
actioncreated, started, running (already running), restarted, recreated, opened, configured, stopped, powered_off, already_stopped, destroyed, absent
forcedtrue when the VM was powered off rather than shut down: the two-minute shutdown in stop or restart timed out, or stop --force was used (action: powered_off)
windowtrue when the desktop window was opened
warningsNon-fatal notices, such as a clipboard change that takes effect at the next start

Other commands:

  • exec --json: the same schema as Linux barn exec --json (node, exit_code, stdout, stderr).
  • password --json: name and password, or {"name": "mac1", "copied": true} with --copy.
  • ssh-config --json: fragment when printing; installation status with --install or --remove.
  • logs --json: name and logs.
  • doctor --json: ok and checks[] (name, ok, detail, optional next); exits 3 if any check fails.

Failures

A failed command reports a stable reason and, when there is one, a next command to run. Exit codes follow the CLI exit code table; ssh and exec pass the remote command’s exit status through.

ReasonExitMeaning and next step
mac_host_unsupported3Host is not Apple Silicon or is running macOS older than 27
mac_runner_missing3Barn.app / native runner is not installed alongside the barn CLI
mac_runner_protocol3Installed Barn.app uses a different runner protocol version; reinstall matching CLI and app builds
mac_root2Invoked as root; run as the logged-in desktop user without sudo
mac_download_consent2Non-interactive macOS download requires --yes (or supply a local file with --ipsw)
mac_machine_absent4Named VM does not exist; create it with barn mac up NAME
mac_not_initialized4VM has not finished its first boot; complete initialization with barn mac up NAME
mac_not_running4ssh or exec called on a stopped VM; run barn mac start NAME
mac_running4Requested configuration change requires the VM to be stopped; run barn mac stop NAME
mac_configuration_conflict4up flags differ from the existing VM; run the suggested configure or recreate command
ssh_config_linked4~/.ssh/config is a symlink or hard link; add the printed Include line manually
mac_vm_limit6Two macOS VMs are already running on this Mac; stop the reported VM first
mac_subnet_in_use6A host route overlaps the VM’s subnet; run barn mac configure NAME --subnet auto
disk_full6Insufficient free disk space to download or install the macOS base image
mac_machine_damaged7An initialized VM slot is missing its disk or identity files (the slot directory is preserved for inspection)
mac_readiness_interrupted130barn mac stop interrupted a first-boot SSH readiness wait

Files

$BARN_HOME/mac

  • config.jsonInstallation identity, default base image, and ssh_config_off flag
  • images/
    • ipsw/
      • <build>.ipswCached Apple restore image (.partial while downloading)
      • <build>.ipsw.jsonRestore image metadata and digest
    • base/
      • <id>/Read-only, unbooted macOS base image bundle
  • slots/
    • <name>/
      • state.jsonMachine record (schema 2)
      • disk.asifCopy-on-write APFS disk layer cloned from the base image
      • machine-id.binApple Virtualization machine identifier
      • auxiliary-storage.binNVRAM / boot auxiliary storage
      • id_ed25519Per-VM SSH private key
      • id_ed25519.pubPer-VM SSH public key
      • known_hostsPinned guest host key under barn-mac-<instance>
      • passwordGenerated guest login password (mode 0600)
      • runner.logPer-VM runtime log read by barn mac logs
  • runtime/Global state lock and per-machine operation locks

Outside $BARN_HOME/mac:

  • Control sockets: /tmp/barn-mac-<uid>-<hash>/.
  • OpenSSH fragment: barn mac ssh-config manages ~/.ssh/barn-mac_config and a # barn-mac:include block in ~/.ssh/config, independent of the Linux # barn:include block. barn mac ssh-config --remove sets ssh_config_off in config.json, so lifecycle commands stop re-adding the Include block until you run barn mac ssh-config --install.
  • Desktop preferences: window positions live in ~/Library/Preferences/com.pgsty.barn.plist (0.9.0 used ~/Library/Preferences/io.pgsty.barn.mac-runner.plist).
  • Inside the guest: Barn writes ~/.ssh/authorized_keys, /private/etc/sudoers.d/80-barn, and /etc/ssh/sshd_config.d/000-barn.conf, sets ComputerName and LocalHostName, and disables idle sleep with pmset.

Recovery state

An interrupted recreate leaves a recovery journal, and barn mac image prune keeps every base that journal still references until recovery cleanup finishes. While a journal is malformed, barn mac image ls, the space estimate in barn mac doctor, and pruning fail until it is repaired, and every image stays in place. If one machine’s state cannot be read, barn mac ls fails as a whole, while commands that name the other machines keep working.

2.5 - Images

Signed catalogs, built-in aliases, repository selection, local cache verification, imports, and pruning.

Barn resolves Linux guest images from a static catalog and immutable qcow2 artifacts. Official and HTTP repositories require ML-DSA-87 catalog signatures, while explicitly selected local directory and HTTPS repositories may be unsigned. You can activate newer image catalogs with barn update without replacing the barn binary; the binary defines the trusted signing public keys and qcow2 safety rules.

Warning

el7 (CentOS Linux 7.9) is an EOL deprecated compatibility image. The catalog also marks el8 (Rocky Linux 8) and u22 (Ubuntu 22.04 LTS) as deprecated as support is phased out. Prefer el9, el10, d12, d13, u24, or u26 for new labs.

Aliases and pull order

Official catalog 2026120302 selects Debian 13 (d13:stable) on the host architecture by default. It covers nine distribution families and 17 stable artifacts, with 35 artifacts including retained versions. Only el7 is amd64-only. Every other family provides both amd64 and arm64.

Both public mirrors published this catalog on December 3, 2026. Run barn update to activate it and barn image info d13 to see the selected version. Barn 1.4.0 verifies the Minisign signature and still needs barn init -I d13 to generate a Debian 13 inventory. Barn 1.5.0 verifies the ML-DSA-87 signature on the same bytes. Debian image acceptance · Platforms and Limits

Familystable in 2026120302Family aliasesArchitecture aliases (arm64 / amd64)
d1320261130.2678.1d, debian, debian13, trixied13a, da / d13x, d13i, dx, di
d1220261130.2678.1debian12, bookwormd12a / d12x, d12i
el77.9.20221112.0c7, centos7, centos79— / el7x, el7i, c7x, c7i
el88.10.20240528.3rocky8el8a / el8x, el8i
el99.9.20261112.1rocky9 (rocky in 1.2.0)el9a / el9x, el9i
el1010.3.20261112.1e, el, rocky, rocky10el10a, ea, ela / el10x, el10i, ex, ei, elx, eli
u2220261109.0.1ubuntu22, ubuntu2204, jammyu22a / u22x, u22i
u2420261017.0.1ubuntu24, ubuntu2404, noble (ubuntu in 1.2.0)u24a / u24x, u24i
u2620261108.0.1u, ubuntu, ubuntu26, ubuntu2604, resoluteu26a, ua / u26x, u26i, ux, ui

Unversioned family shorthands point to the newest mainstream family (e/el/rocky → el10, u/ubuntu → u26, d/debian → d13; in Barn 1.2.0, rocky mapped to el9 and ubuntu mapped to u24). Appending a selects arm64, and appending x or i selects amd64—accepted everywhere an image reference is read (image info/pull, --image/-I, BARN_IMAGE, and vm_image, including :channel or @version). For image info/pull, an explicit -A must name the matching architecture. Inventory commands also honor BARN_ARCH. An inventory’s default vm_arch: native defers to an architecture-suffixed vm_image.

Distribution notes:

  • u22, u24, and u26 are Ubuntu 22.04, 24.04, and 26.04 LTS; d12 and d13 are Debian 12 and 13. Barn’s image recipe builds them from the distributions’ cloud images: the image ships a dba user (UID/GID 88), XFS userspace tools are present, and en_US.UTF-8 is available while C.UTF-8 stays the default locale.
  • el7 is CentOS Linux 7.9 (amd64 BIOS), and el8, el9, and el10 are Rocky Linux (amd64 and arm64 UEFI). All three Rocky families go through Barn’s recipe (dba, UID/GID 88). The current el10 images also include signed kernel modules required by Docker’s default bridge networking, iptables firewall rules, and overlay filesystem. el7 remains the distribution’s unmodified cloud image.
  • cloud-init configures accounts and networking on first boot for every image.
  • After a catalog refresh, existing nodes with unchanged definitions use their recorded image, even if the version has left the catalog. New nodes and explicit barn recreate operations resolve the selected image against the active catalog. Catalog rotation tests
AliasDistributionArchitecturesBootStatus
el7CentOS Linux 7.9 / 2211amd64BIOSdeprecated
el8Rocky Linux 8.10amd64, arm64UEFIdeprecated
el9Rocky Linux 9.9amd64, arm64UEFIsupported
el10Rocky Linux 10.3amd64, arm64UEFIsupported
d12, d13Debian 12 / 13amd64, arm64UEFIsupported
u22Ubuntu 22.04 LTSamd64, arm64UEFIdeprecated
u24, u26Ubuntu 24.04 / 26.04 LTSamd64, arm64UEFIsupported
barn update
barn image list
barn image info d13
barn image info d13:stable
barn image info el9@9.9
barn image pull d13@20261123.2671.1
barn image pull d13 --arch arm64

barn image list prints every version and architecture in the active catalog along with registered local-* aliases. barn image info defaults to the host architecture (like image pull, unless an architecture-suffixed alias is given) and can inspect uncached catalog metadata without QEMU; if a local cache file is present, info also runs qemu-img verification on it. Neither list nor info downloads image files.

Catalog status values indicate support tier (supported, testing, deprecated, or unknown); non-supported images still boot normally and emit a status warning.

When pulling an image, Barn executes four steps:

  1. Load the active catalog — Reads the selected repository’s active local catalog once for the command (either the binary’s embedded catalog or the revision last activated for that repository by barn update or barn image sync).
  2. Resolve the selector and architecture — Resolves image[:channel] or image@version-prefix (or the active catalog’s default if omitted) and the target architecture. Bare aliases in standalone image pull default to the host, while architecture-suffixed aliases select arm64 or amd64 directly; lifecycle commands use vm_arch (or an architecture-suffixed alias), also defaulting to the host when unset. --arch/-A overrides non-pinned choices and rejects conflicting pinned aliases; see configuration precedence.
  3. Verify the local cache — Reuses an existing cached file immediately if its byte size, SHA-256 digest, and qemu-img structural checks all pass.
  4. Download with resume and digest checks — Downloads the artifact from the selected repository with automatic retries and HTTP range resumption, verifying the final size, SHA-256, and qcow2 header before moving it into the cache. The two official mirrors (https://repo.pigsty.io/barn and https://repo.pigsty.cc/barn) can fall back to each other during artifact downloads, while custom --repo sources download exclusively from the specified root. Upstream URLs recorded in the catalog serve as provenance metadata only.

Repository selection precedence is --repo → --mirror (https://repo.pigsty.cc/barn) → BARN_REPO → compiled default (https://repo.pigsty.io/barn). Both official endpoints require valid ML-DSA-87 catalog signatures.

Barn tracks each repository separately under $BARN_HOME/images/manifests/. Pass the same --repo or set BARN_REPO when using its images. A freshly built local directory works immediately. For a custom HTTPS repository, run barn update --repo <url> to activate its catalog.

Barn automatically restores read-only permissions (0444) on verified cache files. If an unreferenced cached file fails verification, Barn renames it to .corrupt-<timestamp> before re-downloading; if a VM still uses that base image, Barn leaves the file in place and reports an integrity error.

Runtime policy

When guest and host architectures match, Barn uses hardware virtualization (Apple HVF on macOS, KVM on Linux) with one built-in exception: the stock Rocky Linux 8 arm64 kernel uses a 64 KiB page size that Apple HVF does not support, so Barn automatically runs el8 on Apple Silicon under same-architecture QEMU TCG and flags tcg in status output. Cross-architecture guests (after resolving vm_arch and any command override) also run under TCG; for amd64 guests on arm64 hosts, Barn pins TCG to a single translation thread to preserve x86 memory ordering.

The ARM64 TCG runtime uses cortex-a72 to avoid firmware hangs with the max CPU model in some QEMU/AAVMF combinations. ARM64 guests on Linux x86-64 have passed an actual Barn boot and SSH check. Barn’s catalog and runtime currently accept only amd64 and arm64; other architectures offered by a distribution or QEMU still require Barn integration before use with barn up.

el7 is supported only on native linux/amd64. On Linux hosts, barn setup installs the native QEMU package set; before booting a foreign vm_arch with up or recreate, install the target architecture’s qemu-system-* emulator and UEFI firmware (barn plan can resolve catalog images without them, though local-* imports still require qemu-img).

barn image pull d13 --mirror
barn image pull d13 --repo https://mirror.example/barn
BARN_REPO=/absolute/local/repository barn up

Trust and verification

Barn 1.5.0 checks catalog.json.sig. Barn 1.4.0 reads catalog.json.minisig over the same bytes. Mirror and key instructions

Release binaries embed the official ML-DSA-87 public key (private signing keys live outside the source repository). Catalog activation rejects unknown signing keys, malformed JSON, conflicting content at the same revision number (equivocation), and revisions lower than the repository’s highest accepted revision unless --allow-downgrade is passed to barn image sync. A missing required signature, an invalid signature, or a revision with conflicting bytes produces exit code 7 (integrity). A new trusted signature over identical catalog bytes is accepted, which also repairs a damaged cached signature.

Every cached or imported image must be a standalone qcow2 file matching its declared byte size and SHA-256 digest, with no backing file, external data file, encryption, or unknown incompatible qcow2 feature bits. Barn marks verified base images read-only and creates copy-on-write overlay disks for each VM node.

barn update
barn image sync --repo https://repo.example/barn \
  https://repo.example/barn/catalog.json
barn image sync --repo /srv/barn --allow-downgrade /srv/barn/catalog.json
barn image reset --repo /srv/barn
  • barn update fetches, verifies, and activates the current catalog from --repo or --mirror.
  • barn image sync activates a catalog from an explicit URL or file path (for unsigned custom repositories, the source path must be <repo>/catalog.json) and supports --allow-downgrade.
  • barn image reset reverts the active catalog for --repo (or default repo) back to the binary’s embedded catalog while keeping the recorded highest-revision watermark intact.

Static repository format

A static Barn image repository uses the following directory layout:

/srv/barn

  • repo.yamlOptional image definitions and policy (schema 1)
  • catalog.jsonGenerated runtime image catalog with digests and sizes (schema 3)
  • catalog.json.sigML-DSA-87, required for official and HTTP repositories
  • catalog.json.minisigCompatibility sidecar for official 1.4.0 clients
  • images/
    • <image>-<version>-<arch>.qcow2Immutable qcow2 image artifacts

Without repo.yaml, Barn reads <image>-<version>-<arch>.qcow2, selects the highest version of each family for stable and uses UEFI. An optional repo.yaml (schema: 1) declares defaults, aliases, channels, versions, architectures, boot modes, support status, source_user (for example, rocky upstream or dba after official normalization), and optional upstream provenance URLs—without manual checksums or byte sizes. barn repo build inspects the qcow2 files and generates catalog.json (schema: 3) with each variant’s filename, SHA-256 digest, file size, and virtual disk capacity.

repo.yaml
schema: 1
revision: 1
defaults: { image: d13, channel: stable, arch: native, boot: uefi }
images:
  d13:
    aliases: [debian13, trixie]
    channels: { stable: "1" }
    versions:
      "1":
        status: unknown
        variants:
          amd64: {}
          arm64: {}

When a variant omits file, Barn expects images/<image>-<version>-<arch>.qcow2 (for example, images/d13-1-amd64.qcow2 and images/d13-1-arm64.qcow2).

Repository management rules (barn repo scan|build|verify /absolute/repo):

  • Repository roots accept relative paths, ~/, and directory symlinks. The root and images/ may be shared writable directories. repo.yaml may link to a non-empty regular file up to 4 MiB. Artifact entries remain regular files; catalog.json output symlinks are not overwritten.
  • Boot mode inherits along variant → family → defaults.boot; status inherits along variant → version → unknown. Every family must define the default channel pointing to an existing version, and family/alias names must be unique and cannot start with local-. Avoid reassigning built-in aliases (ubuntu, debian, rocky, etc.) to different families, because inventory parsing normalizes built-in aliases via the embedded catalog first.
  • Channels and dot-separated numeric prefixes (el9@9.9, el9@9) resolve to an exact version key when present or the highest matching numeric version, yielding an immutable artifact identity (image, exact version, arch):
    d13:stable + native
      -> d13@20261130.2678.1 + arm64
      -> images/d13-20261130.2678.1-arm64.qcow2
  • barn repo scan is read-only and does not require qemu-img; it exits 0 while reporting any missing, unsafe, or untracked files in its output arrays (automation must check that missing and unsafe are empty).
  • barn repo build and barn repo verify use qemu-img. An unchanged rebuild preserves the catalog bytes. If you set revision explicitly, increase it when the contents change. Upload the images first, then the catalog with its applicable sidecars. Build and verification

Local layout and imports

Barn stores cached catalogs, downloaded images, and local imports under $BARN_HOME/images (default ~/.barn/images):

$BARN_HOME/images

  • manifests/Active catalog.json and highest accepted revision per repository
  • local-images.jsonRegistry of named local-* image aliases
  • local/
    • <sha256>.qcow2Imported local qcow2 files indexed by content digest
  • d13/
    • d13-20261130.2678.1-arm64.qcow2Verified read-only catalog artifacts by family
    • d13-20261130.2678.1-amd64.qcow2

Import a local qcow2 file into the cache or register it under a local-* alias:

barn image import /path/to/debian-13-generic.qcow2
barn image import --name local-mybase --boot uefi \
  --source-user debian /path/to/debian-13-generic.qcow2

Import rules:

  • image import accepts relative paths, ~/, and symlinks to regular files, and requires qemu-img. Reads are bounded by the actual local file size or declared catalog size; downloads stop on overflow, while legacy downloads without a declared artifact size are bounded at 8 GiB. Optional --sha256 verifies an expected digest.
  • image import copies and validates the qcow2 container as-is without modifying guest credentials, installing cloud-init, or booting the image.
  • Source filenames may contain spaces or Unicode and need no particular extension; Barn validates the qcow2 contents. New imports use local/<sha256>.qcow2, so different images can share a source filename and identical bytes reuse a cache entry. Existing aliases keep their original cache paths when reimported. Updates that exceed the 1 MiB registry metadata limit fail before changing existing aliases.
  • Named imports (--name local-<alias>) require --boot bios|uefi and --source-user <user> and default to the host architecture. --arch/-A can record an explicit amd64 or arm64 architecture, including aliases. The qcow2 metadata cannot identify the guest CPU, and import does not convert architectures. Match inventory vm_arch or the lifecycle command’s -A when using the image. Aliases are immutable and can be referenced via vm_image: local-mybase; unnamed imports only pre-populate the cache and cannot accept -A.

Pruning

barn image prune --dry-run
barn image prune --yes

barn image prune (or barn image prune --dry-run) lists candidate files that can be reclaimed; passing --yes deletes them.

prune protects images referenced by the selected repository’s active catalog, applied nodes, and registered local-* aliases. It can remove unreferenced images, recognized staging files, and read-only quarantine files ending in .qcow2.corrupt-<timestamp> or .img.corrupt-<timestamp>. To retain a quarantined copy for inspection, copy it outside the cache before cleanup. Preview the candidates with --dry-run and the same --repo you will use for deletion. If a later file fails inspection, files already deleted by prune --yes stay deleted.

To export the binary’s embedded schema-3 catalog byte-for-byte when bootstrapping a mirror, run go run ./tools/catalogexport /absolute/new/catalog.json. Any public catalog published at the embedded revision number must match those exact bytes.

2.6 - Self-hosted repositories and official signatures

Build a repository from local qcow2 images and verify official Barn releases.

Share a lab repository by distributing its images and catalog. Barn 1.5.0 supports filename-based builds and ML-DSA-87 verification. Barn 1.4.0 uses repo.yaml for builds and Minisign for official catalogs.

Create and use a lab repository

Place your images under repo/images/, for example lab-pg-1-arm64.qcow2. Run these commands on a host with qemu-img:

barn repo build ./repo
barn up --repo ./repo -I lab-pg

The first command writes catalog.json. Barn takes the image name, version and architecture from each filename and defaults to UEFI. An existing repo.yaml still selects the repository contents. A local repository can be unsigned and use your original image files.

To share it, serve catalog.json and images/ over HTTPS. Set the address on the client and activate the catalog. Run the same barn update when the repository changes.

export BARN_REPO=https://images.example.org/lab
barn update
barn up -I lab-pg

barn update --repo ./repo refreshes only that directory. Explicitly selected local and custom HTTPS repositories can be unsigned. Plain HTTP requires a valid ML-DSA-87 signature. Both 1.4 and 1.5 clients check image SHA-256 digests and byte counts from a schema 3 catalog.

Official images and packages

Use barn up or barn update with the official repository as usual. New clients verify catalog.json.sig with their built-in key. The maintainer publishes a separate catalog.json.minisig over the same catalog for 1.4.0 clients.

Internal mirrors of the official repository should copy both signature files with the catalog. Users who cached that mirror’s catalog in Barn 1.4.0 can refresh it after upgrading with barn update --repo <mirror>.

Initial script installations rely on HTTPS. For independent verification, get the public key through a trusted channel and use OpenSSL 3.5 or later to check the release manifest. Then check the installer and platform archive against that manifest. Use your existing installation channel for upgrades.

openssl pkeyutl -verify -rawin -pubin -inkey /trusted/official-key.pem \
  -pkeyopt context-string:barn/release/v1 -in checksums.txt -sigfile checksums.txt.sig
shasum -a 256 -c checksums.txt --ignore-missing

Generate and store the maintainer key

Barn signs its official image catalogs and CLI release manifests with one ML-DSA-87 key. Run the Bash commands below from the Barn source root with OpenSSL 3.5 or later and ML-DSA support.

First-time generation and public fingerprint

The official key was generated on December 3, 2026. Restore the same key when moving to another machine. The commands below document initial provisioning and stop if the private key already exists. Backup and recovery

The private key is a passphrase-free PKCS#8 PEM. Anyone who can read it can sign as Barn. Keep it on the maintainer’s machine with disk encryption, a mode 0700 directory and a mode 0600 file. Only the exported public key goes into the source tree and build machines.

(
  set -eu
  umask 077
  keydir="$HOME/.config/barn/signing"
  install -d -m 0700 "$keydir"
  set -C
  openssl genpkey -algorithm ML-DSA-87 > "$keydir/official.pem"
  openssl pkey -in "$keydir/official.pem" -check -noout
  openssl pkey -in "$keydir/official.pem" -pubout -out internal/image/official-key.pem
  chmod 0644 internal/image/official-key.pem
)

Get the public key from a trusted release commit. This command calculates SHA-256 over its DER-encoded SubjectPublicKeyInfo. The fingerprint for the official key introduced on December 3, 2026 is 5b108c30d99f93a28184fef362367dc63d4f7c1c2e56c2e0d89c7e3e1f17a262. New Barn clients display the short ID 583F7D5BAA0D16C5 in catalog state. Public key in v1.5.0

openssl pkey -pubin -in internal/image/official-key.pem -outform DER | openssl dgst -sha256

Backup and recovery

Keep a second copy of the private key on a separate encrypted removable volume. Unlock and mount it first, then replace /Volumes/BarnBackup with its actual mount point. Both cmp commands exit silently on success. They check that the backup is byte-identical and that it yields the public key embedded in the client. Eject the volume and store it offline.

(
  set -euo pipefail
  umask 077
  volume=/Volumes/BarnBackup
  key="$HOME/.config/barn/signing/official.pem"
  test -d "$volume"
  install -d -m 0700 "$volume/barn-signing"
  backup="$volume/barn-signing/official.pem"
  set -C
  cat "$key" > "$backup"
  cmp "$key" "$backup"
  openssl pkey -in "$backup" -pubout | cmp - internal/image/official-key.pem
)

To move to a new signing machine, obtain internal/image/official-key.pem from a trusted release commit and restore from the removable volume. The commands check the public key first and preserve any existing private key at the destination. Recover the original key from backup after a disk failure. A compromised key or loss of all copies requires distributing a client that trusts a replacement key.

(
  set -euo pipefail
  umask 077
  backup=/Volumes/BarnBackup/barn-signing/official.pem
  keydir="$HOME/.config/barn/signing"
  openssl pkey -in "$backup" -pubout | cmp - internal/image/official-key.pem
  install -d -m 0700 "$keydir"
  set -C
  cat "$backup" > "$keydir/official.pem"
  cmp "$backup" "$keydir/official.pem"
)

Sign and publish as the maintainer

From the Barn source root, select the image repository and the signing directory. Recompute the image digests and check that the catalog matches the repository.

repo=../repo/barn
keydir="$HOME/.config/barn/signing"
barn repo verify "$repo"

Reuse an existing catalog.json.minisig if it verifies. When the repository changes, first increase the revision and run barn repo build "$repo", then recreate the legacy signature with the original 1.4.0 key using make catalog-sign CATALOG_KEY="$keydir/barn-catalog-active-20261126.key" CATALOG_FILE="$repo/catalog.json". The tool reads the legacy key’s passphrase from CATALOGSIGN_PASSWORD. Sign those same catalog bytes with the new key.

make catalog-verify CATALOG_PUBLIC_KEY="$keydir/barn-catalog-active-20261126.pub" CATALOG_FILE="$repo/catalog.json"
./packaging/official-sign.sh sign "$repo/catalog.json" "$keydir/official.pem"
./packaging/official-sign.sh verify "$repo/catalog.json"

Upload new images to both mirrors and verify their sizes and SHA-256 digests before publishing the same catalog.json.sig, catalog.json.minisig and catalog.json at each repository root. Synchronize the embedded catalog, revision, timestamp and packaging/image-repository/repo.yaml, then run make catalog-check. On each mirror it verifies both signatures, compares the remote catalog with the embedded bytes and checks every stable image’s length. Use go run ./tools/catalogcheck -verify-bytes to stream and hash every stable image on both mirrors.

Once the official CLI draft is ready, run ./packaging/sign-release.sh /absolute/draft "$HOME/.config/barn/signing/official.pem" /absolute/signed. Upload the resulting release.json, checksums.txt and checksums.txt.sig together to that draft, then verify and publish it with make release-publish RELEASE_TAG="$tag". Release sequence

2.7 - Image Pipeline

Contributor tools that validate or offline-normalize qcow2 candidates for Barn’s official Linux images.

This page is for contributors who build Barn’s official Linux images; if you only use images, skip it. To share images of your own, build a static repository instead.

The tools live under packaging/image-pipeline/ in the Barn source checkout. build.sh turns one downloaded qcow2 with a known SHA-256 into a testing candidate bundle, either validated as it is or normalized offline; build-official.py runs it over the official matrix and assembles a candidate repository. The builder needs no network access or signing keys and leaves Barn’s runtime state alone. Its output then goes through live smoke tests and release review.

  • Tools: Python 3 and qemu-img; offline mode also needs working libguestfs tools (virt-customize, virt-cat). Override them with --qemu-img, --virt-customize, and --virt-cat, or with QEMU_IMG, VIRT_CUSTOMIZE, and VIRT_CAT.
  • Storage: keep source images, RPM/DEB package caches, and output directories outside the Git working tree, which tracks only recipes and lockfiles.
  • Architecture: --arch records the target architecture in the metadata; run offline customization where libguestfs can execute that architecture.

Modes and profiles

  • validate copies and re-hashes the source, checks that it is a single-file qcow2 with qemu-img check, and writes an evidence bundle without touching guest files or credentials.
  • offline normalizes guest access on a staged copy with virt-customize --no-network and virt-cat: it confirms UID/GID 88 is free of unrelated accounts, configures the locked dba/admin identity, disables SSH password and root login, strips SSH host keys, shell history, machine-id, and cloud-init caches, restores SELinux labels, and reads back a deterministic guest marker.

The profile adds distribution-specific steps; build.sh defaults to --profile base:

ProfileNormalization stepsPackage inputs
baseAccount, sudo, SSH, and cloud-init normalization onlyNone (package flags rejected)
el8Base normalization plus Python 3, SSH drop-in include, legacy network cleanup, chronyd, and SELinux relabelingLocked RPM dependency set
el9Base normalization plus legacy network cleanup and SELinux relabelingNone (package flags rejected)
el10Base normalization plus signed kernel-modules and kernel-modules-extra matching kernel-core, Docker bridge/iptables/overlay module verification, and SELinux relabelingLocked RPM dependency set
d12, d13Base normalization plus offline XFS userspace tools and en_US.UTF-8 / C.UTF-8 locale setupLocked DEB dependency set

validate accepts only --profile base. In offline mode, el8, el10, d12, and d13 require --package-lock and --package-cache matching the profile and architecture; build-official.py supplies both for official targets.

Official candidate matrix

build-official.py builds the ten official targets, Debian 12 and 13 (d12, d13) and Rocky Linux 8, 9, and 10 (el8, el9, el10), each on amd64 and arm64, from the upstream URLs, package locks, release versions, SHA-256 digests, and SOURCE_DATE_EPOCH pinned in official-v1.json. --list prints what your checkout pins. Ubuntu artifacts come from the same recipe run directly by pipeline.py, and need no offline package lock because Ubuntu cloud images already ship xfsprogs. Debian source inspection and candidate tests · Rocky Linux image tests

./packaging/image-pipeline/build-official.py --list

./packaging/image-pipeline/build-official.py \
  --source-cache /absolute/source-cache \
  --package-cache /absolute/package-cache \
  --output /absolute/existing-output-root \
  --target d13/arm64 --fetch

Create --source-cache, --package-cache, and --output beforehand and pass canonical absolute paths. --fetch downloads missing pinned HTTPS inputs and verifies their SHA-256 before virt-customize --no-network runs; without it, every locked input must already be cached. Omit --target to build all ten, or repeat it for a subset.

Once all ten bundles exist, assemble a candidate static repository from the parent directory that holds them, repeating --assemble-from for bundles spread over several parents:

./packaging/image-pipeline/build-official.py \
  --assemble-from /absolute/existing-output-root \
  --output /absolute/new-candidate-repository

Assembly requires exactly one bundle per target and a new --output path that does not exist yet. It runs barn repo build and barn repo verify with the barn on PATH or --barn /absolute/path/to/barn. The result maps channels to candidate (for example d13:candidate) with status testing, ready for live VM acceptance before promotion to stable and supported.

Validate a single downloaded image

SOURCE_DATE_EPOCH=1796256000

./packaging/image-pipeline/build.sh \
  --mode validate \
  --source /absolute/debian-13-generic-amd64-20261130-2678.qcow2 \
  --expected-sha256 c0f41265017c18124897401ccdd335dd4e1a0c262092384d5e6723855acb7446 \
  --output /absolute/new/evidence-directory \
  --name d13 --release 20261130.2678.0 --arch amd64 \
  --source-user debian --boot uefi \
  --source-uri https://cloud.debian.org/images/cloud/trixie/20261130-2678/debian-13-generic-amd64-20261130-2678.qcow2 \
  --artifact-url 'https://images.example/d13/{sha256}.qcow2' \
  --license NOASSERTION \
  --source-date-epoch "$SOURCE_DATE_EPOCH" \
  --manifest-version 2026120301

--source must be a canonical absolute path to a regular file, not a symlink, of at most 16 GiB; that cap is the recipe’s, while Barn checks runtime images against their catalog size (local import). --output must be a new path in an existing directory. The builder takes an adjacent lockfile, stages in a 0700 temporary directory, and renames the finished bundle into place; on failure it removes only its staging directory.

Each completed bundle contains:

FilePurpose
<name>-<release>-<arch>-<digest-prefix>.qcow2Validated read-only candidate qcow2 image
build-recipe.jsonBuilder invocation, tool versions, and input digests
manifest-candidate.jsonUnsigned candidate metadata (status: "testing")
provenance.intoto.jsonSLSA build provenance statement
sbom.spdx.jsonSPDX software bill of materials covering declared pipeline inputs and injected packages
validation.jsonBefore/after qcow2 checks, normalization marker results, and pending release gates
checksums.txtSHA-256 checksums of the other files in the bundle
package-lock.jsonIncluded when the profile installs locked RPM/DEB packages

Promote a candidate

With fixed inputs and tool versions, validate mode is byte-for-byte reproducible; for offline mode, build the candidate twice and compare the bundles as release evidence. To promote a candidate to a public supported release:

  1. Run live VM smoke tests across the target host and guest combinations.
  2. Update repo.yaml with the new catalog revision and supported status.
  3. Run barn repo build and barn repo verify.
  4. Sign catalog.json and publish its detached signature as catalog.json.minisig.
  5. Verify the published repository endpoints.

3 - Project

Supported platforms, design decisions, security model, contributing, and release records.

Barn is open source under the Apache-2.0 license and developed on GitHub. Bug reports and pull requests are welcome; please report security vulnerabilities privately through the security policy.

Understand Barn

  • Platforms and Limits — Supported hosts and guests, and the limits to plan around.
  • Design — Why one inventory, explicit destruction, two NICs, and identity checks.
  • Security and Trust — What runs as root, what happens to your SSH config, and how images are verified.

Contribute

  • Contributing — Repository map, build and test gates, docs, and catalog maintenance.
  • Mac Release — Maintainer runbook for signing, notarizing, and publishing Barn.app.

Records

Version changes are in the release notes, and longer design discussions in design essays. Dated verification records are kept here for maintainers: Validation History, 1.1.0 Local Acceptance, and 0.9.3 Changes.

3.1 - Platforms and Limits

Which hosts Barn runs on, which guests it supports, and the limits worth knowing before you plan a lab.

Check here whether Barn runs on your machine, which guest systems it can boot, and which limits might matter for your lab. Barn is built for local development and testing, not for hosting production services.

Version covered

The platform tables below apply to Barn 1.5.0. Run barn version to check your installation. The Linux image catalog can change independently through barn update. See the 1.5.0 release notes and version history of CLI options.

Hosts

HostLinux guestsmacOS guests
macOS on Apple SiliconYes — QEMU 8.2.1+ with HVFYes — macOS 27 or later on the host, Barn.app
macOS on IntelYes — QEMU 8.2.1+ with HVFNo
Linux on amd64 or arm64Yes — QEMU 6.2+ with KVM, NetworkManager or systemd-networkdNo
WindowsNo native release; run Barn on a Linux host instead (options)No

Release binaries cover all four macOS and Linux targets. Day-to-day testing on real hypervisors runs on Apple Silicon Macs and amd64 Linux. barn doctor checks a host’s readiness, and barn setup --dry-run shows what Barn would install.

Linux guests

The built-in image catalog offers nine distribution families, each built for both CPU architectures unless noted. New labs in 1.5.0 default to Debian 13. On Barn 1.4.0, select it with barn init -I d13.

FamilyNameArchitecturesNotes
Debian 13d13amd64, arm64Default in 1.5.0
Debian 12d12amd64, arm64
Ubuntu 26.04 LTSu26amd64, arm64
Ubuntu 24.04 LTSu24amd64, arm64
Ubuntu 22.04 LTSu22amd64, arm64Deprecated
Rocky Linux 10el10amd64, arm64
Rocky Linux 9el9amd64, arm64
Rocky Linux 8el8amd64, arm64Deprecated; on Apple Silicon the arm64 image runs under emulation, because its 64 KiB page kernel cannot run on HVF
CentOS 7el7amd64Deprecated, end of life; native amd64 Linux hosts only

Deprecated images still run, for compatibility testing, but support for them is being phased out. Exact versions, aliases, and how the catalog is updated are in Linux Images.

Limits:

  • One lab per user. All nodes live on one private /24, so a lab can hold as many nodes as that subnet has addresses and your host has memory for.
  • One guest architecture per lab. A guest of the other architecture runs under QEMU’s TCG emulation. It works for compatibility testing but is much slower, so do not use it for performance numbers.
  • Host shares need 9p. vm_shares mounts host directories over Virtio-9p, which needs 9p support in both QEMU and the guest kernel. Where that is missing, copy files over SSH instead (Storage and Access).
  • No snapshots or suspend. barn stop shuts the guest down; barn start boots it again. Guest memory is not saved.

macOS guests

barn mac needs an Apple Silicon Mac running macOS 27 or later, a logged-in desktop session, and Barn.app from the same release as the CLI. It does not use QEMU or the Linux lab’s host network, and it does not need sudo. Guests run macOS 27. On a fresh installation, Barn 1.5.0 selects macOS 27.2.1 (26B131) by default. You can choose a compatible local IPSW or select a newer base with barn mac image update.

Limits:

  • Two running VMs per Mac. Apple’s framework allows at most two macOS VMs running at once, across all apps on the Mac, including a base image being installed. You can keep any number stopped.
  • Disk space. The first VM needs about 65 GiB free for Apple’s restore image and the base installation. Details
  • Framework features. USB passthrough, VM snapshots, and suspend/resume are not available. macOS may restrict Apple Account sign-in inside a virtual machine.

Mac VMs are separate from the Linux lab: barn status, barn destroy, and barn purge never touch them. Use barn mac ls and barn mac doctor instead. macOS VMs guide

Your data

Barn VMs are meant to be rebuilt. Root disks are replaced by recreate and deleted by destroy; only data disks marked persistent: true survive both. Keep anything you cannot regenerate on the host or in version control. What survives each operation

3.2 - Design

The decisions behind Barn — one inventory, explicit destruction, native acceleration, two NICs, layered disks, and verified process identity.

Barn’s behavior follows from a handful of decisions. Each one answers a concrete problem that comes up when you run multi-node labs on a workstation. Knowing them makes the rest of the documentation predictable: why barn up never deletes anything, why every node has two network interfaces, why there is no “project” to switch between.

Barn has two workflows that share a CLI and nothing else:

Linux labs (barn …)macOS VMs (barn mac …)
HypervisorQEMU with HVF or KVM; TCG emulation for a foreign architectureApple Virtualization.framework
ConfigurationOne Ansible inventory (barn.yml or pigsty.yml)Named VMs set up with command-line flags
State$BARN_HOME (default ~/.barn)$BARN_HOME/mac (default ~/.barn/mac)
NetworkNAT management interface plus a shared fixed-IP /24One private /24 NAT subnet per VM, guest at .10
Typical useDatabase clusters, Ansible playbooks, multi-node testingmacOS builds, GUI testing, a clean desktop to reproduce bugs

The rest of this page covers Linux labs. The macOS side is explained in native Mac lifecycle.

One inventory, one lab per user

Problem. A Pigsty or Ansible inventory already names every node and its IP address. A per-directory “project” layer on top of it raises questions with no good answers: which file owns a node’s address, whether moving a checkout creates a second lab, and which project owns the single host bridge.

Decision. The inventory is Barn’s configuration, and each user has exactly one Linux lab, stored under BARN_HOME. Barn reads only the host addresses, a few identity fields (nodename, admin_ip, pg_cluster, pg_seq, …), and the vm_* variables. It validates vm_* strictly and ignores everything else, so a typo in vm_mem fails barn validate while PostgreSQL settings in the same file change freely.

What you notice. barn status, barn ssh, and barn stop work from any directory, and barn up in a directory without an inventory resumes the same lab instead of starting a second one. Why Barn has no projects

Creation is declarative, destruction is explicit

Problem. An inventory gets edited for debugging, switched with a git branch, or loses a group in a bad merge. If a missing node meant “delete this VM”, one typo would wipe a database node.

Decision. The inventory authorizes creation, never deletion. Barn hashes each node’s resolved specification and compares it with what was applied:

  • barn up creates new nodes, starts stopped ones, and finishes interrupted guest setup without restarting healthy VMs.
  • In 1.5.0, new labs inherit Debian 13 from the embedded catalog. Each lab records its default image in the applied specification. Upgrading Barn keeps that default, so starting the lab or adding a node preserves its distribution unless the inventory or a command selects another. Upgrade acceptance
  • A changed node is reported as drift and left alone. CPU and memory changes apply with barn resize; other changes need barn recreate.
  • A node removed from the file keeps running until you run barn destroy on it, and a whole-lab recreate refuses an inventory that omits an existing node.

What you notice. barn plan always tells you what up would do, and the commands that delete data are the ones named after it. Declarative does not mean destructive

Native speed, or a clear failure

Problem. QEMU can silently fall back to software emulation when hardware acceleration is unavailable. The VM still boots, but runs far slower, and nothing tells you why.

Decision. When guest and host architectures match, Barn uses HVF on macOS or KVM on Linux, and fails if that accelerator does not work. It uses TCG emulation only when you ask for a different architecture, or when the image catalog marks a guest as incompatible with the host accelerator (Rocky Linux 8 on Apple Silicon, whose 64 KiB page kernel HVF cannot run).

What you notice.

  • The guest architecture is one setting for the whole lab (vm_arch, or -A for one command). It defaults to the host’s. An architecture-suffixed image alias such as el10a or d13x also selects it. Precedence rules
  • barn status shows each node’s architecture and accelerator.
  • Before recreate deletes a working VM, Barn checks that the QEMU binary, network backend, base image, and firmware for the replacement are all present.

Two network interfaces per node

Problem. Cluster software identifies peers by IP address: replication, consensus, load-balancer backends, a keepalived VIP, and Prometheus targets all expect 10.10.10.11 to be the same machine across reboots and reachable from the other nodes. Port forwarding to the host gives you a way in, but nodes cannot form a cluster through it. At the same time, a freshly booted VM needs internet access to install packages, ideally without you editing host firewall rules.

Decision. Every Linux VM gets two NICs with separate jobs:

InterfaceProvided byUsed for
ManagementQEMU user-mode NAT with DHCPInternet access, DNS, and the SSH port forwarded to 127.0.0.1 on the host
LabA host bridge, static address from the inventoryHost-to-node and node-to-node traffic, Ansible, cluster services, VIPs

The bridge lets QEMU run as your user: macOS hosts use a pinned socket_vmnet daemon; Linux hosts use a barn0 bridge managed by NetworkManager or systemd-networkd, with the distribution’s qemu-bridge-helper. Creating it is a one-time sudo step during barn setup.

What you notice. Nodes reach each other and your host at the inventory addresses, and they reach the internet without any NAT rules on your machine. Why every node has two NICs

Images, disks, and configuration change independently

Problem. A base image download is large, a lab’s root disks are disposable, and test data on a data disk can take an hour to regenerate. Tying their lifetimes together means either redownloading constantly or losing data by accident.

Decision. Each layer has its own lifetime:

  • Verified base images are cached read-only under $BARN_HOME/images and shared by all nodes; each node’s root disk is a thin copy-on-write overlay on top.
  • barn update refreshes the image catalog without touching existing root disks. New and recreated nodes get the newer images.
  • Data disks marked persistent: true survive destroy and recreate.
  • barn image prune removes only images that nothing references.

What you notice. Creating a node is fast and nearly free in disk space, and you choose when a node moves to a new image. What survives each operation

Check identity before acting

Problem. A PID file records a number. After a crash or a reboot, that number may belong to an unrelated process, and a path in a damaged state file may point somewhere it should not. Trusting either can kill the wrong process or delete a disk still in use.

Decision. QEMU and image downloads run as your user; root is used only by setup, network install/uninstall, and hosts install/uninstall. Before Barn signals a process or deletes a node’s files, it checks file ownership, that the path is inside the deployment, the VM’s name and UUID over QEMU’s control socket (QMP), and the process start time and command line. If any check is ambiguous, it stops and reports instead of guessing.

What you notice. An interrupted command can be rerun safely, and an occasional “identity mismatch” error means Barn refused to act on something it could not prove was its own. A PID is not a virtual machine · Security and trust

3.3 - Security and Trust

What Barn runs as root, what it does with SSH keys and ~/.ssh/config, what a guest can reach on your host, and how to verify releases and images.

Read this before letting Barn run VMs on your workstation: what it does as root, what it does with your SSH setup and files, and how to check that a download is genuine.

Barn assumes a single-user development machine. Its ownership and process-identity checks keep it from damaging unrelated files and processes by mistake; they are not a barrier against another hostile user on the same host. Inside a Linux lab the nodes trust each other: they share a private subnet, and the control node holds a key to every peer.

What Barn runs as root

Run barn as your normal user. QEMU processes, Barn.app VMs, the image cache, disks, keys, and state all belong to your account under $BARN_HOME. Only three host-wide changes need sudo, and each prints its plan before asking:

CommandWhat runs as root
barn setup (Linux)The system package manager (apt-get or dnf) installs QEMU, firmware, and OpenSSH. On macOS, Homebrew runs as your user
barn network install / uninstallCreates or removes the host-wide fixed-IP network: the barn0 bridge on Linux, the socket_vmnet launchd service on macOS
barn hosts install / uninstallbarn-hosts-helper rewrites only Barn’s marker-delimited block in /etc/hosts

They are separate commands so you can review and run each one yourself. On a terminal, up, start, restart, and reload offer the same setup plan when a dependency or the Barn network is missing; without a terminal they only report it. Unattended preparation is covered in barn setup.

barn-hosts-helper is the only component that writes /etc/hosts, so keep it and barn from the same build. The CLI runs /opt/barn/libexec/barn-hosts-helper only if its SHA-256 matches the digest compiled into the CLI, and the helper checks the file’s ownership, permissions, link count, and content digest before and after writing. A substituted helper never gets root, and a plan reviewed against an older /etc/hosts cannot overwrite newer edits.

barn mac needs no root at all: each macOS VM’s private network is created in user space by its own runner process.

Your SSH keys and ~/.ssh/config

Barn generates its own keys and leaves yours alone:

  • A Linux lab uses one Ed25519 deployment keypair under $BARN_HOME, shared by all nodes.
  • Each macOS VM has its own Ed25519 keypair in its directory under $BARN_HOME/mac.

Every SSH session Barn opens (barn ssh, barn exec, barn mac ssh, and the rest) runs OpenSSH with -F /dev/null, Barn’s key, and Barn’s own known_hosts. Your ~/.ssh/config, personal keys, and ~/.ssh/known_hosts play no part.

So that plain ssh meta or ssh mac1 also works, Barn adds one marked Include block to ~/.ssh/config pointing at a fragment it owns: ~/.ssh/barn_config for the Linux lab and ~/.ssh/barn-mac_config for Mac VMs. Each block is edited only by its owner. If ~/.ssh/config is a symlink or hard link, as with many dotfile managers, Barn leaves it untouched, writes the fragment, and prints the Include line for you to add. A Host you already defined with a Mac VM’s name keeps your definition; Barn publishes that VM by IP address only.

Whole-deployment destroy and purge remove the Linux integration. To remove either one yourself:

barn ssh-config --remove
barn mac ssh-config --remove

Guest accounts and host keys

Every guest accepts SSH public keys only: password authentication and root login are disabled, and the admin account has passwordless sudo.

  • Linux: the login account defaults to dba and can be set with node_admin_username. Its password is locked. Barn also installs the deployment private key on the control node (admin_ip) so Ansible and Pigsty playbooks can reach every peer. Anyone with a shell on the control node can therefore administer the whole lab.
  • macOS: each VM also gets a random login password for the lock screen and GUI administrator prompts, kept in a mode 0600 password file next to the VM’s SSH key; barn mac password shows it. It stays out of Keychain because the key beside it already grants sudo, so Keychain would add signing and lock-state failures without protecting anything more (design note).

Each connection path pins host keys differently:

ConnectionHost-key policy
Host → Linux guest (barn ssh, ~/.ssh/barn_config)StrictHostKeyChecking accept-new against Barn’s private known_hosts, keyed by the VM’s UUID. The first connection pins the key and a later mismatch is rejected. recreate gives the VM a new UUID, so a rebuilt node never hits a stale entry
Linux control node → lab peersStrictHostKeyChecking no and UserKnownHostsFile /dev/null for Barn-managed peer aliases, so playbooks keep working after nodes are recreated
Host → macOS guest (barn mac, ~/.ssh/barn-mac_config)StrictHostKeyChecking yes against the VM’s own known_hosts, keyed by barn-mac-<instance_id>, with agent forwarding off. The first key is accepted only over the runner’s private network, with the runner’s identity checked before and after the connection, and is then pinned

What a guest can reach on your host

A guest sees host files only through shares you configure, and only a macOS guest shares the clipboard:

ChannelLinux guestmacOS guest
Host directoriesvm_shares entries over Virtio-9p, read-only unless readonly: false (shares)--share entries over VirtioFS, writable unless suffixed :ro (shared folders)
ClipboardNone; Linux guests run headlessPlain text up to 1 MiB each way, while the VM window has focus; on by default (clipboard)

A writable share lets guest processes change the host directory directly, and those changes outlive the VM. Share a dedicated project folder, and use read-only shares when the guest only needs to read. The clipboard never sends items that password managers mark as concealed or transient, and it never carries images or files. Turn it off for a VM with barn mac configure <name> --clipboard off (from its next start), or for the current session with Machine → Share Clipboard.

Each Linux node’s management SSH port is forwarded on host 127.0.0.1 only. Data disks hold test data: during recovery Barn may reformat a corrupted filesystem, persistent disks included, so keep anything valuable on the host (when Barn resets a data disk).

Verify releases and images

Each object Barn downloads has its own check:

ObjectVerification
Release assetsThe installer checks the archive against checksums.txt. Verify the detached ML-DSA-87 signature checksums.txt.sig with the official release key to authenticate the checksum list.
Apple Silicon binariesThe release CLI, helper, and Barn.app carry Developer ID signatures and Apple notarization, and the app has a stapled ticket. Local native builds use ad-hoc signing by default
Image catalogOfficial and plain HTTP repositories require a signature from a key embedded in barn. The highest accepted revision is tracked per repository. An intentional rollback requires barn image sync --allow-downgrade
Image filesDownloads must match the catalog’s byte size, SHA-256, and virtual size. Local imports compute the file’s digest and compare it with --sha256 when supplied. Both paths validate the standalone qcow2 format

To check downloaded release assets yourself, run this in the download directory:

shasum -a 256 -c checksums.txt --ignore-missing

Because the signed catalog pins every image by digest, a mirror cannot substitute an image, and the revision check stops it from replaying an older catalog. The official repositories, https://repo.pigsty.io/barn and https://repo.pigsty.cc/barn, always require a valid signature, even when named with --repo. A custom HTTPS or local repository may serve an unsigned catalog, but only when you select it with --repo or BARN_REPO, so add only sources you trust (Linux Images).

The draft records signed:false. The release owner signs the final checksum manifest, which covers release.json with signed:true. Verify the signature · Release gates

Report a vulnerability

Report vulnerabilities privately through GitHub private vulnerability reporting or by email to [email protected], not in a public issue. Include barn --json version, your host OS and architecture, and the smallest reproduction you have, with private keys and passwords removed. You should get an acknowledgement within five working days.

Security fixes ship in the latest 1.x patch release. Only the latest 1.x release is supported; 0.x releases receive no further fixes. The full policy is in SECURITY.md; ordinary bugs go to GitHub Issues.

3.4 - Contributing

Where Barn’s code lives, the checks a change must pass, how to edit these docs, and how releases and the image catalog are maintained.

Start here to change Barn: find the code, run the checks a pull request must pass, and edit these docs. The last two sections are for maintainers cutting a release or refreshing the image catalog. Barn is Apache-2.0; for a large change, open an issue first to agree on the design.

Choose a repository

What you want to changeWhere to work
CLI behavior, VM lifecycle, native macOS component (Barn.app), installer, and packagespgsty/barn
Documentation site, guides, command reference, and translationspgsty/barn.pgsty.com
Official Linux image definitions or offline normalization rulespackaging/image-repository/ and packaging/image-pipeline/ in pgsty/barn

A useful bug report has barn version, the host OS and architecture, the exact command, and the error output with private keys and passwords removed. Report security problems privately. Coding style, error-message rules, and commit conventions are in CONTRIBUTING.md.

Keep the product model

Barn keeps a deliberately small product model, and changes should preserve it:

  • One Linux deployment per BARN_HOME: no projects, leases, or workspaces (scope, rationale).
  • One inventory format: a Pigsty-compatible Ansible inventory; an unknown vm_* key is an error.
  • Absence never destroys: removing a host from the inventory does not delete its VM; destruction is always an explicit command.
  • One privileged path: root work goes through barn-hosts-helper or the reviewed network plan, nowhere else.
  • barn mac stays separate: it never reads the Linux inventory and runs entirely as the invoking user.

Find the implementation

SubsystemSource paths
CLI commands, flags, JSON/YAML output, and error renderingcmd/barn/, internal/failure/
Inventory parsing, defaults, and resolved node specsinternal/config/, internal/spec/
Linux lifecycle: convergence, journals, disks, and SSH readinessinternal/linuxvm/ (internal/private/ in v1.3.0 and earlier), internal/vm/, internal/cloudinit/, internal/state/
Host platform and QEMU argumentsinternal/platform/, internal/qemu/
Host preparation, networking, process identity, and /etc/hostsinternal/setup/, internal/network/, internal/process/, internal/hostconfig/, cmd/barn-hosts-helper/
Deployment SSH keys and the ~/.ssh/config integrationinternal/sshkeys/, internal/sshconfig/
Guest clock checks and scheduled syncinternal/timesync/, internal/timejob/
Image catalog trust, qcow2 verification, and catalog toolsinternal/image/, tools/catalogcheck/, tools/catalogexport/, tools/catalogsign/
Native macOS VMs and the desktop appinternal/macvm/, native/mac-runner/
Packaging, image pipeline, CI workflows, and integration testspackaging/, .github/workflows/, tests/

Read each package’s tests alongside the code: they pin down which failures Barn recovers from automatically and which ones must stop safely.

Build and test

Install Go 1.27.4 and the linters pinned in packaging/toolchain.env; CI asserts these exact versions:

go install honnef.co/go/tools/cmd/staticcheck@v0.8.2
go install golang.org/x/tools/cmd/deadcode@v0.53.0
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
go install golang.org/x/vuln/cmd/govulncheck@v1.10.0

Put GOBIN (or $(go env GOPATH)/bin) on your PATH. make check also needs Python 3, jq, and a C compiler for the race detector.

TargetWhat it doesRun it
make buildBuilds bin/barn and its matching bin/barn-hosts-helper for this hostWhile iterating (details)
make testgo test ./...While iterating
make racego test -race ./...For concurrency changes
make checkEverything CI runs (below)Before every pull request; it must pass
make mac-native-testC and Swift tests for the native runner; needs Apple Silicon, macOS 27+, and Xcode 27+For native Mac changes
make release-snapshotBuilds and verifies a complete snapshot release without uploading anythingFor changes under tools/, packaging/, .goreleaser.yaml, or the Makefile

make check runs module verification (go mod verify, go mod tidy -diff), shell syntax checks, the maintenance-ownership check, unit and race tests, go vet, Staticcheck, the four-target deadcode intersection, errcheck through golangci-lint, govulncheck, cross-compilation for darwin/arm64, darwin/amd64, linux/amd64, and linux/arm64, the image-pipeline and installer tests (including tests/mac-release-test.py), and the dependency-license check. The maintenance check fails when a new file under tools/ or packaging/ is not referenced by a Make target, a workflow, or CONTRIBUTING.md.

Changes to virtualization, networking, or disk behavior also need a live run on the target host (Linux KVM, macOS HVF, or Virtualization.framework for barn mac); name the host in the pull request.

Packaging changes also run the packaging workflow. To reproduce it locally, install GoReleaser, nFPM, and Syft at the versions in packaging/toolchain.env, then run:

make release-snapshot SNAPSHOT_DIST=.goreleaser-review

release-snapshot first runs make release-check (toolchain versions and goreleaser check), then builds and verifies archives, .deb/.rpm packages, SBOMs, and checksums. SNAPSHOT_DIST (default .goreleaser-snapshot) must name one new directory directly under the repository root. To include the native Mac payload, see Mac Release.

Edit the documentation

The site is Hugo with the OINK theme, in pgsty/barn.pgsty.com; the source repository keeps no docs/ directory.

ContentLocation
Task guidesversions/manuals/1.5/docs/start/ for 1.5-specific changes
Command and configuration referenceversions/manuals/1.5/docs/reference/ for 1.5-specific changes
Project pages (this section)versions/manuals/1.5/docs/about/ for 1.5-specific changes
Design decisions and research, with date and implementation statuscontent/blog/design/
Release notescontent/release/

Every page is an English/Chinese pair, page.md and page.zh.md, with the same front matter routing fields and the same explicit {#id} on every heading, which OINK’s Duo View uses to align the two languages. Follow STYLE_GUIDE.md. Check CLI examples against barn <command> --help, and inventory examples with barn validate and barn plan under a temporary BARN_HOME.

Validate the site before committing:

make check

The check verifies Go modules and builds both editions with the pinned OINK theme. It checks internal links, anchors, assets and search indexes before replacing public/. Use make dev to live-edit the 1.5 manual with a sibling ../oink checkout, or make preview to browse both editions with the pinned theme.

Release outputs and gates

Each release publishes:

  • .tar.gz archives for darwin and linux on amd64 and arm64, each with bin/barn, bin/barn-hosts-helper, and licenses/. Since 0.9.2 the Darwin arm64 archive also carries bin/Barn.app, with the CLI, helper, and app signed with Developer ID and notarized.
  • Linux .deb and .rpm packages that install /usr/bin/barn and /opt/barn/libexec/barn-hosts-helper.
  • checksums.txt, its detached checksums.txt.sig, release.json, SPDX SBOMs, the Homebrew formula, and the installer.

Stable versions from 1.0.0 on become GitHub’s latest release. Versions below 1.0.0 and versions with a prerelease suffix are GitHub pre-releases, and the installer needs an explicit BARN_VERSION for them.

Cut a release in this order:

  1. Move the Unreleased entries in CHANGELOG.md into a dated section, update the README installation links, and add an English release note without a top-level heading at .github/releases/<version>.md.
  2. Pass the catalog gate with make catalog-check, synchronizing the embedded catalog first if it changed (below).
  3. Require source CI to pass on the release commit, and a packaging snapshot to pass on the latest packaging changes.
  4. Build the assets from the tag: push v<version> to run the tag workflow, which needs all six Apple signing secrets, or use the local release path. Both verify archives, packages, SBOMs, checksums, and CLI/helper pairing before creating a draft release.
  5. Run live Linux VM acceptance, plus Mac acceptance when shipping Barn.app.
  6. Sign the draft checksum manifest, upload the final metadata and signature, and run make release-publish RELEASE_TAG=v<version>. Update Homebrew and the bilingual site after publication. Signing procedure
  7. Verify anonymous downloads, the installer, and the Homebrew upgrade against the published bytes.

Maintain the image catalog

The catalog embedded in barn and the one published on the mirrors must be byte-identical at every revision; Barn rejects two different catalogs with the same revision as signed equivocation. Never republish a revision with different bytes.

Build and normalize candidate qcow2 images with the Image Pipeline (packaging/image-pipeline/build-official.py --list shows the ten-image matrix). The pipeline produces an unsigned candidate repository for barn repo build and barn repo verify; it never edits repo.yaml, signs, or publishes, so promotion stays a separate step. Promote an image only after native startup and SSH checks on each changed architecture.

Sign the same catalog.json bytes twice. Barn 1.5.0 verifies the ML-DSA-87 .sig sidecar. Barn 1.4.0 verifies .minisig with the existing Minisign key. Maintainer commands and key fingerprints

When the published catalog changes, bring the source in line before the next release:

  1. Verify the new signed catalog, then copy it to internal/image/default-catalog.json.

  2. Update EmbeddedManifestVersion in internal/image/catalog.go and the embedded catalog date in internal/image/manifest.go; update packaging/image-repository/repo.yaml if the repository sources changed.

  3. Run the catalog tests (go test ./internal/image/...), and barn update with a fresh temporary BARN_HOME to confirm the remote catalog verifies and activates.

  4. Run the online gate:

    make catalog-check
    go run ./tools/catalogcheck -verify-bytes

    make catalog-check activates each official mirror’s signed catalog in a fresh temporary data root, requires exact byte agreement with the embedded catalog, and checks every stable artifact’s availability and size. -verify-bytes also downloads and hashes every stable image (several GB, nothing kept). Formal native builds and both release paths run catalog-check automatically; never bypass it to ship references to removed images.

Client-side verification and the repository format are in Linux Images.

3.5 - Shipping the Mac Component

Maintainer runbook for building, signing, notarizing, and verifying Barn’s native macOS release payload.

Only maintainers cutting a Barn release need this page: it builds, signs, notarizes, and verifies the native macOS payload (the CLI, barn-hosts-helper, and Barn.app) inside barn_VERSION_darwin_arm64.tar.gz. To build Barn.app for your own use, see Build from Source; for the overall release order, see release gates.

Payload and signing order

packaging/mac-release.py build produces the payload: MACOS.md, MACOS.json, bin/barn, bin/barn-hosts-helper, and bin/Barn.app. MACOS.json records the version, source commit, file modes, digests, and signing state; the version and commit must match the GoReleaser archives the payload joins.

The app’s bundle identifier is com.pgsty.barn and its executable is barn-mac-runner. The CLI checks the runner’s versioned protocol and still recognizes the v0.9.0 bundle, Barn Mac.app (io.pgsty.barn.mac-runner). Replacing the app keeps VM state under $BARN_HOME/mac.

Because the CLI embeds the helper’s SHA-256, the payload builder signs in this order and the archive verifiers reject any other result:

  1. Build and sign barn-hosts-helper.
  2. Build barn with the signed helper’s SHA-256 embedded, then sign the CLI.
  3. Sign Barn.app with hardened runtime and a secure timestamp.
  4. Submit the CLI, helper, and app to Apple together for notarization. After acceptance, staple the app, validate its ticket, and check Gatekeeper.
  5. Export the payload, extract it again, and recheck the signatures and the stapled ticket.
  6. During release assembly, replace the CLI and helper in the Darwin arm64 archive with these exact signed bytes, and regenerate its SPDX document and the checksums.

Signing the helper again after the CLI is built changes its digest and breaks the pair.

Build a formal release locally

Use this path when the tag workflow has no signing secrets, or to produce release assets on a maintainer’s Mac.

  1. Prepare the Mac. You need Apple Silicon with macOS 27+ and Xcode 27+, the toolchain pinned in packaging/toolchain.env, and goreleaser, syft, rpm, ruby, bsdtar, jq, and python3 on PATH. Find your Developer ID Application identity with security find-identity -v -p codesigning, and store a notarization profile with xcrun notarytool store-credentials. Keep certificate private keys and passwords outside the repository.

  2. Check out the release tag. release-local requires HEAD at tag v<version>, a clean working tree and index with no untracked files, and an origin remote.

  3. Synchronize the catalog if it changed. The formal payload build and release-local both run make catalog-check first and stop on any mismatch; see Maintain the image catalog.

  4. Build the signed payload and assemble the release into a new directory outside the source tree:

    export BARN_CODESIGN_IDENTITY='Developer ID Application: your organization (TEAMID)'
    export BARN_NOTARY_PROFILE=barn-release
    export BARN_MAC_REQUIRE_NOTARIZATION=1
    VERSION="${RELEASE_VERSION:?Set RELEASE_VERSION to the checked-out release tag version}"
    COMMIT="$(git rev-parse HEAD)"
    export SOURCE_DATE_EPOCH="$(git show -s --format=%ct HEAD)"
    export BARN_BUILD_DATE="$(date -u -r "$SOURCE_DATE_EPOCH" +%Y-%m-%dT%H:%M:%SZ)"
    RELEASE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/barn-release.XXXXXX")"
    
    python3 packaging/mac-release.py build \
      "$VERSION" "$COMMIT" "$SOURCE_DATE_EPOCH" "$RELEASE_DIR/native.tar.gz"
    BARN_MAC_PAYLOAD="$RELEASE_DIR/native.tar.gz" \
      make release-local VERSION="$VERSION" OUTPUT="$RELEASE_DIR/assets"
    VariableEffect
    BARN_CODESIGN_IDENTITYDeveloper ID identity used to sign the helper, CLI, and app; unset means ad-hoc signing
    BARN_NOTARY_PROFILEStored notarytool profile; the payload is submitted to Apple for notarization
    BARN_MAC_REQUIRE_NOTARIZATION=1Fails the build unless it is Developer ID signed and notarized; mac-release.py build also runs the catalog gate first
  5. Check the output. release-local accepts only a Developer ID signed, notarized payload built from the same commit, so a snapshot or uncommitted payload fails here. It verifies archives, packages, SBOMs, checksums, and CLI/helper pairing, and writes the assets to $RELEASE_DIR/assets. Continue with acceptance.

Test packaging with a snapshot

In a checkout based on a stable release tag, use the same version helper as CI to select the next patch snapshot (for example, 1.4.1-next after v1.4.0). The packaging check compares the native payload’s version and commit. A dirty checkout uses uncommitted as the commit identifier.

set -e
source packaging/semver.sh
snapshot_tag=$(git describe --tags --abbrev=0 --match 'v[0-9]*')
snapshot_version=$(barn_next_snapshot_version "${snapshot_tag#v}")
snapshot_commit=$(git rev-parse HEAD)
if [ -n "$(git status --porcelain --untracked-files=normal)" ]; then
  snapshot_commit=uncommitted
fi
snapshot_epoch=$(git show -s --format=%ct HEAD)
snapshot_dir=$(mktemp -d "${TMPDIR:-/tmp}/barn-snapshot.XXXXXX")

python3 packaging/mac-release.py build \
  "$snapshot_version" "$snapshot_commit" "$snapshot_epoch" "$snapshot_dir/native.tar.gz"
BARN_MAC_PAYLOAD="$snapshot_dir/native.tar.gz" SOURCE_DATE_EPOCH="$snapshot_epoch" make release-snapshot

Snapshots accept ad-hoc signatures; only formal release verification requires a notarized Developer ID payload.

Configure automated signing

The tag workflow uses these six repository secrets:

SecretValue
MAC_CERTIFICATE_BASE64Base64-encoded Developer ID Application .p12, including the private key
MAC_CERTIFICATE_PASSWORDPassword protecting the .p12
MAC_CODESIGN_IDENTITYImported identity name or certificate fingerprint
MAC_NOTARY_KEY_BASE64Base64-encoded App Store Connect API .p8 key
MAC_NOTARY_KEY_IDAPI key identifier
MAC_NOTARY_ISSUERAPI issuer identifier
Secrets configuredTag workflow behavior
NoneSkips automatic release creation; use the local path
SomeFails immediately
All sixBuilds, signs, and notarizes the payload; any failure blocks release assembly

The Mac workflow imports the signing material into an ephemeral runner keychain and removes it when the job ends; pull requests and snapshots use ad-hoc builds. The release workflow creates the draft release only after verifying the assembled payload.

Verify installation and publish

  1. Run the gates: make check, make mac-native-test, and a full snapshot with the native payload.

  2. Test installation in an isolated directory: first install, repeat install, and upgrade.

  3. Run live acceptance on a supported physical Mac with the packaged app. Check startup, SSH, the desktop window, and normal shutdown; replacing the app must keep instance IDs, machine IDs, SSH keys, and host pins. The harness automates this:

    ARGS=(--barn /absolute/path/to/barn --home /absolute/disposable-home --output /absolute/new-evidence-dir)
    python3 tests/mac-live-acceptance.py "${ARGS[@]}" --plan
    python3 tests/mac-live-acceptance.py "${ARGS[@]}" --allow-test-root --gui
    OptionMeaning
    --barnAbsolute path to the packaged barn
    --homeDedicated, disposable BARN_HOME; mac1 is recreated and destroyed
    --outputNew or empty evidence directory, separate from --home
    --allow-test-rootRequired the first time; marks --home as a destructive test root
    --planPrint the phases without running Barn or touching files
    --guiAdd desktop and clipboard checks
    --allow-downloadLet up download macOS from Apple (about 26 GB) when no base is prepared

    A failed run keeps the VM state and the evidence. When testing SSH integration, isolate the process’s home directory as well as BARN_HOME, because the managed ~/.ssh/config entries live outside the VM state root.

  4. Sign and publish the draft. Stage the verified assets in the tag workflow or local draft. Sign the checksum manifest and upload release.json, checksums.txt and checksums.txt.sig together. make release-publish RELEASE_TAG=v<version> verifies the staged inventory and digests before publication. Signing steps

  5. Update Homebrew. Release assembly generates barn.rb from packaging/homebrew/barn.rb.tmpl, which installs barn into bin and the helper and app into libexec; keep its install and test logic aligned with the tap. Once the assets are public, update all four platform URLs and checksums. Versions with a suffix keep an explicit version line, because Homebrew may otherwise infer 64 from the architecture suffix; plain versions omit it.

  6. Verify the public release. Install from the public archives, the installer, and a Homebrew upgrade against the released bytes, and record signing, notarization, VM acceptance, and public installation results separately in Validation History.

3.6 - Validation History

Original Barn release validation, native VM tests, image checks, and design history.
Note

This page collects documentation, source, packaging, VM, and public-installation checks through 2026-12-02. Each entry identifies the source build or release tested. For current host support and release behavior, see Platforms and Limits and the release notes.

Documentation and release archive

The English and Chinese command references were compared with --help from CLIs built at tags v1.1.0 through v1.4.0. For 1.4.0, the tables cover all 63 operational commands and 181 visible command-specific options, counted per command. Isolated data directories were used to validate and plan the inventory examples, check image architecture selection, and build and verify the sample image repositories. 1.4.0 source · Command reference

The embedded catalogs were checked at all 17 version tags. The archive uses the original tag dates for Farrow 0.1.0–0.8.0 and GitHub publication dates from Barn 0.9.0 onward, all in UTC+8. For the nine GitHub Releases from 0.9.0 through 1.4.0, release.json identified the tagged commit and release channel. All 19 hashes in each checksums.txt and the hash of the checksum file itself matched the SHA-256 digests published by GitHub. Release archive · Public releases

Four official macOS arm64 archives were downloaded and checked against their published SHA-256 hashes. The 0.9.0 and 0.9.1 archives contained the CLI and helper. Both 0.9.2 and 1.4.0 also included Barn.app. In those two releases, codesign --verify --strict passed for the CLI, helper, and app, and xcrun stapler validate verified the app’s notarization ticket. 0.9.2 release · 1.4.0 release

On both official mirrors, make catalog-check verified the signature of revision 2026112601, activated it in a fresh data directory, compared it byte for byte with the 1.4.0 embedded catalog, and checked the availability and size of all 17 stable images. Catalog checker at the release tag

Barn 1.4.0 public release

The annotated tag v1.4.0 points to 9382a996cf56b9c486bdb210a1b8dd00ecda2b6d. This commit passed the macOS and Linux source checks and the full packaging snapshot. Apple accepted notarization submission 57772859-4d6a-4059-9d95-f8cd33a2f7ba. In the final Apple Silicon archive, the CLI, hosts helper and app passed signature verification. The app’s stapled ticket validated, and Gatekeeper reported Notarized Developer ID. Source CI · Packaging CI · Tag workflow

Both official image repositories served revision 2026112601, signed by key B848292042883667. Each activated in a fresh data directory and matched the embedded catalog byte for byte. The release check verified all 17 stable artifact sizes on each mirror. The LAN mirror also passed the SHA-256 check for all 31 images and both network-helper archives. Image catalog and guest checks · Pre-release fixes and verification

GitHub published release 460427007 as the latest stable version at 2026-11-27T10:08:20Z. All 20 draft attachments and all 20 anonymous public downloads matched the locally assembled files in size and SHA-256. The 19 entries in checksums.txt verified, and the public latest redirect selected v1.4.0. Release and downloads

On Apple Silicon and Linux amd64, the public latest installer passed a fresh installation, upgrade from 1.3.0, and repeated installation. Both upgrades retained the test data marker and the runnable 1.3.0 executable. The new executables reported the tagged commit. The Apple Silicon app booted macOS 27.2.1 from the final archive. With the native window open, the runner reported a visible desktop and a ready guest. SSH returned build 26B131. The isolated guest was destroyed and its base was preserved. Installation guide

On Linux amd64, the CLI extracted from the release DEB previewed and downloaded Debian 13.8 (d13@20261123.2671.1). A separate SHA-256 calculation over the cached file matched the signed catalog. A second preview with --prune reported the cached image as unchanged. The Intel Mac and Linux arm64 release archives passed build and package verification. Image update command

In an isolated Apple Silicon Homebrew prefix, brew upgrade pgsty/infra/barn upgraded 1.3.0 to 1.4.0. The installed CLI reported the tagged commit and passed brew test, including the CLI, helper and app signature checks. All four archive digests in the published formula matched the public release files. Homebrew formula update

The Barn formula passed brew style and brew audit --strict --online. The first tap CI run flagged two single-use methods in the shared updater. The fix reads each platform’s URL and digest block once. The updater passed 168 assertions, and a before-and-after render of 32 formulae produced identical results for all 128 platform entries. Tap CI passed on Linux, Intel macOS and Apple Silicon. Updater fix · Three-platform tap CI

Barn 1.3.0 public release

The annotated tag v1.3.0 points to ef58e770e43e7d80e060c077bb80cf1943c6bf6b. Before tagging, this commit passed source and native Mac CI and packaging CI, including the full GoReleaser snapshot. The repository keeps its Apple signing credentials on the release Mac, so the tag workflow skipped remote assembly. Apple accepted the local build as described in local release verification.

GitHub marked release 454853556 as the latest stable version at 2026-11-23T00:21:05Z. For each of the 20 attachments, the authenticated draft download and the anonymous public download matched the local file in size and SHA-256. All 19 entries in checksums.txt verified. The public releases/latest link resolved to v1.3.0. Barn 1.3.0 release and downloads

The public latest installer completed fresh installations on Apple Silicon and Linux amd64. On each host a GitHub connection timeout or disconnect interrupted the first attempt to upgrade from 1.2.0. After retrying the public download, both installations reported 1.3.0 at ef58e77, retained a runnable 1.2.0 CLI and the test data marker, and activated signed catalog 2026112101 from the LAN mirror. The upgraded Mac app passed stapler validate and Gatekeeper reported Notarized Developer ID. Installation and platform downloads

Homebrew upgraded an existing Apple Silicon installation from 1.2.0 to 1.3.0. The installed CLI reported the tagged commit and passed brew test, including signature checks for the CLI, hosts helper, and Barn.app. The formula passed brew style and brew audit --strict --online. Each of its four archive URLs served the size and digest recorded for the release. Homebrew formula update

The first tap CI run flagged Ruby expressions in the shared updater and its tests. After the style fix, the updater passed 168 assertions and produced the same 128 asset names across 32 formulae and four platforms. Tap CI passed on Linux, Intel Mac, and Apple Silicon. Tap CI

Barn 1.3.0 local release verification

The release build at ef58e770e43e7d80e060c077bb80cf1943c6bf6b passed make check and make mac-native-test. make release-local produced four platform archives, four Linux packages, eight SPDX files, the installer, the Homebrew formula, release metadata, and checksums.txt. All 19 entries in the checksum file verified. Apple accepted notarization submission 8ced9387-3265-41ec-ac15-d515c3a7912f. The app extracted from the final Darwin arm64 archive passed stapler validate, and Gatekeeper reported Notarized Developer ID. Release source

On Apple Silicon the installer passed first installation, repeated installation, and upgrade from the published 1.2.0 archive using local copies of the assets. The upgrade retained the earlier executable and the data marker. The generated Homebrew formula installed the same archive in an isolated prefix and passed all 11 assertions. Both official mirrors and the LAN mirror activated signed catalog 2026112101 in fresh data roots. Its bytes matched the embedded catalog. All 29 image files on the LAN mirror matched their listed SHA-256 digests.

On a Linux amd64 KVM host, the packaged CLI booted el10x as Rocky Linux 10.3. The guest loaded the six kernel modules in the image recipe, created a bridge with a veth pair and an nftables NAT chain, and passed barn time status and barn time sync. Its data marker survived stop and start. The test deployment was then destroyed. Rocky image verification

On Apple Silicon, two macOS 27.2.1 guests covered all 15 headless lifecycle phases across the original run and a continuation with the same guest disks. SSH to the second guest timed out during its initial boot under load. After a normal restart, a temporary change from 2 vCPUs and 4 GiB to 4 vCPUs and 8 GiB, and time for the guest to settle, both original instance IDs, SSH identities, and disk markers were verified. The remaining checks covered shared folders, network isolation, normal stop/start, and identity rotation on recreate. A final test at 2 vCPUs and 4 GiB recovered the original marker, opened the native desktop, and verified build 26B131 over SSH with the window visible. One SSH command also exited 255 during that last startup before two consecutive reads of the original marker succeeded. Native Mac acceptance harness

Barn 1.3.0 pre-tag checks

The 1.3.0 candidate passed make check, make mac-native-test, and make release-snapshot on Apple Silicon. Both official mirrors served signed catalog 2026112101 with the same bytes as the candidate, and all 17 stable artifacts matched their signed sizes. A macOS regression test exercised the system plutil with an unset subnet address and a configured mask. Separate preview tests checked that a protected plist could be deferred for a free subnet and that a live overlap still blocked setup. Candidate source

The snapshot was built as 1.2.1-next from the preceding v1.2.0 tag and the candidate commit. Verification covered four platform archives, four Linux packages, eight SPDX documents, and 19 final checksums. The Darwin arm64 archive included the ad-hoc signed Barn.app. With downloads served from the local snapshot, the installer passed fresh installation, repeat installation, and upgrade from a copy of the published 1.2.0 installation. Formal signing, notarization, and public download checks belong to the tagged release. Mac release procedure

A follow-up pre-release audit extended protected sharing-preference deferral to macOS network repair (checking both keys as root before restarting socket_vmnet and preserving clean host-unchanged reporting), aligned explicit --arch native conflict handling across image info/pull and lifecycle commands, and updated golang.org/x/crypto to 0.59.0, golang.org/x/net to 0.63.0, and actions/setup-go to v7.1.0. The updated candidate passed make check (including zero-vulnerability govulncheck and the updated 11-module license check), make mac-native-test, make catalog-check, and fresh BARN_HOME barn update checks against both official mirrors; packaging snapshot and CI gates run after pushing main. Updated candidate source

Before tagging v1.3.0, 8a58fdf refreshed compression dependencies (github.com/klauspost/compress 1.20.5 and github.com/pierrec/lz4/v4 4.1.34) and pinned release tools (GoReleaser 2.20.3 / embedded nFPM 2.49.0, Syft 1.57.2, deadcode 0.53.0, and govulncheck 1.10.0), followed by a full pre-release audit aligning README.md, CHANGELOG.md, .github/releases/1.3.0.md, and the bilingual documentation site (62 operation commands and 176 local option entries). Re-verification passed make check, make mac-native-test, make release-check, make catalog-check, and fresh BARN_HOME barn update checks on both official mirrors; the public release record documents the tag, CI, signing, public downloads and Homebrew checks.

macOS 27.2.1 guest image

On an Apple Silicon host running macOS 27.2.1, Apple’s restore service offered build 26B131. The 25,595,954,706-byte IPSW matched Apple’s SHA-256 233e85a09887579d47d0b195e7db72be7f204261059c6946f719acf6b300814f. Restoring it to a 100 GiB base took 438 seconds. The source build selects this image on first use. Barn 1.2.0 also reused the new base with barn mac image update, while the existing stopped VM kept its original instance ID and 26A428 base. Mac image selection

In an isolated BARN_HOME, barn mac exec mac1 -- sw_vers on a freshly cloned guest returned macOS 27.2.1 and build 26B131. The first run exposed a case-sensitive check for SSH configuration keywords in the harness. OpenSSH 10.5p1 reported PasswordAuthentication no, KbdInteractiveAuthentication no, and PermitRootLogin no. After the parser accepted both keyword styles, two fresh guests passed all 15 headless lifecycle phases in 390 seconds, including SSH and sudo, shared folders, stop/start, and identity rotation on recreate. After both test VMs were removed, all 10 checks in barn mac doctor passed in the original store. Native Mac acceptance harness

Barn 1.2.0 final acceptance

ItemRecorded identity
Tag and commitv1.2.0 → 90f615804b823b4eb491101e642073dcd37a9700
Build time2026-11-11T23:38:07Z; SOURCE_DATE_EPOCH=1794440287
GitHub ReleaseID 442314866; published 2026-11-12T00:05:32Z as stable/latest
Apple notarizationAccepted submission 165b486b-5055-4eca-a595-54bed6bdd6c1
Signed catalogRevision 2026110502; SHA-256 d41e46d20bc57cb1b071e3919a27a8f7f703df2addca879970a528e7ab004065
  • CI and packaging: Source/Mac CI and complete packaging CI passed the release commit. The tag workflow passed its signing-configuration check and skipped remote assembly; the documented local signing path produced the formal release. make release-local, signatures, notarization, staple, and Gatekeeper passed.
  • Final artifacts and catalog: All 20 draft and all 20 anonymous public downloads matched the verified local sizes and SHA-256 digests. Both official catalogs verified, activated in fresh roots, and matched the embedded bytes; each mirror’s 17 stable artifacts passed reachability/size checks. Selected runtime image downloads also verified their payload digests.
  • Final runtime: The downloaded Linux archive passed 18 KVM operations covering ext4/XFS root growth, idempotence, shrink rejection, guest-tool failure, CLI interruption, identity/data retention, concurrency, and teardown. The downloaded native Mac bundle completed all 15 lifecycle phases plus desktop, two-way clipboard, close-window background execution, SSH, and normal shutdown. One Apple HTTPS timeout was preserved and retried successfully after identity/base checks; no product bytes changed.
  • Public delivery: Public latest and pinned installers passed on darwin/arm64 and linux/amd64. Isolated installer upgrade from 1.1.0 and repeated installation passed. The Homebrew update passed a real 1.1.0 → 1.2.0 upgrade, brew test, style, and strict online audit. The bilingual reference now documents 57 commands and 174 local option entries per language against 1.2.0.

Physical runtime coverage was darwin/arm64 and linux/amd64; darwin/amd64 and native linux/arm64 received cross-build and artifact checks. The historical 1.1.0 homepage recording is explicitly labelled. See the complete release review for candidate upgrade evidence, retained retries, and scope limits.

Barn 1.2.0 preparation

The 1.2.0 readiness review preserves the uncommitted candidate’s source, catalog, full snapshot, Linux/KVM and native Mac checks, followed by the completed commit, CI, signing, and publication gates.

Barn 1.1.0 final acceptance

ItemRecorded identity
Tag and commitv1.1.0 → b2cc8da8983e710255d504bf26bf5d7b3f182790
Build time2026-11-09T01:28:55Z; SOURCE_DATE_EPOCH=1794187735
GitHub ReleaseID 438656123; published 2026-11-09T01:46:13Z as stable/latest
Signed catalogRevision 2026110502; SHA-256 d41e46d20bc57cb1b071e3919a27a8f7f703df2addca879970a528e7ab004065
  • Source and packaging: The release commit passed source/Mac CI and complete packaging CI before tagging. Local make check, make mac-native-test, and make release-snapshot also passed. The tag workflow passed its signing-configuration check; the complete release used the documented local signing path because repository signing secrets were absent.
  • Downloaded assets: All 20 draft attachments were downloaded again and matched the local sizes and SHA-256 digests. The 19-entry checksum manifest, archive/package parity, four binary architectures, file permissions, helper pairing, and SPDX documents passed verification. Apple accepted notarization submission cabe1b9c-fc54-4f07-b8bf-d834f0226013; the downloaded app passed signature, staple, and Gatekeeper checks. The relocated Homebrew bin/libexec layout found the matching native component.
  • Catalog: Both official catalogs passed signature verification, activation in fresh data roots, and byte comparison against the embedded catalog; all 17 stable artifacts passed HTTP availability and size checks on both mirrors. The final downloaded binary also activated the official catalog in a fresh BARN_HOME.
  • Linux runtime: The downloaded linux/amd64 binary created a Debian 13 guest using -I d13 -A x86_64 without rewriting its inventory. CPU/memory changes 2/2 GiB → 3/3 GiB → 2/2 GiB, stop/start, remote arguments, and exit 17 passed. VM UUID, SSH public key, machine ID, and the persistent-disk sentinel survived resizing and restart. A second Debian 13 guest booted as arm64 through -A aarch64, using QEMU TCG with cortex-a72; SSH reported aarch64. Both test guests were removed after verification.
  • Mac runtime: A new isolated macOS 27 guest passed creation, SSH, remote exit 17, stop/start, identity and data retention, and destruction. Existing user SSH files were unchanged and the user’s running Mac VM was left in place. The signed public installer and repeated installation also passed in a separate directory.
  • Public delivery: Anonymous downloads of all 20 public attachments matched the verified draft. Both the default installer and explicit BARN_VERSION=1.1.0 installed the published release. The Homebrew update sets all four archive URLs and digests. The initial Ubuntu 26.04 recording verified public installation and a first Linux VM on a prepared host network; the homepage recording now shows a real Apple Silicon macOS run (brew install pgsty/infra/barn, ./configure -c full, a four-node barn up, and barn status on macOS 27.0.1 with QEMU 11.1.3). A subsequent 16-stage in-place upgrade and multi-distro acceptance run on Apple Silicon is recorded in Barn 1.1.0 Local Acceptance.

Physical hosts covered darwin/arm64 and linux/amd64, with an additional linux/arm64 guest under TCG. darwin/amd64 and native linux/arm64 received cross-build and artifact checks. GUI and clipboard evidence retains its earlier dated scope. Initial harness retries corrected unsupported timeout flags, a test write requiring guest sudo, and a TCG assertion that did not accept the thread=multi option; their logs were retained alongside the successful runs.

Barn 1.0.0 final acceptance

The final acceptance record binds the downloaded artifacts and public installation checks to this release identity:

ItemRecorded identity
Tag and commitv1.0.0 → 69ef7f1d6ffc7c6fbffffe178b2fa48e799dc02d
Build time2026-11-04T17:54:45Z; SOURCE_DATE_EPOCH=1793814885
GitHub ReleaseID 434268111; published 2026-11-04T23:18:10Z as stable/latest
Signed catalogRevision 2026110502; SHA-256 d41e46d20bc57cb1b071e3919a27a8f7f703df2addca879970a528e7ab004065
  • Source and downloaded assets: The final commit passed source/Mac CI and packaging CI. The release used local Developer ID signing because automated signing secrets were absent. All 20 uploaded attachments were downloaded again, matched their original sizes and SHA-256 digests, and passed the 19-entry checksum manifest plus archive/package, CLI/helper, architecture, permission, SBOM, and identity checks.
  • Catalog bytes: Both official catalogs verified and matched the embedded bytes. Streaming all 17 stable artifacts from each mirror produced 34 successful size/digest checks. A fresh BARN_HOME activated the catalog with barn update.
  • Packaged Mac acceptance: The downloaded CLI/helper/app passed Developer ID, notarization, staple, and Gatekeeper checks, including after installation and relocation into the Homebrew layout. An isolated 0.9.3 → 1.0.0 installer upgrade retained the old release and existing VM identities, SSH keys, and data sentinels. A new VM passed SSH, write, stop/start, identity/data retention, and destruction checks.
  • Linux acceptance: On linux/amd64, the downloaded binaries created two Debian 13 guests in a fresh state root. Fixed IPs, accounts, XFS data disks, stop/start/restart, argument boundaries, and remote exit 17 passed. Missing-node recreation failed before stopping VMs; control-node deletion elected a successor; destruction followed by up rotated machine identity while preserving a persistent-disk sentinel.
  • Public channels: After publication, both the default installer and explicit BARN_VERSION=1.0.0 installed the public release. Real Homebrew upgraded 0.9.2 → 1.0.0 and passed brew test, online audit, and tap tests. The tap update and site update were published, and the public bilingual release and installation pages were checked.

Physical runtime coverage was darwin/arm64 and linux/amd64. darwin/amd64 and linux/arm64 received cross-build and artifact checks. GUI, clipboard, and fault-injection experiments from the preceding candidate run retain that earlier identity below.

Hardening and candidate rehearsals — 2026-11-04–05

The hardening checkpoint at 377061c passed source checks and a 0.9.4-next packaging snapshot without a native Mac payload. Subsequent physical-host tests began with 0.9.4-next; fixes received focused retests, followed by a signed and notarized 1.0.0-rc.1 build using catalog 2026102802. The candidate run covered disk-preservation checks, lock release after cancelled sudo work, shared-networkd uninstall, the 15-stage Mac lifecycle, GUI/clipboard, and interrupted-recreate recovery. Final release assembly later used catalog 2026110502 and the identity above.

The record retains failed attempts as well as successful reruns. A short SSH probe needed bounded retry; a resource-constrained build and a shared module-cache failure needed environment corrections; one acceptance assertion incorrectly required a stdout field when successful empty output could omit it. The dm-error experiment was rejected by the whole-disk guard before reaching the filesystem checker. These observations identify which product path actually ran and which failure belonged to the harness or environment.

Barn 0.9.1 local candidate acceptance

The 0.9.1 record reports make check, native component tests, four-platform packaging, and an ad-hoc native payload. The CLI candidate was 0.9.1-dev.1; the complete snapshot was 0.9.1-next. An isolated upgrade from a real 0.9.0 archive used a local download fixture and verified repeated installation, retained releases, helper pairing, and app discovery. Homebrew checks covered the bin/libexec layout; native tests and mac doctor did not start a VM. The public 0.9.1 assets contained CLI/helper archives and Linux packages, without Barn.app; the original record’s public-release checklist describes the subsequent process, not completed runtime evidence.

Pre-0.9.0 checkpoint

At the 2026-09-29 checkpoint, Barn 0.9.0 was the first release candidate prepared under the barn name prior to publication. For current installation commands, use the Quick Start.

Documentation baseline

ComponentIdentity at the 2026-09-29 checkpointScope notes
Application and docsBarn 0.9.0 release candidateBuilt from the renamed source tree prior to public tag release
CLI and configurationbarn, barn.yml, BARN_*Clean break from earlier internal names
State and host resources~/.barn, Barn networking, and barn-hosts-helperUses fresh ~/.barn state without migrating pre-rename development directories
Image repository/barn on the official endpointsRequires valid minisign catalog signatures

macOS guests

At the 2026-09-29 checkpoint, barn mac ran macOS 27 guests on Apple Silicon via Barn Mac.app (io.pgsty.barn.mac-runner; subsequently renamed to Barn.app / com.pgsty.barn in Barn 0.9.1) with state under $BARN_HOME/mac (see the current macOS Guests guide and Mac Commands reference).

Following the rename on 2026-09-29, local CLI and barn-hosts-helper unit suites, native bridge/image/exit-prompt/menu tests, the runner bundle build, ad-hoc code-signature verification, and probe checks all passed, building on the full 16-phase live macOS VM acceptance run recorded earlier that day.

The rename record explicitly limits the renamed build’s evidence to those checks: its VM lifecycle was not replayed. The 2026-10-03 archive correction retained the original dates, versions, commits, and test scope rather than attributing earlier VM runs to the renamed build.

Remaining pre-0.9.0 release checks

At the 2026-09-29 checkpoint, the remaining pre-publication gates for 0.9.0 were:

  • Full source, archive, DEB/RPM, installer, and four-platform checks on the final tagged commit.
  • Fresh host setup and Linux/macOS VM lifecycle and cleanup verification under the renamed binary and paths.
  • macOS Developer ID signing, notarization, and release publication.
  • Verification of the public GitHub repository, Homebrew tap, official /barn image endpoints, and barn.pgsty.com.

Earlier Mac implementation records

  • 2026-09-26–27: The initial implementation log records a full IPSW download and CLI restore, base-image immutability, dual-guest lifecycle tests, and installer rejection of a modified package. The final 12-stage run took 140.305 s starting with already initialized guests. It used the retired fixed-slot/shared-network implementation and an ad-hoc development signature.
  • 2026-09-28: The complexity review retained identity, locking, and recovery safeguards while simplifying the implementation. Regression checks verified that readiness did not rewrite SSH material. An initial shutdown timeout coincided with high guest load; the full rerun passed without forced power-off or timeout changes. The record treats the load as an observation, not a proven cause.

Barn Mac native record

On 2026-09-29, the pre-rename development tree was validated on an Apple Silicon Mac running macOS 27.0 (26A428) using an ad-hoc signed development build and APFS clones of a base image prepared on 2026-09-26 from Apple’s pinned 27.0 restore image:

  • Source and bundle checks: Full make check, native Swift component tests, and the Mac bundle build with extracted-archive checksum, signature, and probe checks passed.
  • Automated 16-phase live acceptance (244.9 s): Verified VM creation from the base image, named VM creation with a VirtioFS shared folder, independent machine identities, sshd hardening, disk and per-VM subnet isolation, DNS, outbound HTTPS, exit-code propagation, exec argument boundaries, bidirectional shared-folder writes, clean stop/start, configure, enforcement of the two-VM running limit, recreate identity rotation, desktop window display, two-way plain-text clipboard sync, idempotent up, and destroy.
  • Manual timing and recovery checks: First boot from a prepared base image reached SSH readiness in 22 s; clean shutdown completed in 6.5 s; subsequent starts reached SSH readiness in 6–12 s; forced power-off completed in 0.7 s. Also verified booting into macOS Recovery (--recovery), changing --subnet while preserving the pinned SSH host key, and connecting via ssh mac1 through installed ~/.ssh/barn-mac_config entries.

Items deferred to subsequent release milestones at that checkpoint:

  • Developer ID signing, Apple notarization, and public distribution of the app bundle.
  • End-to-end IPSW download + base preparation via first-time barn mac up or barn mac image update.
  • Desktop menu Restart… and Shut Down… actions, additional Apple Silicon models, and host reboot persistence.

The same named-machine record includes a later 07ebfd4 candidate rerun: all 16 phases passed in 298.9 s after an initial five-second SSH probe failed and the guest answered on a later observation. Both runs reused an existing 26A428 base; fresh download and restore remained outside that checkpoint’s coverage.

Pre-rename Linux validation summary

Host or artifactPathLast verifiedResult
Two Linux amd64 hosts (m0, m3)KVM, 7 guest distributions per host2026-09-21 (0.8.0)Clean initialization, first SSH, in-place candidate upgrade, repeated up, stop/start, disk identity, and Ansible inventory reads passed
Two macOS arm64 hosts (m1, m5)HVF, 7 guest distributions per host2026-09-21 (0.8.0)Full 7-distro lifecycle checks plus 7-node ansible all -m ping passed
Catalog 20260920019 families, 37 artifacts (September Debian/Ubuntu refresh)2026-09-21Embedded, local, LAN, and public catalog bytes matched (23e8dbf6...); 10 new image objects verified at both public endpoints and booted across the 4 hosts
Ubuntu 26.04 amd64KVM, QEMU 10.2.1, Ubuntu 24.04 guest2026-09-16 (0.7.0 recovery)Corrupt data-disk reset, failed probes, busy mounts, retained-disk recreation, share recovery, and idempotent up passed
macOS arm64HVF, Ubuntu 24.04.4 guests2026-09-05 (0.6.0 lifecycle)Create, scale-out, control-to-peer SSH, stop/start, reload, recreate, degraded status, and scale-in passed
macOS 26.6.2 arm64HVF, QEMU 11.1, socket_vmnet2026-09-01 (v0.2.0)Selected node create/SSH/stop/start, incremental cached create, full status, and full destroy passed
macOS 26.6.2 arm64HVF, QEMU 11.1, socket_vmnet2026-08-27Single-node and additive four-node lifecycle passed
Ubuntu 26.04 amd64 (mx)KVM, QEMU 10.2.1, NetworkManager2026-09-01 (v0.2.0)Audited a live four-node deployment and connected to its control guest
Ubuntu 26.04 amd64 (mx)KVM, QEMU 10.2.1, NetworkManager2026-08-27Host setup, single-node, additive four-node, and network uninstall passed
macOS arm64HVF host, TCG rule for Rocky Linux 8.10 arm642026-08-28Boot, stop/start, and SSH readiness in 44.2 s passed
Published Catalog 20260905019 families, 27 qcow2 artifacts2026-09-05Artifact verification, embedded/public byte equality, and signed barn update against both official endpoints passed
Published Catalog 20260829039 families, 27 signed qcow2 artifacts2026-08-29Full 19 GiB SHA-256 sweep and clean-client d13:stable pull passed

In the 0.8.0 four-host acceptance run, each host booted Rocky Linux 9.8 and 10.2, Debian 12.15 and 13.7, and Ubuntu 22.04.5, 24.04.5, and 26.04.1 (28 guest VMs total, all passing and cleaned up afterward). Both official endpoints served catalog 2026092001 with SHA-256 23e8dbf6c19bd192d56c6d71eb30901f17945b3487e427a43abe108463780306, verified via isolated barn update runs and HTTP HEAD content-length checks on the 10 new image objects.

Open test items at the earlier checkpoint

  • Rocky/EL9 hosts with NetworkManager + firewalld, and a fresh systemd-networkd host replay.
  • Physical host reboot persistence across active deployments.
  • Live hypervisor runs on darwin/amd64 and linux/arm64 hosts beyond cross-build and package verification.
  • End-to-end el7 VM lifecycle replay on native linux/amd64.
  • Full Pigsty configure → barn up → install.yml playbook execution.
  • Fresh-host setup and VM creation driven end-to-end from the public download installer, Homebrew formula, or published DEB/RPM packages.

Barn verification history

Farrow 0.8.0 — 2026-09-21

  • Release CI and assets: Tag v0.8.0 (320a32afa8f6fca02592215aa0d5607ca4e852b2) passed source CI, the packaging snapshot workflow, and the release tag workflow, publishing 20 release assets (19 checksummed payloads). All 20 assets were downloaded anonymously, the 19 payloads matched the entries in checksums.txt, and isolated user-prefix installs on darwin/arm64 and linux/amd64 verified 0.8.0 (320a32a).
  • Homebrew tap: Commit 9c34019 updated pgsty/infra/farrow to 0.8.0 across all four targets and passed local brew fetch, audit, and tap CI.
  • Four-host 7-distro acceptance: Clean initialization was run at baseline commit 6d7870e26cb2f4082a00c188f746783fc027687e across two Linux amd64 hosts (m0, m3, installed from the .deb package) and two macOS arm64 hosts (m1, m5, installed from the verified archive), booting the 7-distro pro inventory from a local LAN repository. Runtime candidate 1c054a027420b5410c6f6feb344e27e001ae1af1 (adding the macOS Homebrew authentication-order fix) was then installed in place on all four hosts and verified across idempotent up (preserving running QEMU processes, VM UUIDs, and disk inodes), two rounds of guest SSH, stop/start, /data disk mounts, Debian locale/XFS checks, control-to-peer SSH, and Ansible inventory reads (ansible all -m ping on both Macs). See the 0.8.0 Release Notes for per-host timings.

Farrow 0.7.0 release — 2026-09-17

  • Release CI and assets: Commit 9c6d4896d93733d1cb60a7e5d8591e9a06659c9d (v0.7.0) passed source CI, the packaging snapshot workflow, and the release tag workflow. All 20 public release assets passed anonymous download and SHA-256 verification, public installer checks passed on darwin/arm64 and linux/amd64, and pgsty/infra/farrow passed local brew upgrade and brew test.
  • Ubuntu amd64/KVM storage & bootstrap recovery: Tested corrupt ext4/XFS data-disk resets (3.2 s recovery while keeping the QEMU process alive), persistent disk retention across recreate, transient probe failures and busy mounts (preserving existing disk data and UUIDs), read-only 9p share fallback, and resuming a 0.6.0 VM whose initial egress probe had failed (3.3 s recovery, surfacing the expected control-ssh warning where 0.6.0 had already removed the staged control key; see the 0.7.0 Release Notes). Catalog 2026090501 remained unchanged.

Farrow 0.6.0 release — 2026-09-05

  • Release CI and assets: Following lifecycle, UX, release-metadata, and CI fixture reviews, commit 057774e3a13477782a2ae07bd71127d03c0f1ae7 (v0.6.0) passed Go 1.27.1 source CI, packaging checks (13d9d70), and the release tag workflow, producing 20 verified release assets. An isolated darwin/arm64 installation verified upgrading from 0.5.0 to 0.6.0 via the public installer, plus farrow init and farrow plan.
  • macOS arm64/HVF lifecycle acceptance: Verified initial boot, scale-out without restarting the control node, control-to-peer SSH, stop/start, reload, selective recreate, scale-in, guest /etc/hosts refresh, preflight rejection of invalid reload or conflicting partial recreate before stopping existing VMs, degraded status reporting, and SSH exit code 255 passthrough.
  • Catalog 2026090501: Switched the default image to u24:stable and incorporated the Debian/Rocky updates from 2026090302 across all 27 verified qcow2 artifacts on both official endpoints.

Farrow 0.5.0 release — 2026-09-03

Commit fc85b65ff6a24b0933b56ae1179be9ada2ba91b1 (v0.5.0) passed Go 1.27.1 source and GoReleaser packaging gates and published the 20-asset pre-release. 0.5.0 introduced confirmation-free whole-deployment farrow purge, set https://repo.pigsty.io/farrow as the global default repository with --mirror for https://repo.pigsty.cc/farrow, removed implicit upstream URL fallback during artifact downloads, and added packaging/image-pipeline/build-official.py for the eight digest-pinned Debian/Rocky targets.

Farrow 0.4.0 release — 2026-09-02

Passed make check and all release archive, DEB/RPM, SBOM, checksum, installer, and Homebrew formula gates. farrow up gained automatic interactive host setup when run on an unprepared terminal host, vm_disks[].fs defaulted to auto, readiness errors began surfacing the last guest error line, and CLI output formatting was unified across commands.

Farrow 0.3.0 release — 2026-09-02

Passed make check and all release packaging gates. Made catalog refreshes explicit via farrow update and farrow image sync, and added per-node failure stages and log inspection hints to guest readiness error messages.

Farrow 0.2.0 release — 2026-09-01

Commit 59d1b62aebb3d044a317e4006cc8a0bf56f4feaf (v0.2.0) passed source CI, packaging workflows, and local four-platform archive, DEB/RPM, and SPDX verification. Live darwin/arm64 HVF acceptance verified selective u24-1 create/SSH/stop/start, incremental cached el9-1 creation, whole-deployment status, and destroy with SSH config cleanup. On Ubuntu 26.04 amd64/KVM, the Linux binary audited a running four-node deployment and connected to its control guest.

Schema-3 Catalog closure — 2026-08-29

Catalog 2026082903 (9 families, 27 artifacts, SHA-256 571b1ff9c7d4d42355df3392ea62a339471c2d01d868669a7625fac8b93f245d, signed by key 4686B39A40F9B562) passed byte-for-byte equality checks between the embedded catalog and published endpoints, a full SHA-256 sweep across all 27 qcow2 artifacts (19 GiB), and a clean-client d13:stable (409.3 MiB) download and qemu-img check on darwin/arm64.

0.1.0 candidates — 2026-08-28 and 2026-08-29

Validated two targeted fixes prior to 0.2.0:

  • Targeted QMP recovery: When QMP sockets were externally removed from two of four running nodes on darwin/arm64, Barn restarted only the two affected nodes (13.7 s to readiness) while keeping the two healthy nodes’ boot IDs unchanged.
  • QEMU-free catalog inspection: Decoupled farrow image list and make check from requiring qemu-img on PATH when no local cached qcow2 files need inspection.

EL7/EL8 compatibility — 2026-08-28

Commit 7c666c7 restored el7 and el8 support with regression tests covering pre-recreate runtime preflight ordering and signed-catalog baseline migration. Catalog 2026082801 (9 families, 17 image artifacts, plus 2 socket_vmnet archives) passed full SHA-256 and signature checks, and an isolated darwin/arm64 run booted Rocky Linux 8.10 arm64 under the built-in TCG rule to SSH readiness in 44.2 s (verifying NetworkManager, fixed IP, dba UID/GID 88, and guest markers).

Native replay — 2026-08-27

Verified fixed-IP networking, SSH readiness, default CPU/memory/root/data disks, cloud-init, stop/start, cross-directory CLI invocations, control-node uptime preservation during scale-out, control-to-peer SSH, ignoring upper-layer Pigsty variables, and explicit-only node destruction across darwin/arm64 and linux/amd64 (mx). On Linux, also verified passwordless sudo automation, Debian qemu-bridge-helper group permissions, unprivileged bridge attachment, refusal to uninstall an active bridge with four attached tap interfaces, and clean network teardown after destroy.

3.7 - Barn 0.9.3 Changes

Barn 0.9.3 changes covering resource resize, recovery, paths, sharing, node selection, images, and limits.

This page records the user-visible changes in Barn 0.9.3, tagged on October 31 and published on November 1, 2026 (UTC+8). The workflow changes began in source commit 27f17bb and were completed by the commits leading to the release. Check barn version when auditing another build.

See the Barn 0.9.3 release notes for the upgrade summary and the complete bilingual release note.

Resource changes and recovery

Edit vm_cpu or vm_mem and run barn resize [node...]. QEMU hot-plugs supported increases when the running VM has reserved capacity; decreases, older VMs, and unsupported backends use a stop/start fallback. The VM identity, disks, and SSH keys remain unchanged. resize refuses image, disk, network, share, creation, removal, and deployment-wide changes; use recreate, up, destroy, or a full selected operation as indicated by its next: field.

Linux and macOS lifecycle, persistent-disk, and replacement operations journal their transition state. If a process is interrupted or receives SIGINT or SIGTERM, the next lifecycle command can recover the operation; cancelled commands report the structured cancelled result. On macOS, barn mac up --no-wait returns when the VM process starts and may leave first-boot SSH and sudo provisioning running. Run barn mac up NAME again to wait for readiness.

Paths

barn init and setup work through directory symlinks. init -o ./lab/config/barn.yml also creates missing parent directories. Existing files still require --force, and writes never follow or replace an output-file symlink.

User-selected paths now accept normal development layouts:

InputResolution
BARN_HOMERelative paths, ~/, and directory symlinks; may also be the working directory
Inventory and provision --scriptSymlinks to regular files; each file retains its 4 MiB limit
Linux vm_shares.hostRelative to the inventory’s real file, or an absolute/~/ path; directory symlinks work
Local image repository and image importRelative paths, ~/, and symlink inputs
catalogexport outputRelative paths and ~/, directory aliases, and automatic parent creation; target must be absent
BARN_MAC_RUNNER and local socket_vmnet archiveRelative paths and ~/; archive inputs may be symlinks and still undergo digest verification

CLI-relative paths, including a relative BARN_HOME, are interpreted from the current working directory. Use an absolute BARN_HOME to reach the same deployment from different directories. Barn still rejects / and the user’s home directory as data roots and checks the ownership and structure of its managed state. An owned ~/.ssh directory may be reached through a directory symlink; a linked ~/.ssh/config is still left for manual Include integration.

Shared folders and mount paths

Linux guests use QEMU Virtio-9p, now supported on macOS hosts as well as Linux hosts. QEMU and the guest kernel must support 9p. Native macOS guests use VirtioFS. In 0.9.3, both barn mac up and barn mac configure accept --share.

  • Linux share sources use the invoking user’s actual filesystem permissions. A directory may belong to another user, overlap another source, or be writable by multiple guests. Coordinate concurrent writes as you would between host processes.
  • Source paths support spaces, Unicode, and commas. Linux guest mount paths are normalized and escaped for shell commands and fstab, including spaces, Unicode, and shell punctuation.
  • Mac share names support spaces and Unicode: valid UTF-8, 1–255 bytes, excluding ., .., /, and ASCII control characters. Share sources may be directory symlinks.
  • The eight-share limit is removed. Backend device and host resource limits still apply. Linux sources must not overlap BARN_HOME, and mount targets must not overlap each other, system directories, data-disk mounts, or the guest SSH directory.

See Storage and Access for Linux shares and Mac Commands for native macOS shares. Barn never changes host ownership to make a share writable.

Apply only the selected node changes

Explicit selections in plan, up, reload, and recreate preserve unselected peers’ applied definitions, even if those peers were edited or omitted in the current inventory. Uncreated, unselected nodes do not require image resolution. This allows a multi-node edit to be applied in batches:

barn plan node-1 -f barn.yml
barn recreate node-1 -f barn.yml
barn plan node-2 -f barn.yml

The entire inventory must still parse correctly. Conflicts with applied addresses, aliases, control-node roles, or shared deployment settings are checked before stopping or deleting nodes. Omitting selectors evaluates the whole inventory; removing a YAML entry never deletes its VM. See Daily Operations.

Generated template image selection

barn init [template] --image <reference> writes an explicit vm_image under all.vars for every generated node. barn setup [template] --image <reference> uses the same behavior while preparing a generated template. References may be aliases, channels, or version selectors; the flag does not download an image. Existing inventories selected with -f or discovered automatically are never rewritten by this option.

Images and development limits

AreaNew behavior
Linux node countNo separate 20-node ceiling; nodes need distinct usable addresses in the deployment’s /24 and sufficient host resources
External inventory hostsvm_skip: true entries may use hostnames or IPv6 keys; managed VMs still use IPv4, and at least one managed node is required
Linux capacity stringsCase-insensitive units; K/M/G/T and KiB/MiB/GiB/TiB are binary, while KB/MB/GB/TB remain decimal
Provisioning--parallel accepts positive integers and uses at most the selected node count; --timeout accepts any positive duration, without the old four-worker or 24-hour ceilings
Image sizeNo 8 GiB artifact ceiling for local imports or catalog artifacts with declared sizes; downloads without a declared size retain the legacy 8 GiB bound
Image importsArbitrary source filenames; new cache entries use local/<sha256>.qcow2, so same-name files with different contents coexist and identical contents reuse the cache
Local aliasesNo 256-alias ceiling; updates exceeding the 1 MiB registry metadata limit fail before writing. Reimporting an existing alias preserves its old cache path
Local repositoriesRelative or linked roots and shared writable directories work; repo.yaml may be a symlink to a regular file
Mac logsAny positive --lines count; requested lines are no longer silently clipped at 1 MiB or 10,000 lines
Fallback portsTry preferred + n × 10000 through port 65535, rather than stopping after five candidates

Provisioning still defaults to one worker and a one-hour deadline, with 1 MiB of captured stdout and stderr per node. These user-facing limits are separate from the internal VM startup scheduler. Image digests, declared sizes, qcow2 structure, retained-disk compatibility, and process identity are still verified. The contributor image pipeline retains its own recipe bounds.

3.8 - Barn 1.1.0 Local Acceptance

Upgrade an Apple Silicon host in place, rebuild Linux and macOS labs, and record reviewable acceptance runs.

This run starts with the installed Barn 1.0.0, installs the public 1.1.0 Homebrew formula, checks upgrade and everyday workflows, then rebuilds the test environment. The script was written before execution. This run has ended: core checks passed, one recovery gap was found, and clipboard/privileged-host checks remain incomplete. The owner authorized deletion of existing local Barn VMs.

Environment and evidence

  • Host: macOS 27.0.1, Apple Silicon, 18 logical CPUs, 128 GiB RAM; QEMU 11.1.3.
  • Initial state: eight running Linux VMs and one running macOS VM named mac1; the normal executable is /opt/homebrew/bin/barn.
  • Upgrade target: public tag v1.1.0, commit b2cc8da8983e710255d504bf26bf5d7b3f182790.
  • Recordings, raw output, assertions, and executable scripts live in a separate acceptance directory outside Git. Each stage produces an asciicast v2 recording with original timing and a viewing copy with shortened waits.
  • Linux checks use the actual user’s ~/.barn. Detailed native Mac checks reuse tests/mac-live-acceptance.py with a dedicated test root and an APFS clone of the prepared base; final checks cover the normal user path.
  • Terminal recordings capture output without keyboard input, passwords, or private SSH keys. Desktop checks use native application controls; the screenshot is in the acceptance chat. Clipboard status is recorded below.

Execution order

StageOperationsPass condition
U01 Upgrade baselineRecord the old version, node identities, public SSH fingerprints, and data sentinels; stop Linux and Mac VMsReviewable baseline; every target stops cleanly
U02 Local installationbrew upgrade pgsty/infra/barn; check version, helper, signatures, notarization, and brew testNormal PATH resolves to public 1.1.0; CLI, helper, and App match
U03 Upgrade recoveryStart existing VMs and compare identities, data, and SSH; then remove old VMsUpgrade preserves identities and data; explicit disposal succeeds
L01 First runRun barn up from an empty directory; check generated inventory, confirmation, progress, and SSHDefault native Ubuntu 24.04 guest becomes ready
L02 Inventory and catalogFour templates; valid/invalid YAML; -I/-A and aliases; both signed official repositories; metadata and cacheValid input resolves consistently; failures have correct classification and exit codes; overrides leave inventory unchanged
L03 Two nodes and storageUbuntu/Debian pair; persistent ext4, temporary data, XFS, space/Unicode paths, read-only and writable 9p sharesFilesystem types, permissions, and bidirectional reads/writes match the inventory
L04 Network and accessFixed IPs, control-node SSH to its peer, DNS/HTTPS, SSH config, exec argument boundaries and remote exit codesCorrect addresses, targets, output streams, and exits
L05 LifecycleRepeated up, selected stop/start/restart, CPU/memory increase/decrease, reload, selected recreationIdempotent calls retain PIDs; resources change in the guest; peers and persistent data remain intact
L06 Failures and deletionOmitted nodes, missing share paths, interrupted guest process recovery, provision success/failure/timeout, purge cancellationNo implicit deletion; actionable failures; retries recover; cancellation preserves state
L07 RetentionRecreate, selected and whole destroy, create again, purgeRoot/temporary data resets; persistent data follows each command’s retention rules
L08 Image matrixEight supported arm64 image families and Debian amd64 under TCGSSH, architecture, OS identity, and data disk work; el8 arm64 uses expected TCG
M01 Multiple Macs and identityAutomated two-VM checks, independent identities and disks, immutable shared baseIdentities differ; cloning and lifecycle operations preserve the base
M02 Mac networks and sharesSeparate subnets, host access, guest isolation, DNS/HTTPS, VirtioFS, remote argumentsNetwork and sharing behavior matches the reference
M03 Mac lifecycleStop/start, resource configuration, third-running-VM limit, recreate identity rotation, selected destructionIdentity retention/rotation matches the operation; the peer remains intact
M04 Desktop and clipboardOpen desktop, verify login, copy text both ways, close the window, check SSHUsable desktop; exact text transfer; window closure keeps the VM running
F01 Final stateRemove dedicated test VMs; check normal installation, state, diagnostics, and SSH config; index recordingsNo leftover test processes; every result has output or visual evidence

Assertions and retries

Every command records arguments, exit status, duration, and raw output. Failed assertions preserve the environment. Script corrections create separate retry records; product defects are recorded independently. Failed footage remains available. Only viewing copies shorten waits.

The existing host network is checked and reused first. Operations requiring host sudo inspect actual authorization and the execution plan; unavailable checks are marked blocked. Apple OS image updates, physical Intel Macs, and Linux KVM are separate environment coverage.

Results and playback

This run ended at 11:08 on 2026-11-09 (Asia/Shanghai). The normal PATH resolves to public Barn 1.1.0. Upgrade recovery passed for the original eight Linux VMs and one Mac VM before their authorized deletion. All test VMs, the dedicated Mac data root, and the additional 120 GiB base were removed; the original default macOS base remains.

Stage results

AreaResult and evidence
Homebrew installation and upgradePassed; matching CLI/native components, signatures, notarization, and brew test; existing VM identities and persistent-path data survived
CLI, inventory, and catalogsPassed; first run, four templates, architecture aliases, invalid inputs, both signed official sources, local catalog build/verification/import/pruning
Linux pair and lifecyclePassed; fixed IPs, control-node SSH, DNS/HTTPS, arguments/exits, ext4/XFS, read-only/writable 9p, resource changes, recreation, persistent disk reattachment
Failures and recoveryMissing shares, provision failure/timeout, cancelled purge, and process interruption after disk sync passed; immediate power-loss readiness issue below
Native Mac automated suiteAll 15 phases passed; separate identities/disks/networks, unchanged base, resource settings, running-VM limit, recreation, selected destruction
Normal Mac data pathPassed; complete installation of a new 120 GiB base from the existing IPSW, read-only/writable VirtioFS, SSH Include, original default base retention, extra-cache pruning
Interactive terminalsLinux and Mac passed; real guest TTY allocation and interactive shell exit 17 propagated; all three Linux log sources parsed as JSON
DesktopLogged-in Finder desktop visually confirmed; closing the window kept the same VM process and SSH available; bidirectional clipboard remains unverified
Source checksmake check and make mac-native-test passed on the release commit
Final stateZero Linux or Mac VMs and no remaining test VM processes; barn doctor, barn mac doctor, and network status healthy

Deleting the control node promotes a remaining node. After updating admin_ip in the inventory as instructed, creating the former node again reattached its retained disk and preserved the peer’s PID and data. With the old inventory requesting a control-role reversal, up correctly refused implicit recreation.

Image matrix

All nine configurations passed image acquisition, boot, SSH, OS/architecture checks, data writes, stop/start, and cleanup. -I/-A left the inventory file unchanged. EL7/arm64 returned usage / 2 because the catalog has no matching artifact. EL7/amd64 on this host returned capability / 3 without creating a deployment.

ImageGuest architectureAcceleratorResult
u22@20261020.0.1arm64hvfPassed
u24@20261017.0.1arm64hvfPassed
u26@20261016.0.1arm64hvfPassed
d12@20261026.2643.1arm64hvfPassed
d13@20261103.2651.1arm64hvfPassed
el8@8.10.20240528.3arm64tcg,thread=multiPassed
el9@9.8.20260525.2arm64hvfPassed
el10@10.2.20260525.0arm64hvfPassed
d13@20261103.2651.1amd64tcg,thread=singlePassed

Readiness marker after forced termination

Immediately after successful recreation of an Ubuntu 24.04 arm64/HVF node, its verified QEMU process was forcibly terminated. The next up booted the guest, but both /var/lib/barn/ready.json and error.json were absent. SSH and persistent data worked and cloud-init had finished; up timed out after 180 seconds with exit 5. This observed recovery gap is preserved in 03-linux-lifecycle-r3 and 03-power-loss-investigation.

The following recovery restored readiness while preserving the running VM PID, its peer, and persistent data:

barn exec meta -- sudo -n /usr/local/libexec/barn-finalize
barn up meta -f barn.yml

In a second trial, the guest ran sudo sync before the process was terminated, again after checking its command line and QMP UUID. up recovered automatically. The immediate-interruption behavior was observed once under the stated conditions; persistence timing and other images need further investigation. Relevant 1.1.0 code is the readiness probe and guest-setup retry entry.

Checks not completed

  • Bidirectional clipboard: native UI automation did not reliably inject the host system clipboard, and the browser tool has an isolated clipboard. Manual host input had not arrived when this run ended, so this remains unverified.
  • Privileged host changes: sudo -n required a password, including access to root-owned network planning state. Existing network reuse, privilege-error classification, and read-only hosts plans were checked; network reinstall/uninstall and /etc/hosts writes were not executed.
  • This host is Apple Silicon. Physical Intel Macs, Linux/KVM, and Apple OS image updates remain separate environment coverage.

Local evidence

Evidence lives at ~/barn-acceptance/1.1.0-20261109-101029/. Open player/index.html for offline playback of 23 asciicasts: approximately 58.9 minutes of original timing or 12.1 minutes in the viewing copies. Viewing copies change timestamps only; output bytes and SHA-256 are checked per recording. Terminal recordings do not contain desktop frames; the desktop screenshot is in the acceptance chat.

evidence/plan-before-execution.md and .zh.md preserve the original plan. Stage directories contain script snapshots, commands, exit codes, and raw output; findings.json records the recovery gap and incomplete checks. Initial footage and retries remain for script corrections involving Homebrew prompts, SSH aliases, create/recreate plan categories, control-role promotion, TCG parameters, and error classification. Full recordings stay local; this site contains the acceptance account.