This is the multi-page printable view of this section.
Barn documentation
- 1: Guides
- 2: Reference
- 2.1: Command Reference
- 2.1.1: Preparation and Utilities
- 2.1.2: Linux Lifecycle
- 2.1.3: Guest Access and Hosts
- 2.1.4: Guest Time Synchronization
- 2.1.5: Image Commands
- 2.1.6: Repository Commands
- 2.1.7: Host Network Commands
- 2.1.8: macOS Commands
- 2.2: Configuration
- 2.3: CLI Contracts
- 2.4: Mac Runtime Reference
- 2.5: Images
- 2.6: Self-hosted repositories and official signatures
- 2.7: Image Pipeline
- 2.1: Command Reference
- 3: Project
- 3.1: Platforms and Limits
- 3.2: Design
- 3.3: Security and Trust
- 3.4: Contributing
- 3.5: Shipping the Mac Component
- 3.6: Validation History
- 3.7: Barn 0.9.3 Changes
- 3.8: Barn 1.1.0 Local Acceptance
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
qcow2images. - 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 upboots them with QEMU and reads each guest’s readiness marker over SSH. - macOS VMs on Apple Silicon.
barn mac upcreates 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 planshows whatbarn upwill 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 explicitdestroy,purgeorrecreate. - 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 plancomparesbarn.ymlwith what is running;barn upcreates missing nodes and starts stopped ones. Changes that would replace a disk wait for an explicitbarn 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_vmneton macOS,barn0on 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/hostscan requiresudo. - 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 underBARN_HOME(default~/.barn), sobarn statusandbarn sshwork 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
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.appyourself to try unreleased changes. - Uninstall — Remove VMs, cached images, the host network, and Barn itself.
1.1 - Download and Install Barn
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:
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:
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
| Guest | Host | Needs |
|---|---|---|
| Linux | macOS on Apple Silicon or Intel | QEMU 8.2.1 or later (HVF acceleration) |
| Linux | Linux on amd64 or arm64 | QEMU 6.2 or later, a usable /dev/kvm, and NetworkManager or systemd-networkd |
| macOS 27 | Apple Silicon running macOS 27 or later, with a logged-in desktop session | Barn.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 OS | Architecture | Archive | Debian / Ubuntu | RHEL / Fedora |
|---|---|---|---|---|
| macOS | Apple Silicon (arm64) | tar.gz | — | — |
| macOS | Intel (amd64) | tar.gz | — | — |
| Linux | x86-64 (amd64) | tar.gz | DEB | RPM |
| Linux | ARM64 (arm64) | tar.gz | DEB | RPM |
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.
| File | What it is | Shipped in |
|---|---|---|
barn | The CLI for Linux labs and macOS VMs | Every archive and package |
barn-hosts-helper | Companion that edits /etc/hosts for barn hosts install | Every archive and package, paired with its CLI |
Barn.app | Native runner and desktop window for macOS guests | The 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:
Manual archives
Download barn_1.5.0_<os>_<arch>.tar.gz and checksums.txt, and verify the digest before extracting:
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:
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 from | What changed | To keep the old behavior |
|---|---|---|
| 1.4.0 to 1.5.0 | New 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.x | vm_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.x | New nodes default to 1 vCPU / 2 GiB instead of 2 vCPU / 4 GiB; existing VMs keep their size until you change it | Set vm_cpu: 2 and vm_mem: 4GiB |
Upgrading Barn never changes the OS inside existing VMs. Guest images update separately:
| To update | Run | Effect on existing VMs |
|---|---|---|
| Barn itself | brew upgrade, install.sh, or a newer package | None; disks and state are kept |
| The Linux image catalog | barn update (or barn update --mirror) | None; new and recreated nodes use the newer images |
| Cached Linux base images | Preview with barn image update --dry-run, then run barn image update | Existing nodes keep their backing images |
| The macOS base image | barn mac image update | None; 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
You will boot a Debian 13 VM, log in to it, then grow it into a four-node lab by editing one YAML file. Every command runs on your host as your normal user. For macOS guests, see macOS VMs.
Before you start
- Install Barn.
- Keep about 2 GiB of free memory per VM; each node defaults to 1 vCPU and 2 GiB.
- Use an interactive terminal. The first run prepares the host and asks once before changing anything;
sudomay then ask for your password. For CI and other unattended runs, see Automation. - In mainland China, add
--mirrorto the firstbarn upto download images fromrepo.pigsty.cc.
Start a VM
In 1.5.0, barn up selects Debian 13 for a new lab. With Barn 1.4.0, use barn up -I d13 on the first run to follow this tutorial.
On a fresh host, barn up first shows what it will set up and asks you to confirm. Only the rows that apply appear: dependencies (QEMU, UEFI firmware, OpenSSH), network (the lab subnet), config (the one-node barn.yml it writes here), and sudo (which of those steps need root). On a host that already has QEMU:
Barn then downloads and verifies the Debian image, boots the VM, and waits until SSH answers:
If 10.10.10.0/24 is already routed on your machine, Barn picks a free private /24 for this first lab instead; barn status shows the address it chose.
If barn up stops with an error, run barn doctor to check the host and barn logs meta to read the guest console, fix what they report, and run barn up again. It continues from where it stopped and leaves healthy VMs running. Troubleshooting covers the common cases.
Log in and look around
You are now user dba on meta, with key-based SSH and passwordless sudo. barn up also installed SSH aliases, so plain ssh meta works from any terminal. Type exit to return to the host.
From the host, list the lab and run commands inside a guest. Everything after -- runs in the VM:
The image version in the status output depends on your active catalog.
| What you just created | Value |
|---|---|
| Node and address | meta at 10.10.10.10 |
| Image | Debian 13 (d13), same CPU architecture as the host |
| CPU and memory | 1 vCPU, 2 GiB |
| Disks | 64 GiB root disk, 128 GiB data disk mounted at /data |
Both disks are thin-provisioned, so they take host space only as the guest writes data. Treat /data as test storage, not a home for files you care about: if barn up finds its filesystem corrupted while recovering a node, it reformats it. Storage and Access shows what each command keeps.
The lab’s state lives in ~/.barn, not in ~/barn-lab, so barn status, barn ssh, and barn stop work from any directory. Each user has one Linux lab at a time; barn up in another directory without an inventory resumes it rather than starting a second one (why).
Grow it into a four-node lab
Open ~/barn-lab/barn.yml, which the first run wrote, and add three hosts under nodes. Use addresses in the same /24 as meta:
Preview the change, then apply it:
barn plan reports create: node-1, node-2, node-3, and barn up creates the three VMs without restarting meta. All four nodes now reach each other at these addresses, which is what a database cluster or an Ansible playbook expects. At the default size, the lab uses 8 GiB of guest memory.
Every later change follows the same loop: edit barn.yml, run barn plan, then apply. The command that applies it depends on what changed, because barn up never replaces an existing VM’s disks:
Change in barn.yml | Apply with | Result |
|---|---|---|
| Add a node | barn up | Creates the new VM |
| CPU or memory | barn resize <node> | Same VM, same disks, new size |
| Image or disk layout | barn recreate <node> | New root and non-persistent data disks; persistent data disks are kept |
| Remove a node | barn destroy <node> | Deletes the VM; until then it stays on disk |
Pick the image, size, or subnet
The defaults suit a first run. To start from something else, generate barn.yml yourself in an empty directory before the first barn up:
| To get | Run |
|---|---|
| Two, three, or four nodes | barn init dual -I d13, barn init trio -I d13, or barn init full -I d13 |
| Another OS for every node | barn init -I el9 — see Images for the names |
| Another subnet | barn init -c 10.20.30.0/24 -I d13 |
| amd64 guests on an Apple Silicon Mac | barn init -A amd64 -I d13 — emulated, so slower |
The options combine, for example barn init full -I el9. barn init writes the result to barn.yml; edit it for anything else, such as the size of every node:
Check the file before booting anything:
validate and plan need neither QEMU nor the host network, so you can check an inventory on any machine. Linux Configuration lists every variable, and image and architecture settings explains how -I and -A interact with the file.
Stop, start, and clean up
barn destroy deletes the VMs with their root disks and non-persistent data disks, the deployment state, and the SSH aliases it installed. It keeps persistent data disks, the deployment’s SSH keys, downloaded images, and the host network, so running barn up in ~/barn-lab later rebuilds the lab from barn.yml without downloading again. To remove everything, see Uninstall.
Next steps
- Daily Operations — Restart nodes, read logs, and apply inventory changes safely.
- Storage and Access — Add persistent disks, copy files, and reach services in the guest.
- Images — Run Ubuntu, Rocky Linux, other Debian releases, or your own
qcow2. - Automation — Drive Barn from scripts, CI, or Pigsty.
1.3 - macOS Virtual Machines
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
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
On a Mac with no prepared base, Barn 1.4.0 selects macOS 27.2.1 (26B131) and asks before downloading it:
After you confirm, Barn:
- Downloads the restore image from Apple (
updates.cdn-apple.com), resuming any partial transfer and checking Apple’s published SHA-256. - Installs macOS once into an unbooted base image. The install uses one of the two VM slots while it runs.
- Clones
mac1from the base with APFS copy-on-write, boots it, creates your account, and waits until SSH and passwordlesssudowork.
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:
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
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:
The full schema is in the Mac reference.
Desktop
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 item | Action |
|---|---|
| Machine → Share Clipboard | Toggle 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 Background | Hide 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:
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>:
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:
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:
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.
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 --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:
Stop the VM before changing CPUs, memory, shared folders, or subnet (clipboard sharing can change while it runs):
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.
| Operation | Guest disk and installed apps | Hardware settings, IP, and account |
|---|---|---|
stop / start, restart, repeated up | Kept | Kept |
configure | Kept | Updated as requested |
recreate | Replaced with a fresh macOS clone | Kept; new login password and SSH keys |
destroy | Deleted | Deleted; the base image stays |
macOS versions and disk space
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:
Clean up
Destroying the last Mac VM removes its ~/.ssh/config entries and keeps the default base image. To remove all Mac VM state:
- Destroy every Mac VM (
barn mac destroy ...) and runbarn mac ssh-config --remove. - Delete
$BARN_HOME/mac(default~/.barn/mac). - Optionally delete
~/Library/Preferences/com.pgsty.barn.plist(io.pgsty.barn.mac-runner.plistin0.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.
| Symptom | Fix |
|---|---|
dev and mac1 are running; macOS allows 2 macOS virtual machines at a time | Run the suggested barn mac stop NAME, or quit another tool’s macOS VM. See Requirements. |
preparing macOS needs … GiB free on this volume | Free space, or run barn mac image prune --installers --yes. |
… has a 200 GiB disk, but macOS … is prepared only at 100 GiB | Run the printed barn mac setup --disk 200G, then barn mac recreate NAME --update. |
network … overlaps route … on start | A 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 host | Allow 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_protocol | The 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 session | Run 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
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
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
| Command | Reads the inventory | What it does |
|---|---|---|
stop | No | Stops running nodes |
start | No | Boots stopped nodes, re-checks running ones, and updates SSH aliases if a loopback port had to move |
restart | No | Stops and boots nodes with their applied definitions |
reload | Yes | Validates 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:
| Plan reports | Meaning | Apply with |
|---|---|---|
create | Node is in the inventory but not provisioned yet | barn up |
resize | Node CPU or memory changed | barn resize <node> |
recreate | Node image, disks, shares, or other VM definition changed | barn recreate <node> |
missing | Provisioned node is no longer in the inventory | Restore 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:
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:
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, sossh-config,hosts,exec, andprovisionkeep working. Setadmin_ipin the inventory to the new control node (and delete the old entry unless you wantupto recreate it), then runbarn upto install its control SSH access.barn destroyremoves 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, sobarn uprebuilds the lab from the inventory.barn destroy --delete-persistentalso deletes persistent disks;--purgealso deletes keys and deployment state. Both apply to the whole deployment only.barn purgedeletes the whole lab, persistent disks, keys, and deployment state immediately, keeping the image cache and host network.barn purge --askshows the nodes and scope first and acceptsy/yes;n/no, an empty line, or EOF cancels.purgeaccepts 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:
To clear cached images, see Image Repositories; to remove Barn completely, see Uninstall.
1.5 - Storage, Files, and Service Access
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:
Create the VM and check the mounts:
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
| Operation | Root and non-persistent data disks | Persistent data disks (persistent: true) |
|---|---|---|
stop then start, restart, or reload | Kept | Kept |
resize, including root growth | Kept | Kept |
Repeated up on a healthy node | Kept | Kept |
recreate | Replaced | Kept and reattached |
destroy (one node or the whole lab) | Deleted | Kept |
destroy --delete-persistent, destroy --purge, or purge | Deleted | Deleted, including disks kept from earlier destroys |
Newly formatted data filesystems are owned by root. To see /data survive a stop and start:
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
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 finds | What it does | Reported in |
|---|---|---|
| A blank disk with no signature | Formats it with fs | nodes[].repairs, unless this is the disk’s first format |
| A healthy ext4 or XFS filesystem | Mounts it unchanged | — |
An ext4 or XFS filesystem that will not mount, where e2fsck -fn or xfs_repair -n reports recognized corruption | Reformats it, erasing its contents | nodes[].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 recognize | Leaves the data alone | nodes[].warnings |
| A missing device, failed probe, busy mount, read-only device, or host I/O error | Leaves the data alone | nodes[].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:
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:
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 --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:
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
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
| Family | Distribution | Short aliases | Notes |
|---|---|---|---|
d13 | Debian 13 | d, debian, trixie | Default for new labs in 1.5.0 |
d12 | Debian 12 | bookworm | |
u24 | Ubuntu 24.04 LTS | noble | |
u26 | Ubuntu 26.04 LTS | u, ubuntu, resolute | |
u22 | Ubuntu 22.04 LTS | jammy | deprecated |
el10 | Rocky Linux 10 | e, el, rocky | |
el9 | Rocky Linux 9 | rocky9 | |
el8 | Rocky Linux 8 | rocky8 | deprecated; arm64 runs under TCG on Apple Silicon |
el7 | CentOS Linux 7.9 | c7, centos7 | deprecated (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:
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:
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
-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:
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:
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:
--name(must start withlocal-),--boot(uefiorbios), and--source-usergo together. Without them, Barn caches the verifiedqcow2by 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 examplebarn 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’svm_archor the command’s-Ato 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:
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 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.
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:
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
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.
barn setup --yesaccepts the host-preparation plan without asking. It needssudothat works without a password prompt (cached credentials or aNOPASSWDrule); what it installs is described inbarn setup.barn upexits 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-levelwarningsas well as each node’swarningsandrepairs.barn execandbarn provisionrun commands and scripts in the guests; see below.barn purgedeletes the deployment in thisBARN_HOME, persistent disks and keys included, without asking. The image cache stays, so the next run does not download again. Usebarn destroy --yesinstead 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:
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:
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:
| Exit | error | Typical cause in automation |
|---|---|---|
2 | usage | Missing inventory on first run, invalid flags, unknown image alias, or destroy/recreate without --yes when stdin is not a terminal |
4 | conflict | Drift 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) |
5 | partial | Some nodes of a multi-node up or provision failed; read nodes[] or results[] before retrying |
7 | integrity | A digest, signature, or identity check failed, including reason: catalog_signature or catalog_equivocation |
A few commands report success differently:
barn doctor --jsonexits0when host compute checks pass, even if aclass: networkcheck reports an error. Readchecks[]andbarn network status --jsonbefore relying on the fixed-IP network.barn sshandbarn execexit with the remote command’s status (255can also mean an OpenSSH transport failure); with--jsonthey returnsuccess,exit_code,stdout, andstderr.barn networkandbarn hostsinstall/uninstallonly print their plan and exit0when--yesis missing and stdin is not a terminal or output is--json/--yaml. Pass--yes, or checkappliedin 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 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):
Run it on selected nodes, or on every node when you name none; all targets must be running:
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 limit | Behavior |
|---|---|
--parallel | Positive integer; default 1 (serial). Workers never exceed the number of selected nodes |
--timeout | Deadline for the whole operation; default 1h, any positive duration |
--sudo | Runs the script through non-interactive sudo -n |
| Output | Up to 1 MiB each of stdout and stderr per node; stdout_truncated / stderr_truncated mark a cut |
| Exit code | 5 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:
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
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:
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:
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 usessudo; whensudoneeds a password, the agent gives you the command to run; - downloads a macOS restore image of about 24 GiB;
- runs
destroy,recreate, orpurge, 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
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 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:
Fix:
Download fails: the installer downloads from GitHub Releases (
--mirrorchanges only the guest image repository). If you need a proxy, exportHTTPS_PROXYorALL_PROXYin 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 toPATHand run the check again:With two installs (for example
~/.local/binand Homebrew), update the onePATHselects; see Upgrade Barn.Keep
barnandbarn-hosts-helperfrom 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:
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:
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:
Fix: Barn never writes through an output-file symlink. Pass the link’s target instead:
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:
Fix:
- KVM on Linux: enable KVM and give your user read/write access to
/dev/kvm. - QEMU or firmware missing: run
barn setupto install the host packages. - Foreign architecture on Linux:
barn setupinstalls only the host-native emulator. Install the matchingqemu-system-*binary and UEFI firmware before running a guest with a differentvm_arch. Homebrew’sqemuon macOS includes both thearm64andamd64emulators.
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:
Fix:
Stopped but intact: in a terminal,
barn upadds the restart to its host plan and asks once. Without a terminal, runbarn setup --yes.partialorinvalid: 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: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 setupfixes 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 commandbarn network statusprints.
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:
Fix:
- Debian and Ubuntu: the helper should be
root:<group> 4750, with a group your user belongs to.barn setupsets this throughdpkg-statoverride, andbarn network uninstallrestores the original. If another user installed the Barn network, uninstall it as that user, then runbarn setupas yourself. - RPM-family hosts: the packaged mode is
4755and 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:
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.
| Warning | Fix |
|---|---|
| Data disk unavailable | Fix 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-only | Check write permissions on the host and in the guest, then run barn up. |
| Guest hosts or control-node SSH incomplete | Run barn up to rewrite the managed files in the guest. |
| Private interface unavailable | Check 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:
Fix:
| What you see | Fix |
|---|---|
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 missing | Restore 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 warning | The 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 flags | Put -- 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:
Fix:
recreate: the node’s definition changed in a way that needs a new root disk. Afterbarn 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 runbarn recreate <node>(--yesin scripts).missing: a node with a VM was removed from the inventory. Restore its entry, or delete the VM withbarn destroy <node>. While any node is missing,barn recreatewithout 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:
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:
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 state | What barn status does / what to run |
|---|---|
| Host rebooted, or an unrelated process reused the QEMU PID | Marks the VM stopped; run barn start |
barn stop was interrupted while QEMU kept running | Restores running; run barn stop again if you still want it stopped |
Online barn resize was interrupted after changing the live guest | Reports resize_incomplete; run barn resize <node> again or barn restart <node> |
First barn up failed during preparation | Fix the inventory and run barn up -f barn.yml; Barn rolls back the journaled unfinished artifacts |
barn destroy was interrupted | Run 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 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
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.
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 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
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
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
| Remove | Run | What is kept |
|---|---|---|
| Nothing yet, just stop the VMs | barn stop; barn mac stop --all | Everything, disks included |
| One Linux node | barn destroy <node> | The other nodes, that node’s persistent disks, keys, images, host network |
| The Linux lab | barn destroy | Persistent disks, deployment keys, cached images, host network |
| The Linux lab, its persistent disks, and keys | barn purge (deletes immediately; --ask to confirm first) | Cached images, host network |
| Named Mac VMs | barn mac destroy <name...> (asks you to confirm) | Other Mac VMs, cached macOS images |
Barn’s SSH, /etc/hosts, and clock-sync integrations | Step 2 | Your own ~/.ssh/config and /etc/hosts entries |
| Cached images | barn image prune --yes; barn mac image prune --installers --yes | Images a VM still uses, and the default macOS base |
| The Linux host network | barn network uninstall --yes (after all Linux VMs are gone) | — |
| Barn itself | Step 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
Destroy Linux and Mac virtual machines
Discard the whole Linux lab, persistent disks and deployment keys included:
It deletes immediately. To review the VM list and scope first, run
barn purge --askand answery/yesorn/no;purgeaccepts no--yes,-y, or--force. Then list and destroy any macOS VMs by name:Remove SSH,
/etc/hosts, and timer integrationsDestroying the whole Linux deployment already removes the default
~/.ssh/barn_configintegration. Remove anything else you installed: a custom-named SSH fragment,/etc/hostsentries, Mac SSH aliases, or the clock-sync user timer:Each command removes only the block Barn wrote.
Prune cached images
Preview, then delete, cached Linux and macOS images:
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.
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 inchecks.networkd.Uninstall the Barn application and remaining state
If a package manager installed Barn, remove the package:
HomebrewDebian / UbuntuRHEL / Fedora- User-scoped
install.sh: removebarn,barn-hosts-helper,.barn-current,.barn-releases/, and.barn-install.lockfrom~/.local/bin, and thePATHline from your shell rc file. - Manual archive or source build: with all Mac guests stopped, remove the extracted release directory,
bin/mac, or any copiedBarn.app(Barn Mac.appin0.9.0), plus~/Library/Preferences/com.pgsty.barn.plist(io.pgsty.barn.mac-runner.plistin0.9.0). - Manually installed hosts helper: if you installed
/opt/barn/libexec/barn-hosts-helperby hand and no other user on the host uses Barn, remove it afterbarn hosts uninstall --yes.
- User-scoped
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
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 macmachine 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
qcow2images.
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
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
| Label | Availability | Behavior |
|---|---|---|
| 1.1.0 | Options available across 1.1.0–1.5.0 | 1.1.0 used 2 vCPUs / 4 GiB by default and accepted CPU/memory resize through the inventory |
| 1.2.0 | Added in 1.2.0 | Resource 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.0 | Added in 1.3.0 | barn 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.0 | Added in 1.4.0 | barn image update, catalog signing key rotation, Debian 13.8 on both architectures, and immediate power-off during Linux purge |
| 1.5.0 | Changed in 1.5.0 | New 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
| Task | Commands and detailed reference |
|---|---|
| Prepare | setup, init, validate, doctor |
| Plan and create | plan, up |
| Start and stop | start, stop, restart, reload |
| Change and inspect | resize, recreate, status |
| Delete | destroy, purge |
| Access Linux guests | ssh, exec, logs, provision, ssh-config |
| Publish host names | hosts install, hosts uninstall |
| Synchronize clocks | time status, sync, auto |
| Refresh catalog | update, image sync, image reset |
| Manage Linux images | image list, info, pull, update (1.4.0), import, prune |
| Maintain a repository | repo scan, build, verify |
| Host network | network status, install, uninstall |
| Native macOS VMs | mac ls, up, start, stop, restart, configure, recreate, destroy |
| Mac access | mac open, ssh, exec, password, ssh-config, logs |
| Mac preparation | mac setup, doctor, image ls, image update, image prune |
| CLI utilities | version, completion, help |
Global options
| Option | Meaning |
|---|---|
-h, --help | Human-readable help for the selected command; exits 0 |
--json | Structured JSON on stdout; progress and diagnostics stay on stderr |
--yaml | Structured YAML on stdout; mutually exclusive with --json |
-v, --verbose | Bounded diagnostics on stderr |
--version | Root-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
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
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
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.
Aliases: s.
What setup changes
Setup skips steps that are already satisfied and prints the whole plan before the first change:
| Step | What it does | Root |
|---|---|---|
dependencies | Installs missing QEMU, qemu-img, UEFI firmware, and OpenSSH: brew install qemu on macOS (Homebrew required), apt-get or dnf on Linux | Linux only |
capabilities | Runs the host checks of barn doctor | No |
network | Installs 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 Linux | Yes |
verify | Re-checks the installed network | No |
config | Writes the generated inventory, or uses the existing one | No |
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.
--yesskips that question and is required without a terminal, where setup otherwise exits2. It cannot answersudo: without a terminal,sudomust work without a password, or setup exits3with reasonsudo_unavailable(troubleshooting).--dry-runprints the plan and changes nothing; itsnext:line is the command that applies it. It cannot be combined with--yes.barn --json setupreportsready,blocked,steps[],dependencies(withmissing[]and the exact package-managercommands[]),network, andnext/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
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-c, --cidr string | generated template network as a canonical RFC1918 IPv4 /24 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-d, --dry-run | show the resolved setup plan without changing anything | 1.1.0 |
-f, --file string | Inventory to prepare; mutually exclusive with a template argument | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-m, --mode string | macOS fixed-IP network backend: host or shared (default “host”) | 1.1.0 |
-r, --repo string | image repository URL or local directory, also used for socket_vmnet; overrides --mirror and $BARN_REPO | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
-y, --yes | accept the one-time setup plan (required without a terminal) | 1.1.0 |
barn init
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).
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-c, --cidr string | rebase the generated template to a canonical RFC1918 IPv4 /24 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
--force | Overwrite the destination inventory; default preserves existing files | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
-o, --output string | write to this path instead of ./barn.yml; ‘-’ writes to stdout | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
barn validate
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | Inventory to validate; otherwise use local discovery, with no applied-state fallback | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
-r, --repo string | image repository whose catalog checks the images; overrides $BARN_REPO | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
barn doctor
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 version
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 completion
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.
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
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 to | Run | What happens to disks |
|---|---|---|
| See what a change would do | plan | Nothing; read-only |
| Create the lab, or bring it back after a stop or reboot | up | Kept |
| Boot, shut down, or reboot existing nodes as they are | start, stop, restart | Kept |
Restart nodes and re-apply the inventory (stop, then up) | reload | Kept; nodes new in the inventory are created |
| Change CPU or memory, or grow the root disk | resize | Kept |
| Change image, architecture, data disks, network, or shares | recreate | Root and non-persistent data disks replaced |
| Remove some nodes, or the whole lab but keep persistent data | destroy | Deleted, except persistent data disks |
| Start over from nothing | purge | Everything 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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | desired inventory; defaults to the discovered inventory, then the applied state | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
-r, --repo string | image repository URL or directory; overrides $BARN_REPO | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | desired inventory; defaults to the discovered inventory, then the applied state | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-n, --no-wait | return once QEMU is running, without waiting for the guest to boot | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
-r, --repo string | image repository URL or directory; overrides --mirror and $BARN_REPO | 1.1.0 |
--rollback | remove safe artifacts from nodes that fail to prepare | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
barn start
Use start to boot nodes that already exist, from any directory: it reads applied state, not the inventory, and never creates nodes.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --no-wait | return once QEMU is running, without waiting for the guest to boot | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
barn stop
Use stop to shut nodes down and free host CPU and memory; root disks, data disks, keys, and deployment state all stay.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
barn restart
Use restart to reboot nodes exactly as they were created. Inventory edits are ignored; use reload to pick them up.
restart stops and starts existing nodes from applied state, then waits for SSH and checks guest clocks unless --no-wait is set.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --no-wait | return once QEMU is running, without waiting for the guest to boot | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | desired inventory; defaults to the discovered inventory, then the applied state | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-n, --no-wait | return once QEMU is running, without waiting for the guest to boot | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
-r, --repo string | image repository URL or directory; overrides --mirror and $BARN_REPO | 1.1.0 |
--rollback | remove safe artifacts from nodes that fail to prepare | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | desired inventory; defaults to the discovered inventory, then the applied state | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
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.
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | override deployment vm_arch: native, amd64, or arm64; environment overrides require 1.2.0 | 1.1.0 |
-C, --cpu string | Base vCPUs before scale, integer 1–256; effective CPU count is also limited to 256; overrides BARN_CPU | 1.2.0 |
-D, --disk string | Absolute root capacity, at least the base virtual size; bare integer means GiB; overrides BARN_DISK | 1.2.0 |
-f, --file string | desired inventory; defaults to the discovered inventory, then the applied state | 1.1.0 |
--force | recreate without the interactive confirmation (required without a terminal) | 1.1.0 |
-I, --image string | override vm_image/vm_version for selected nodes; environment overrides require 1.2.0 | 1.1.0 |
-M, --mem string | Base memory before scale, minimum 512 MiB; bare integer means MiB; overrides BARN_MEM | 1.2.0 |
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-n, --no-wait | return once QEMU is running, without waiting for the guest to boot | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
-r, --repo string | image repository URL or directory; overrides --mirror and $BARN_REPO | 1.1.0 |
-S, --scale string | Integer 1–256 multiplying base CPU and memory only; disk does not scale; overrides BARN_SCALE | 1.2.0 |
--yes | same as --force | 1.1.0 |
barn status
Use status to check what is running and how each node is configured, from any directory.
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 destroy
Use destroy to remove nodes you no longer need, or the whole Linux lab while keeping persistent data disks for a later rebuild.
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--delete-persistent | also delete owned persistent data disks | 1.1.0 |
--force | destroy without the interactive confirmation (required without a terminal) | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
--purge | terminal disposal: also delete persistent disks, keys, and deployment state | 1.1.0 |
--yes | same as --force | 1.1.0 |
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.
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--ask | show the deletion scope and ask for y/yes before purging | 1.1.0 |
-p, --parallel int | Node concurrency: omitted = max(1, logical CPUs - 2); 0 = all selected nodes; positive = limit | 1.2.0 |
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
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 meta -- … | barn exec meta -- … | |
|---|---|---|
| Guest receives | One string, parsed by the guest shell, as with plain ssh | The program and its arguments, with no shell |
Pipes, ;, $VAR | Work; quote them so your local shell leaves them alone | Wrap the command in sh -c '…' |
| Spaces, quotes, empty arguments | Re-parsed by the guest shell | Preserved exactly |
| No command | Opens an interactive login shell | Fails: 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 exits2. 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,execalso accepts one quoted string and hands it to the guest shell. - Exit status: Barn exits with the remote command’s status, so
exit 17in the guest makesbarnexit17. Check whether a nonzero code came from the guest before reading it as a Barn error class.
barn ssh
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 exec
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 logs
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.
| Option | Meaning / default | Available in |
|---|---|---|
-f, --follow | continue streaming appended log data | 1.1.0 |
-s, --source string | log source: serial, qemu, or events (default “serial”) | 1.1.0 |
barn provision
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.
| Option | Meaning / default | Available in |
|---|---|---|
-p, --parallel int | Positive concurrency limit; default 1; zero is invalid | 1.1.0 |
-s, --script string | local Bash script to stream to each selected guest | 1.1.0 |
--sudo | run the guest script through sudo -n | 1.1.0 |
-t, --timeout duration | hard deadline for the operation (default 1h0m0s) | 1.1.0 |
barn ssh-config
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.
| Option | Meaning / default | Available in |
|---|---|---|
-i, --install | install the deployment fragment and one Include in ~/.ssh/config | 1.1.0 |
--name string | SSH Host and fragment prefix (default “barn”) | 1.1.0 |
--remove | remove the Include and fragment Barn installed | 1.1.0 |
barn hosts install
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.
| Option | Meaning / default | Available in |
|---|---|---|
-f, --file string | Inventory nodes, aliases and vm_hosts; usable before VM creation | 1.2.0 |
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
barn hosts uninstall
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.
| Option | Meaning / default | Available in |
|---|---|---|
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
Implementation
2.1.4 - Guest Time Synchronization
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
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.
| Command | Option | Default | Meaning | Available in |
|---|---|---|---|---|
time status [node...] | --timeout | 1m | Total deadline, from 1s to 10m | 1.3.0 |
time sync [node...] | --timeout | 1m | Total deadline, from 1s to 10m | 1.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:
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.
| Host | Scheduler | Job files |
|---|---|---|
| macOS | launchd calendar job | ~/Library/LaunchAgents/com.pgsty.barn.time.plist |
| Linux | systemd 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
2.1.5 - Image Commands
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
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.
| Option | Meaning / default | Available in |
|---|---|---|
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-r, --repo string | image repository URL or directory; overrides --mirror and $BARN_REPO | 1.1.0 |
barn image list
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.
| Option | Meaning / default | Available in |
|---|---|---|
-r, --repo string | image repository URL or directory; overrides $BARN_REPO | 1.1.0 |
barn image info
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | artifact architecture (defaults to native): native, amd64 (x86_64, x64), or arm64 (aarch64, a64) | 1.1.0 |
-r, --repo string | image repository URL or directory; overrides $BARN_REPO | 1.1.0 |
barn image pull
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | artifact architecture (defaults to native): native, amd64 (x86_64, x64), or arm64 (aarch64, a64) | 1.1.0 |
--mirror | use the China official repository at repo.pigsty.cc; overridden by --repo | 1.1.0 |
-r, --repo string | image repository URL or directory; overrides --mirror and $BARN_REPO | 1.1.0 |
barn image update
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.
| Option | Effect | Available in |
|---|---|---|
-A, --arch string | Select one architecture, including native, amd64 or arm64 | 1.4.0 |
-d, --dry-run | Verify the candidate catalog and preview downloads and requested cleanup without writing local state | 1.4.0 |
--prune | After successful downloads, remove files eligible under the normal pruning rules | 1.4.0 |
--mirror | Select the China official repository | 1.4.0 |
-r, --repo string | Select a repository URL or directory. Takes precedence over --mirror and BARN_REPO | 1.4.0 |
--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
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.
| Option | Meaning / default | Available in |
|---|---|---|
-A, --arch string | Guest architecture recorded with --name; defaults to native; does not convert the image | 1.1.0 |
-b, --boot string | required with --name: bios or uefi | 1.1.0 |
--name string | Immutable local-* alias; requires --boot and --source-user | 1.1.0 |
-s, --sha256 string | optional expected SHA-256 | 1.1.0 |
-u, --source-user string | required with --name: source image login user | 1.1.0 |
barn image sync
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.
| Option | Meaning / default | Available in |
|---|---|---|
--allow-downgrade | activate a catalog older than the newest revision seen so far | 1.1.0 |
-r, --repo string | Repository whose active catalog is replaced | 1.1.0 |
barn image reset
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.
| Option | Meaning / default | Available in |
|---|---|---|
-r, --repo string | Repository whose active catalog is reset to the embedded catalog | 1.1.0 |
barn image prune
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.
| Option | Meaning / default | Available in |
|---|---|---|
-d, --dry-run | show unreferenced images and stale staging files without deleting | 1.1.0 |
-r, --repo string | image repository URL or directory; overrides $BARN_REPO | 1.1.0 |
-y, --yes | Delete the listed unreferenced files; mutually exclusive with --dry-run | 1.1.0 |
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
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
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
Report the state of every qcow2 file without changing anything or needing qemu-img:
| State | Meaning |
|---|---|
tracked | Selected by filename inference or repo.yaml, and present |
missing | Referenced by repo.yaml but absent from images/ |
untracked | Present in images/ but not referenced by repo.yaml |
unsafe | Not 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 repo build
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 verify
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.
Implementation
The self-hosted repository guide gives a two-command example.
2.1.7 - Host Network Commands
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
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.
| Option | Meaning / default | Available in |
|---|---|---|
-c, --cidr string | Optional expected private /24; otherwise inspect the installed subnet | 1.1.0 |
barn network install
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.
| Option | Meaning / default | Available in |
|---|---|---|
-a, --archive string | macOS: pinned socket_vmnet archive | 1.1.0 |
-c, --cidr string | network: an RFC1918 IPv4 /24 (default “10.10.10.0/24”) | 1.1.0 |
-i, --interface-id string | macOS: persistent vmnet UUID | 1.1.0 |
-m, --mode string | macOS vmnet mode: host or shared (default “host”) | 1.1.0 |
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
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
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.
| Option | Meaning / default | Available in |
|---|---|---|
-y, --yes | apply the displayed privileged plan without confirmation (sudo may still ask for a password) | 1.1.0 |
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. 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 withmac_vm_limit. - Machine names. A command with an optional
[name]uses the only existing machine, ormac1. With several machines and none namedmac1, pass a name.configure,recreate, anddestroyalways need one.startandstoptake several names or--all, not both. - Sizes.
--memoryand--diskare binary even when writtenGB:16G,16GiB, and16GBall mean 16 GiB, and a bare number is bytes. Linux inventoryGBis decimal. - Confirmation.
recreateanddestroyprint what they will delete and ask you to type the command name.--yesor--forceskips the question and is required without a terminal; neither command has a-yshorthand. Commands that download macOS from Apple (up,setup,image update) ask first;-y/--yesskips that question and is required without a terminal. - State. Machines live under
$BARN_HOME/mac, separate from the Linux inventory. These commands ignore the LinuxBARN_IMAGE/BARN_ARCH/BARN_CPU/BARN_MEM/BARN_SCALE/BARN_DISKoverrides.
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.
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 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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--clipboard on|off | on/off, true/false, or yes/no; default on, active while the desktop window is focused | 1.1.0 |
--cpu int | vCPUs, default 4; minimum 2, maximum host logical CPU count | 1.1.0 |
--disk size | Base capacity, minimum 32 GiB; default uses the prepared base, or 100 GiB initially | 1.1.0 |
--ipsw string | install macOS from this restore image instead of downloading from Apple | 1.1.0 |
--memory size | Memory, default 8 GiB; a whole MiB from 4 GiB to host RAM | 1.1.0 |
-n, --no-wait | return once the VM runs; first boot may still be initializing | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
--share [name=]path[:ro] | Repeatable [name=]path[:ro|:rw]; default writable, mounted under /Volumes/My Shared Files | 1.1.0 |
--subnet string | Canonical private /24, or auto; default selects the first free subnet | 1.1.0 |
--user string | Guest administrator; default is the host username, or barn if that name is invalid | 1.1.0 |
-y, --yes | download macOS from Apple without asking (required without a terminal) | 1.1.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--all | start every machine | 1.1.0 |
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
--recovery | boot macOS Recovery and show its desktop | 1.1.0 |
barn mac stop
Use stop to shut machines down cleanly through macOS; disks and settings stay as they are.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--all | stop every machine | 1.1.0 |
--force | Power off immediately instead of requesting shutdown; unsaved guest work is lost | 1.1.0 |
barn mac restart
Use restart to apply settings saved with configure, or to reboot a guest that misbehaves.
It shuts the machine down normally and starts it again. It takes at most one name and has no --all.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
barn mac configure
Use configure to change a machine’s CPUs, memory, shared folders, network, or clipboard setting without touching its disk or account.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--clipboard on|off | on/off, true/false, or yes/no; omitted retains the setting | 1.1.0 |
--cpu int | vCPUs, minimum 2 and maximum host logical CPU count; omitted retains current value | 1.1.0 |
--memory size | Memory, a whole MiB from 4 GiB to host RAM; omitted retains current value | 1.1.0 |
--share [name=]path[:ro] | Add or replace a named share; repeatable, writable by default, optional :ro or :rw | 1.1.0 |
--subnet string | move to this private /24 network, or auto for the first free one | 1.1.0 |
--unshare stringArray | stop sharing the named folder (repeatable) | 1.1.0 |
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.
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--force | skip the confirmation (required without a terminal) | 1.1.0 |
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--update | use the newest prepared macOS base | 1.1.0 |
--yes | Same as --force; no -y shorthand | 1.1.0 |
barn mac destroy
Use destroy to delete machines you no longer need.
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.
Explicit names are required. Run barn mac image prune afterwards to remove bases that no machine uses.
| Option | Meaning / default | Available in |
|---|---|---|
--force | skip the confirmation (required without a terminal) | 1.1.0 |
--yes | Same as --force; no -y shorthand | 1.1.0 |
barn mac open
Use open to see and use the machine’s desktop; it starts a stopped machine first.
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 ssh
Use ssh for an interactive shell in the machine, or to run a shell command line in it.
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 exec
Use exec in scripts: it runs one program with its arguments passed exactly as given and returns the program’s exit status.
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 password
Use password when the guest desktop asks for the login password, at the lock screen or an administrator prompt.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-c, --copy | copy to the clipboard instead of printing | 1.1.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
-i, --install | install the entries as one Include in ~/.ssh/config | 1.1.0 |
--remove | remove the entries Barn installed | 1.1.0 |
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.
--lines/-n must be positive and defaults to 100. Here -n means lines, not no-wait. There is no follow option.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --lines int | number of recent lines (default 100) | 1.1.0 |
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.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--disk size | Base capacity, at least 32 GiB. Defaults to the current base capacity or 100 GiB for the first base | 1.1.0 |
--ipsw string | install macOS from this restore image instead of downloading from Apple | 1.1.0 |
-y, --yes | download macOS from Apple without asking (required without a terminal) | 1.1.0 |
barn mac image ls
Use image ls to see which restore images and bases take up disk space, and which machines use them.
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 update
Use image update to move to Apple’s newest macOS 27 build.
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.
| Option | Meaning / default | Available in |
|---|---|---|
--ipsw string | use this restore image instead of downloading from Apple | 1.1.0 |
-y, --yes | download without asking (required without a terminal) | 1.1.0 |
barn mac image prune
Use image prune to reclaim disk space from bases that no machine uses.
It lists unused bases other than the current default. --installers adds downloaded restore images and partial downloads. Nothing is deleted without --yes.
| Option | Meaning / default | Available in |
|---|---|---|
--installers | include downloaded restore images and partial downloads | 1.1.0 |
-y, --yes | Delete the listed unused images; otherwise only list candidates | 1.1.0 |
barn mac doctor
Run doctor first when something goes wrong, and after installing or upgrading Barn.
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.
Implementation
2.2 - Configuration
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.
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:
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:
- The path given with
-f. barn.yml,barn.yaml,pigsty.yml, thenpigsty.yamlin 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.- The applied specification stored in
BARN_HOME— only forplan,up,reload,recreate, andresize.
| Commands | Desired 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 install | Uses applied node names by default. An explicit -f reads that inventory and its vm_hosts mappings |
start, stop, restart, status, destroy, purge | Operate 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_*, andnode_packages, are ignored and never cause VM drift. - Inheritance: Values inherit
all.vars→ nestedchildren.<group>.vars→ host variables, deepest wins. A host-level list such asvm_disksreplaces 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_ipinall.varsnames the control node. If it is omitted or matches no managed node, Barn picks the first managed node in traversal order (each group’shostsbefore itschildren). Setadmin_ipso reordering groups cannot move the control role. - Login account: All nodes share one login user matching
[a-z_][a-z0-9_-]{0,31}, defaultdba. Withdba, an explicitnode_admin_uidmust be88; with a custom user,node_admin_uidonly has to be an integer and the guest assigns the UID. - Skipped hosts:
vm_skip: truemarks 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 asmissinginplanwithout destroying it. - Strict
vm_*namespace: Unknownvm_*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
| Variable | Default | Meaning |
|---|---|---|
vm_skip | false | Skip virtualization for this physical or external host |
vm_image | d13 (new lab in 1.5.0) | Image family, :channel reference, or image@version selector; see Image and architecture |
vm_version | unset | Newest numeric version matching this prefix, such as 9 or 9.7 |
vm_arch | native | Deployment-wide guest architecture; follows the host unless set to amd64 or arm64 |
vm_cpu | 1 | Base vCPU count; the effective count after scaling must be 1–256 |
vm_mem | 2048 | Base memory: bare integer in MiB, or a size string such as 8GiB (minimum 512MiB) |
vm_scale | 1 | Positive integer multiplying CPU and memory only |
vm_hosts | [] | Extra host /etc/hosts mappings, declared only in all.vars |
vm_disk | 64 | Root 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:
| Settings | Effective CPU | Effective memory |
|---|---|---|
| None | 1 | 2 GiB |
vm_scale: 3 | 3 | 6 GiB |
vm_cpu: 2, vm_scale: 3 | 6 | 6 GiB |
vm_mem: 4GiB, vm_scale: 3 | 3 | 12 GiB |
vm_cpu: 2, vm_mem: 4GiB, vm_scale: 3 | 6 | 12 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 field | CLI | Environment variable | Default |
|---|---|---|---|
vm_image | --image/-I | BARN_IMAGE | d13 (new lab in 1.5.0) |
vm_arch | --arch/-A | BARN_ARCH | native |
vm_cpu | --cpu/-C | BARN_CPU | 1 |
vm_mem | --mem/-M | BARN_MEM | 2048 MiB |
vm_scale | --scale/-S | BARN_SCALE | 1 |
vm_disk | --disk/-D | BARN_DISK | 64 GiB |
Each field resolves per node; the first source that sets it wins:
- CLI flag
- Non-empty environment variable
- Host variable
- Deepest child group
- Parent groups
all.vars- Default
- CPU and memory are always bases, multiplied once by the final scale.
-S 3replaces the scale rather than multiplying it; add-S 1to set exact CPU and memory. - CLI and environment values override host values on the selected nodes. Put common defaults in
all.varswhen 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 2uses 2. Suggested follow-up commands repeat effective environment overrides as explicit flags.
| Command | Overrides | Effect |
|---|---|---|
init, template-generating setup | All six | Written into the new inventory, defaults included; CPU and memory as bases plus scale |
up that generates an inventory interactively | All six | Saved in the generated inventory |
validate, plan, up, reload, recreate | All six | Change this run’s desired specification only; the YAML is not rewritten, so the next run against the file reports drift |
resize | All six | Applies CPU and memory changes and grows the root disk; -I/-A are only checked for consistency |
setup reusing an inventory | None | Flags are rejected and environment variables ignored |
start, stop, restart, status, destroy, purge | None | Applied 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.
Precedence
| Order | Image (per node) | Architecture (whole deployment) |
|---|---|---|
| 1 | --image/-I, on the selected nodes | --arch/-A |
| 2 | BARN_IMAGE | BARN_ARCH |
| 3 | vm_image and vm_version: host, then groups, then all.vars | vm_arch |
| 4 | Saved deployment default, or the embedded default for a new lab | native: 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.
| Architecture | Aliases | Meaning |
|---|---|---|
native | — | Follow the current host; the default |
amd64 | x86_64, x64 | x86-64 guest |
arm64 | aarch64, a64 | ARM64 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
-IorBARN_IMAGE, the suffix sets the deployment architecture, overridingvm_arch. - In
vm_image, the suffix takes precedence overvm_arch: native, the value generated templates write. A concretevm_archthat names the other architecture fails validation, as do nodes whose suffixes disagree. -AandBARN_ARCHmust agree with every suffix still in effect: naming the other architecture, ornative, fails with exit2. A matching value such asel10a -A arm64is accepted.
Image selection details
vm_archbelongs to the whole deployment: set it once inall.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_imageis omitted, existing labs use their saved default for existing and added nodes. A lonevm_versionselects 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 invm_imagerather than reassigning built-in aliases.
vm_version keeps the family and the version prefix in separate fields:
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, andvalidateapply to that invocation only. To keep them, setall.vars.vm_archand the node or groupvm_image, and remove any supersededvm_version.initand template-generatingsetupwrite both into the new inventory;setuprejects-I/-Awith an existing inventory. - Without an inventory file, lifecycle commands apply overrides on top of the saved specification.
startandrestartalways use applied state. - Existing VMs are never converted. After you edit
vm_archor omit-A,upreports drift; switching the architecture requiresrecreatewith all existing nodes selected.resizecannot change the image or architecture. - A guest whose architecture differs from the host runs under QEMU TCG emulation. On Linux,
barn setupinstalls only the native emulator: install the targetqemu-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.
| Field | Default | Meaning |
|---|---|---|
path | required | Absolute 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 |
size | 128 | Capacity: GiB integer or size string |
fs | auto | auto, 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 |
persistent | false | When 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.
| Field | Default | Meaning |
|---|---|---|
host | required | Absolute 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 |
guest | required | Absolute mount point, normalized; spaces, Unicode, and shell punctuation are accepted, control characters are not |
readonly | true | Set 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
.sshdirectory. Do not put PostgreSQL data directories on 9p. - If the guest user cannot write a
readonly: falseshare, Barn mounts it read-only with a warning and leaves host ownership alone; fix host permissions and re-runbarn upto upgrade the mount. - Changing
vm_shareson an existing node requiresbarn recreate. A missing host directory duringuporstartfails only that node;restart,reload, andrecreateverify 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:
- Each entry needs an
addressand a non-emptynameslist. Addresses must be canonical IPv4 in the inventory’s/24, within.9–.254(.1–.8are 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.upnever publishes them. hosts installwithout-fpublishes only names and aliases from applied state and replaces the whole Barn block, dropping these service names; repeat the-fcommand 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:
| Change | Apply with |
|---|---|
| New node | barn up |
CPU or memory, including vm_scale | barn resize <node>; keeps identity and disks |
Larger vm_disk | barn resize <node>, or barn resize -D <size> <node> without editing; grow-only |
| Image, data disks, shares, or other VM definition | barn recreate <node> |
vm_arch, login user, or the /24 | barn recreate of the whole deployment |
Node removed or set to vm_skip: true | Shown 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
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.
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.
| Mode | stdout | stderr |
|---|---|---|
| Text (default) | Results and follow-up hints (connect:, retry:, next:) | Live progress, prompts, error: lines |
--json or --yaml | One JSON or YAML document: the command’s report or a failure object | Progress and diagnostics |
-v, --verbose | Unchanged | Adds 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.
| Code | error | Meaning |
|---|---|---|
0 | Success (including ready guests with non-fatal warnings[] or repairs[]) | |
1 | runtime | Operation executed and failed (external tool, download, or guest failure) |
2 | usage | Invalid CLI syntax, missing inventory file, or invalid configuration/image selector |
3 | capability | Host lacks a required dependency, active Barn network, or privilege |
4 | conflict | Operation conflicts with current deployment state or another active barn process |
5 | partial | Node-level batch failure; inspect failures[] (successful peer nodes remain intact) |
6 | resource | Host IP address, port, subnet, or disk path is already in use |
7 | integrity | Digest, catalog signature or signed revision, instance identity, or file ownership verification failed |
130 | cancelled | Interrupted by SIGINT/SIGTERM or interactive confirmation declined |
sshandexecreturn the remote command’s exit code verbatim, so text output, JSONexit_code, and the process status agree.255can mean either an OpenSSH transport failure or a remote command that exited255.- Deployment lock: When another
barnprocess holds the deployment, mutating commands wait up to 10 minutes while naming the holder, then exit4withreason: "deployment_busy". Read-only and access commands (status,ssh,exec,ssh-config,hosts) do not wait;statusshows the last committed state and names the active operation innote. - 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 withreason: "catalog_equivocation". Permission and I/O errors while reading a cached signature are runtime failures (exit1).
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:
| Field | Present | Meaning |
|---|---|---|
error | Always | Error class from the exit code table |
message | Always | Human-readable summary |
reason | When known | Stable snake_case cause for automation |
next | When known | Suggested next command |
operation_id | When assigned | Correlates with barn logs --source events |
command | An external program failed | name, argv, exit_status, signal, timed_out, stderr |
failures, rolled_back | Exit 5 from a lifecycle batch | Failed nodes and rolled-back preparations, as in Lifecycle results |
Common reason values on Linux commands:
reason | error | Cause and usual next step |
|---|---|---|
no_inventory | usage | No inventory in the current directory: barn init, or pass -f |
unknown_node | usage | A selector is not a node name in the inventory or deployment |
unknown_image | usage | The image selector is not in the active catalog |
qemu_missing | capability | QEMU is missing or unusable; next names the fix |
network_absent | capability | The Barn network is not installed: barn setup |
sudo_unavailable | capability | sudo failed, or needs a password while stdin is not a terminal |
no_deployment | conflict | BARN_HOME holds no applied deployment: barn up |
node_not_running | conflict | The node is stopped: barn start <node> |
resize_required | conflict | Drift that barn resize applies |
recreate_required | conflict | Drift that needs barn plan, then barn recreate <node> |
nodes_removed | conflict | The inventory omits existing nodes; see Lifecycle results |
deployment_changed | conflict | Applied state changed during recreate preflight; review and retry |
deployment_busy | conflict | Another command held the lock for 10 minutes |
interrupted_transition | conflict | A node is still mid-transition after an interrupted command; run the next command |
hosts_name_taken | conflict | /etc/hosts maps a Barn name outside the Barn-owned block |
disk_full | resource | The host disk ran out of space |
image_integrity | integrity | A 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:
| Command | stdin is a terminal | stdin is not a terminal |
|---|---|---|
recreate, destroy | Lists 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 prompt | Exit 2 unless --yes or --force is given (there is no -y) |
setup | Shows the plan and asks once | Requires --yes, else exit 2; --dry-run previews and cannot be combined with --yes |
network, hosts install/uninstall | Shows the privileged plan and asks (install defaults to yes, uninstall to no); with --json/--yaml it only previews | Prints 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 missing | Shows the host-preparation plan and asks once, as setup does; an interactive up with neither an inventory nor a deployment also generates meta | Reports 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,
-fmeans--file(exceptbarn logs -f, which is--follow),-nmeans--no-wait(barn mac logs -nsets the line count), and-dmeans--dry-run. - Safety and repository flags are long-form only:
--ask,--mirror,--force,--rollback,--remove,--allow-downgrade,--sudo,--delete-persistent,--purge. -yexists only where a command’s option table lists it; ondestroyandrecreate,--yesis the same as--force.- Path arguments such as
-f,--script, a local--repo,image importsources, andreporoots 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:
| Field | Contents |
|---|---|
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_config | Event-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:
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
-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 (
sudoforwards 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
uporstart, a missing host share or a failed new-node preparation affects only that node; independent stopped nodes still start, and the command exits5with 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; astopinterrupted while the VM kept running marks itrunning. After an onlineresizeinterrupted mid-change,statusreportsresize_incomplete: retrybarn resize <node>or runbarn restart <node>. Other interrupted transitions print the recovery command (destroyresolves them directly), and the next run after a failed initialuprolls back uncommitted journal artifacts automatically. - Event log:
setupand the lifecycle run that follows share oneoperation_id. Even if setup fails before a deployment exists,barn logs --source events --jsonshows the bounded phase log, without sensitive arguments or credentials;setup --dry-runwrites none. - Retained persistent disks: Disks left by a previously removed node do not block destroying the remaining nodes; delete them with
destroy --delete-persistentorpurge. - macOS setup:
setupfinishes Homebrew discovery or installation and the pinnedsocket_vmnetdownload before asking for administrator privileges, so a slow download cannot expire an earliersudotoken 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 variable | Purpose |
|---|---|
BARN_HOME | Private 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_DISK | VM specification overrides; CLI takes priority. Read only by commands accepting each field; see specification overrides |
BARN_REPO | Default image repository URL or path; overridden by --mirror and --repo |
BARN_OUTPUT | Default output format (text, json, or yaml); overridden by --json/--yaml |
BARN_VERBOSE | Boolean default for diagnostic output; overridden by -v/--verbose |
BARN_VMNET_ARCHIVE | Path to a local pinned socket_vmnet archive for macOS setup; accepts relative paths, ~/, and symlinks (SHA-256 verification still applies) |
NO_COLOR | Any 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
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.
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 macas the logged-in desktop user. Commands that talk to the runner rejectrootwithmac_root, and a host that is not Apple Silicon on macOS 27 or later withmac_host_unsupported. Disk space and the two-VM limit are under requirements. - On Linux and Intel Macs,
barn --helphidesmac. Commands that only read local state, such asbarn mac image ls, work without the runner. barn macwith no subcommand runsbarn 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 Homebrewlibexeclayouts.BARN_MAC_RUNNERoverrides 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.
| Setting | New machine default | Change it with |
|---|---|---|
| CPUs | 4 | configure --cpu, while stopped |
| Memory | 8 GiB | configure --memory, while stopped |
| Shared folders | none | configure --share / --unshare, while stopped |
| Subnet | first free /24 | configure --subnet, while stopped |
| Clipboard sync | on | configure --clipboard, anytime; applies at the next start |
| Disk capacity | the prepared base’s capacity, or 100 GiB for the first base | fixed |
| Administrator account | your host macOS username, or barn if that is not a valid account name | fixed |
| macOS build | the default base | recreate --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
passwordfile (mode0600) and printed bybarn mac password. - Hostnames: the guest ComputerName is
<name>and LocalHostName isbarn-<name>(reachable asbarn-<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 --sharewith 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_limitand 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.
| Item | Value |
|---|---|
| Subnet | First 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 |
| Reachability | Host-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:
sshjoins the arguments after--into one command string for the guest shell, as plainsshdoes. Without a command it opens an interactive shell.execpasses the program and each argument separately, so spaces, quotes, and empty arguments arrive intact. It requires a command. Wrap pipelines, redirection, and compound commands insh -c '...'. For compatibilityexecalso accepts a single command string as shell shorthand; new scripts should pass separate arguments or an explicitsh -c.
Argument rules for both commands:
- A remote command always follows
--, and its first argument must not be empty. Interactivebarn mac ssh devneeds 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, withbarn mac lsas the next step. --jsonneeds 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).
| Field | Values |
|---|---|
base | The default base for new machines |
machines[].image | The base this machine was cloned from |
state | prepared (created, first boot not completed), starting, running, stopping, stopped, unknown |
ready | true when this check verified guest SSH and passwordless sudo |
ssh | ready, pending (first boot in progress), unavailable, offline, unchecked |
observed | Present when the running guest reports a macOS build different from its base |
window_visible | Present while the desktop window is open |
error, warnings | The last failure recorded for the machine, and SSH issues found during this check |
running, limit | Machines 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.
| Field | Values |
|---|---|
action | created, started, running (already running), restarted, recreated, opened, configured, stopped, powered_off, already_stopped, destroyed, absent |
forced | true 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) |
window | true when the desktop window was opened |
warnings | Non-fatal notices, such as a clipboard change that takes effect at the next start |
Other commands:
exec --json: the same schema as Linuxbarn exec --json(node,exit_code,stdout,stderr).password --json:nameandpassword, or{"name": "mac1", "copied": true}with--copy.ssh-config --json:fragmentwhen printing; installation status with--installor--remove.logs --json:nameandlogs.doctor --json:okandchecks[](name,ok,detail, optionalnext); exits3if 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.
| Reason | Exit | Meaning and next step |
|---|---|---|
mac_host_unsupported | 3 | Host is not Apple Silicon or is running macOS older than 27 |
mac_runner_missing | 3 | Barn.app / native runner is not installed alongside the barn CLI |
mac_runner_protocol | 3 | Installed Barn.app uses a different runner protocol version; reinstall matching CLI and app builds |
mac_root | 2 | Invoked as root; run as the logged-in desktop user without sudo |
mac_download_consent | 2 | Non-interactive macOS download requires --yes (or supply a local file with --ipsw) |
mac_machine_absent | 4 | Named VM does not exist; create it with barn mac up NAME |
mac_not_initialized | 4 | VM has not finished its first boot; complete initialization with barn mac up NAME |
mac_not_running | 4 | ssh or exec called on a stopped VM; run barn mac start NAME |
mac_running | 4 | Requested configuration change requires the VM to be stopped; run barn mac stop NAME |
mac_configuration_conflict | 4 | up flags differ from the existing VM; run the suggested configure or recreate command |
ssh_config_linked | 4 | ~/.ssh/config is a symlink or hard link; add the printed Include line manually |
mac_vm_limit | 6 | Two macOS VMs are already running on this Mac; stop the reported VM first |
mac_subnet_in_use | 6 | A host route overlaps the VM’s subnet; run barn mac configure NAME --subnet auto |
disk_full | 6 | Insufficient free disk space to download or install the macOS base image |
mac_machine_damaged | 7 | An initialized VM slot is missing its disk or identity files (the slot directory is preserved for inspection) |
mac_readiness_interrupted | 130 | barn 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
- ipsw/
- 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
- <name>/
- 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-configmanages~/.ssh/barn-mac_configand a# barn-mac:includeblock in~/.ssh/config, independent of the Linux# barn:includeblock.barn mac ssh-config --removesetsssh_config_offinconfig.json, so lifecycle commands stop re-adding theIncludeblock until you runbarn mac ssh-config --install. - Desktop preferences: window positions live in
~/Library/Preferences/com.pgsty.barn.plist(0.9.0used~/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, setsComputerNameandLocalHostName, and disables idle sleep withpmset.
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
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.
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
| Family | stable in 2026120302 | Family aliases | Architecture aliases (arm64 / amd64) |
|---|---|---|---|
d13 | 20261130.2678.1 | d, debian, debian13, trixie | d13a, da / d13x, d13i, dx, di |
d12 | 20261130.2678.1 | debian12, bookworm | d12a / d12x, d12i |
el7 | 7.9.20221112.0 | c7, centos7, centos79 | — / el7x, el7i, c7x, c7i |
el8 | 8.10.20240528.3 | rocky8 | el8a / el8x, el8i |
el9 | 9.9.20261112.1 | rocky9 (rocky in 1.2.0) | el9a / el9x, el9i |
el10 | 10.3.20261112.1 | e, el, rocky, rocky10 | el10a, ea, ela / el10x, el10i, ex, ei, elx, eli |
u22 | 20261109.0.1 | ubuntu22, ubuntu2204, jammy | u22a / u22x, u22i |
u24 | 20261017.0.1 | ubuntu24, ubuntu2404, noble (ubuntu in 1.2.0) | u24a / u24x, u24i |
u26 | 20261108.0.1 | u, ubuntu, ubuntu26, ubuntu2604, resolute | u26a, 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, andu26are Ubuntu 22.04, 24.04, and 26.04 LTS;d12andd13are Debian 12 and 13. Barn’s image recipe builds them from the distributions’ cloud images: the image ships adbauser (UID/GID 88), XFS userspace tools are present, anden_US.UTF-8is available whileC.UTF-8stays the default locale.el7is CentOS Linux 7.9 (amd64BIOS), andel8,el9, andel10are Rocky Linux (amd64andarm64UEFI). All three Rocky families go through Barn’s recipe (dba, UID/GID 88). The currentel10images also include signed kernel modules required by Docker’s default bridge networking, iptables firewall rules, and overlay filesystem.el7remains the distribution’s unmodified cloud image.cloud-initconfigures 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 recreateoperations resolve the selected image against the active catalog. Catalog rotation tests
| Alias | Distribution | Architectures | Boot | Status |
|---|---|---|---|---|
el7 | CentOS Linux 7.9 / 2211 | amd64 | BIOS | deprecated |
el8 | Rocky Linux 8.10 | amd64, arm64 | UEFI | deprecated |
el9 | Rocky Linux 9.9 | amd64, arm64 | UEFI | supported |
el10 | Rocky Linux 10.3 | amd64, arm64 | UEFI | supported |
d12, d13 | Debian 12 / 13 | amd64, arm64 | UEFI | supported |
u22 | Ubuntu 22.04 LTS | amd64, arm64 | UEFI | deprecated |
u24, u26 | Ubuntu 24.04 / 26.04 LTS | amd64, arm64 | UEFI | supported |
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:
- 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 updateorbarn image sync). - Resolve the selector and architecture — Resolves
image[:channel]orimage@version-prefix(or the active catalog’s default if omitted) and the target architecture. Bare aliases in standaloneimage pulldefault to the host, while architecture-suffixed aliases selectarm64oramd64directly; lifecycle commands usevm_arch(or an architecture-suffixed alias), also defaulting to the host when unset.--arch/-Aoverrides non-pinned choices and rejects conflicting pinned aliases; see configuration precedence. - Verify the local cache — Reuses an existing cached file immediately if its byte size, SHA-256 digest, and
qemu-imgstructural checks all pass. - 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
qcow2header before moving it into the cache. The two official mirrors (https://repo.pigsty.io/barnandhttps://repo.pigsty.cc/barn) can fall back to each other during artifact downloads, while custom--reposources 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).
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 updatefetches, verifies, and activates the current catalog from--repoor--mirror.barn image syncactivates 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 resetreverts 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.
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 andimages/may be shared writable directories.repo.yamlmay link to a non-empty regular file up to 4 MiB. Artifact entries remain regular files;catalog.jsonoutput symlinks are not overwritten. - Boot mode inherits along
variant→family→defaults.boot; status inherits alongvariant→version→unknown. Every family must define the default channel pointing to an existing version, and family/alias names must be unique and cannot start withlocal-. 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): barn repo scanis read-only and does not requireqemu-img; it exits0while reporting anymissing,unsafe, oruntrackedfiles in its output arrays (automation must check thatmissingandunsafeare empty).barn repo buildandbarn repo verifyuseqemu-img. An unchanged rebuild preserves the catalog bytes. If you setrevisionexplicitly, 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:
Import rules:
image importaccepts relative paths,~/, and symlinks to regular files, and requiresqemu-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--sha256verifies an expected digest.image importcopies and validates theqcow2container as-is without modifying guest credentials, installingcloud-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|uefiand--source-user <user>and default to the host architecture.--arch/-Acan record an explicitamd64orarm64architecture, including aliases. The qcow2 metadata cannot identify the guest CPU, and import does not convert architectures. Match inventoryvm_archor the lifecycle command’s-Awhen using the image. Aliases are immutable and can be referenced viavm_image: local-mybase; unnamed imports only pre-populate the cache and cannot accept-A.
Pruning
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
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:
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.
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.
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.
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
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.
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.
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.
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.
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
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;offlinemode also needs workinglibguestfstools (virt-customize,virt-cat). Override them with--qemu-img,--virt-customize, and--virt-cat, or withQEMU_IMG,VIRT_CUSTOMIZE, andVIRT_CAT. - Storage: keep source images, RPM/DEB package caches, and output directories outside the Git working tree, which tracks only recipes and lockfiles.
- Architecture:
--archrecords the target architecture in the metadata; runofflinecustomization wherelibguestfscan execute that architecture.
Modes and profiles
validatecopies and re-hashes the source, checks that it is a single-fileqcow2withqemu-img check, and writes an evidence bundle without touching guest files or credentials.offlinenormalizes guest access on a staged copy withvirt-customize --no-networkandvirt-cat: it confirms UID/GID88is free of unrelated accounts, configures the lockeddba/adminidentity, disables SSH password and root login, strips SSH host keys, shell history, machine-id, andcloud-initcaches, restores SELinux labels, and reads back a deterministic guest marker.
The profile adds distribution-specific steps; build.sh defaults to --profile base:
| Profile | Normalization steps | Package inputs |
|---|---|---|
base | Account, sudo, SSH, and cloud-init normalization only | None (package flags rejected) |
el8 | Base normalization plus Python 3, SSH drop-in include, legacy network cleanup, chronyd, and SELinux relabeling | Locked RPM dependency set |
el9 | Base normalization plus legacy network cleanup and SELinux relabeling | None (package flags rejected) |
el10 | Base normalization plus signed kernel-modules and kernel-modules-extra matching kernel-core, Docker bridge/iptables/overlay module verification, and SELinux relabeling | Locked RPM dependency set |
d12, d13 | Base normalization plus offline XFS userspace tools and en_US.UTF-8 / C.UTF-8 locale setup | Locked 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
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:
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 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:
| File | Purpose |
|---|---|
<name>-<release>-<arch>-<digest-prefix>.qcow2 | Validated read-only candidate qcow2 image |
build-recipe.json | Builder invocation, tool versions, and input digests |
manifest-candidate.json | Unsigned candidate metadata (status: "testing") |
provenance.intoto.json | SLSA build provenance statement |
sbom.spdx.json | SPDX software bill of materials covering declared pipeline inputs and injected packages |
validation.json | Before/after qcow2 checks, normalization marker results, and pending release gates |
checksums.txt | SHA-256 checksums of the other files in the bundle |
package-lock.json | Included 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:
- Run live VM smoke tests across the target host and guest combinations.
- Update
repo.yamlwith the new catalogrevisionandsupportedstatus. - Run
barn repo buildandbarn repo verify. - Sign
catalog.jsonand publish its detached signature ascatalog.json.minisig. - Verify the published repository endpoints.
3 - Project
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
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
| Host | Linux guests | macOS guests |
|---|---|---|
| macOS on Apple Silicon | Yes — QEMU 8.2.1+ with HVF | Yes — macOS 27 or later on the host, Barn.app |
| macOS on Intel | Yes — QEMU 8.2.1+ with HVF | No |
Linux on amd64 or arm64 | Yes — QEMU 6.2+ with KVM, NetworkManager or systemd-networkd | No |
| Windows | No 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.
| Family | Name | Architectures | Notes |
|---|---|---|---|
| Debian 13 | d13 | amd64, arm64 | Default in 1.5.0 |
| Debian 12 | d12 | amd64, arm64 | |
| Ubuntu 26.04 LTS | u26 | amd64, arm64 | |
| Ubuntu 24.04 LTS | u24 | amd64, arm64 | |
| Ubuntu 22.04 LTS | u22 | amd64, arm64 | Deprecated |
| Rocky Linux 10 | el10 | amd64, arm64 | |
| Rocky Linux 9 | el9 | amd64, arm64 | |
| Rocky Linux 8 | el8 | amd64, arm64 | Deprecated; on Apple Silicon the arm64 image runs under emulation, because its 64 KiB page kernel cannot run on HVF |
| CentOS 7 | el7 | amd64 | Deprecated, 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_sharesmounts 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 stopshuts the guest down;barn startboots 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
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 …) | |
|---|---|---|
| Hypervisor | QEMU with HVF or KVM; TCG emulation for a foreign architecture | Apple Virtualization.framework |
| Configuration | One 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) |
| Network | NAT management interface plus a shared fixed-IP /24 | One private /24 NAT subnet per VM, guest at .10 |
| Typical use | Database clusters, Ansible playbooks, multi-node testing | macOS 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 upcreates 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 needbarn recreate. - A node removed from the file keeps running until you run
barn destroyon it, and a whole-labrecreaterefuses 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-Afor one command). It defaults to the host’s. An architecture-suffixed image alias such asel10aord13xalso selects it. Precedence rules barn statusshows each node’s architecture and accelerator.- Before
recreatedeletes 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:
| Interface | Provided by | Used for |
|---|---|---|
| Management | QEMU user-mode NAT with DHCP | Internet access, DNS, and the SSH port forwarded to 127.0.0.1 on the host |
| Lab | A host bridge, static address from the inventory | Host-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/imagesand shared by all nodes; each node’s root disk is a thin copy-on-write overlay on top. barn updaterefreshes the image catalog without touching existing root disks. New and recreated nodes get the newer images.- Data disks marked
persistent: truesurvivedestroyandrecreate. barn image pruneremoves 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
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:
| Command | What 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 / uninstall | Creates or removes the host-wide fixed-IP network: the barn0 bridge on Linux, the socket_vmnet launchd service on macOS |
barn hosts install / uninstall | barn-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:
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
dbaand can be set withnode_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
0600passwordfile next to the VM’s SSH key;barn mac passwordshows it. It stays out of Keychain because the key beside it already grantssudo, so Keychain would add signing and lock-state failures without protecting anything more (design note).
Each connection path pins host keys differently:
| Connection | Host-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 peers | StrictHostKeyChecking 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
| Channel | Linux guest | macOS guest |
|---|---|---|
| Host directories | vm_shares entries over Virtio-9p, read-only unless readonly: false (shares) | --share entries over VirtioFS, writable unless suffixed :ro (shared folders) |
| Clipboard | None; Linux guests run headless | Plain 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:
| Object | Verification |
|---|---|
| Release assets | The 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 binaries | The 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 catalog | Official 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 files | Downloads 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:
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
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 change | Where to work |
|---|---|
CLI behavior, VM lifecycle, native macOS component (Barn.app), installer, and packages | pgsty/barn |
| Documentation site, guides, command reference, and translations | pgsty/barn.pgsty.com |
| Official Linux image definitions or offline normalization rules | packaging/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-helperor the reviewed network plan, nowhere else. barn macstays separate: it never reads the Linux inventory and runs entirely as the invoking user.
Find the implementation
| Subsystem | Source paths |
|---|---|
| CLI commands, flags, JSON/YAML output, and error rendering | cmd/barn/, internal/failure/ |
| Inventory parsing, defaults, and resolved node specs | internal/config/, internal/spec/ |
| Linux lifecycle: convergence, journals, disks, and SSH readiness | internal/linuxvm/ (internal/private/ in v1.3.0 and earlier), internal/vm/, internal/cloudinit/, internal/state/ |
| Host platform and QEMU arguments | internal/platform/, internal/qemu/ |
Host preparation, networking, process identity, and /etc/hosts | internal/setup/, internal/network/, internal/process/, internal/hostconfig/, cmd/barn-hosts-helper/ |
Deployment SSH keys and the ~/.ssh/config integration | internal/sshkeys/, internal/sshconfig/ |
| Guest clock checks and scheduled sync | internal/timesync/, internal/timejob/ |
Image catalog trust, qcow2 verification, and catalog tools | internal/image/, tools/catalogcheck/, tools/catalogexport/, tools/catalogsign/ |
| Native macOS VMs and the desktop app | internal/macvm/, native/mac-runner/ |
| Packaging, image pipeline, CI workflows, and integration tests | packaging/, .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:
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.
| Target | What it does | Run it |
|---|---|---|
make build | Builds bin/barn and its matching bin/barn-hosts-helper for this host | While iterating (details) |
make test | go test ./... | While iterating |
make race | go test -race ./... | For concurrency changes |
make check | Everything CI runs (below) | Before every pull request; it must pass |
make mac-native-test | C and Swift tests for the native runner; needs Apple Silicon, macOS 27+, and Xcode 27+ | For native Mac changes |
make release-snapshot | Builds and verifies a complete snapshot release without uploading anything | For 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:
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.
| Content | Location |
|---|---|
| Task guides | versions/manuals/1.5/docs/start/ for 1.5-specific changes |
| Command and configuration reference | versions/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 status | content/blog/design/ |
| Release notes | content/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:
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.gzarchives fordarwinandlinuxonamd64andarm64, each withbin/barn,bin/barn-hosts-helper, andlicenses/. Since 0.9.2 the Darwin arm64 archive also carriesbin/Barn.app, with the CLI, helper, and app signed with Developer ID and notarized.- Linux
.deband.rpmpackages that install/usr/bin/barnand/opt/barn/libexec/barn-hosts-helper. checksums.txt, its detachedchecksums.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:
- Move the
Unreleasedentries inCHANGELOG.mdinto a dated section, update the README installation links, and add an English release note without a top-level heading at.github/releases/<version>.md. - Pass the catalog gate with
make catalog-check, synchronizing the embedded catalog first if it changed (below). - Require source CI to pass on the release commit, and a packaging snapshot to pass on the latest packaging changes.
- 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. - Run live Linux VM acceptance, plus Mac acceptance when shipping
Barn.app. - 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 - 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:
Verify the new signed catalog, then copy it to
internal/image/default-catalog.json.Update
EmbeddedManifestVersionininternal/image/catalog.goand the embedded catalog date ininternal/image/manifest.go; updatepackaging/image-repository/repo.yamlif the repository sources changed.Run the catalog tests (
go test ./internal/image/...), andbarn updatewith a fresh temporaryBARN_HOMEto confirm the remote catalog verifies and activates.Run the online gate:
make catalog-checkactivates 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-bytesalso downloads and hashes every stable image (several GB, nothing kept). Formal native builds and both release paths runcatalog-checkautomatically; 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
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:
- Build and sign
barn-hosts-helper. - Build
barnwith the signed helper’s SHA-256 embedded, then sign the CLI. - Sign
Barn.appwith hardened runtime and a secure timestamp. - Submit the CLI, helper, and app to Apple together for notarization. After acceptance, staple the app, validate its ticket, and check Gatekeeper.
- Export the payload, extract it again, and recheck the signatures and the stapled ticket.
- 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.
Prepare the Mac. You need Apple Silicon with macOS 27+ and Xcode 27+, the toolchain pinned in
packaging/toolchain.env, andgoreleaser,syft,rpm,ruby,bsdtar,jq, andpython3onPATH. Find your Developer ID Application identity withsecurity find-identity -v -p codesigning, and store a notarization profile withxcrun notarytool store-credentials. Keep certificate private keys and passwords outside the repository.Check out the release tag.
release-localrequiresHEADat tagv<version>, a clean working tree and index with no untracked files, and anoriginremote.Synchronize the catalog if it changed. The formal payload build and
release-localboth runmake catalog-checkfirst and stop on any mismatch; see Maintain the image catalog.Build the signed payload and assemble the release into a new directory outside the source tree:
Variable Effect BARN_CODESIGN_IDENTITYDeveloper ID identity used to sign the helper, CLI, and app; unset means ad-hoc signing BARN_NOTARY_PROFILEStored notarytoolprofile; the payload is submitted to Apple for notarizationBARN_MAC_REQUIRE_NOTARIZATION=1Fails the build unless it is Developer ID signed and notarized; mac-release.py buildalso runs the catalog gate firstCheck the output.
release-localaccepts only a Developer ID signed, notarized payload built from the same commit, so a snapshot oruncommittedpayload 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.
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:
| Secret | Value |
|---|---|
MAC_CERTIFICATE_BASE64 | Base64-encoded Developer ID Application .p12, including the private key |
MAC_CERTIFICATE_PASSWORD | Password protecting the .p12 |
MAC_CODESIGN_IDENTITY | Imported identity name or certificate fingerprint |
MAC_NOTARY_KEY_BASE64 | Base64-encoded App Store Connect API .p8 key |
MAC_NOTARY_KEY_ID | API key identifier |
MAC_NOTARY_ISSUER | API issuer identifier |
| Secrets configured | Tag workflow behavior |
|---|---|
| None | Skips automatic release creation; use the local path |
| Some | Fails immediately |
| All six | Builds, 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
Run the gates:
make check,make mac-native-test, and a full snapshot with the native payload.Test installation in an isolated directory: first install, repeat install, and upgrade.
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:
Option Meaning --barnAbsolute path to the packaged barn--homeDedicated, disposable BARN_HOME;mac1is recreated and destroyed--outputNew or empty evidence directory, separate from --home--allow-test-rootRequired the first time; marks --homeas a destructive test root--planPrint the phases without running Barn or touching files --guiAdd desktop and clipboard checks --allow-downloadLet updownload macOS from Apple (about 26 GB) when no base is preparedA 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/configentries live outside the VM state root.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.txtandchecksums.txt.sigtogether.make release-publish RELEASE_TAG=v<version>verifies the staged inventory and digests before publication. Signing stepsUpdate Homebrew. Release assembly generates
barn.rbfrompackaging/homebrew/barn.rb.tmpl, which installsbarnintobinand the helper and app intolibexec; 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 explicitversionline, because Homebrew may otherwise infer64from the architecture suffix; plain versions omit it.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
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
| Item | Recorded identity |
|---|---|
| Tag and commit | v1.2.0 → 90f615804b823b4eb491101e642073dcd37a9700 |
| Build time | 2026-11-11T23:38:07Z; SOURCE_DATE_EPOCH=1794440287 |
| GitHub Release | ID 442314866; published 2026-11-12T00:05:32Z as stable/latest |
| Apple notarization | Accepted submission 165b486b-5055-4eca-a595-54bed6bdd6c1 |
| Signed catalog | Revision 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/arm64andlinux/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
| Item | Recorded identity |
|---|---|
| Tag and commit | v1.1.0 → b2cc8da8983e710255d504bf26bf5d7b3f182790 |
| Build time | 2026-11-09T01:28:55Z; SOURCE_DATE_EPOCH=1794187735 |
| GitHub Release | ID 438656123; published 2026-11-09T01:46:13Z as stable/latest |
| Signed catalog | Revision 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, andmake release-snapshotalso 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 Homebrewbin/libexeclayout 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/amd64binary created a Debian 13 guest using-I d13 -A x86_64without rewriting its inventory. CPU/memory changes2/2 GiB → 3/3 GiB → 2/2 GiB, stop/start, remote arguments, and exit17passed. VM UUID, SSH public key, machine ID, and the persistent-disk sentinel survived resizing and restart. A second Debian 13 guest booted asarm64through-A aarch64, using QEMU TCG withcortex-a72; SSH reportedaarch64. 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.0installed 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-nodebarn up, andbarn statuson 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:
| Item | Recorded identity |
|---|---|
| Tag and commit | v1.0.0 → 69ef7f1d6ffc7c6fbffffe178b2fa48e799dc02d |
| Build time | 2026-11-04T17:54:45Z; SOURCE_DATE_EPOCH=1793814885 |
| GitHub Release | ID 434268111; published 2026-11-04T23:18:10Z as stable/latest |
| Signed catalog | Revision 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_HOMEactivated the catalog withbarn 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.0installer 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 exit17passed. Missing-node recreation failed before stopping VMs; control-node deletion elected a successor; destruction followed byuprotated machine identity while preserving a persistent-disk sentinel. - Public channels: After publication, both the default installer and explicit
BARN_VERSION=1.0.0installed the public release. Real Homebrew upgraded0.9.2 → 1.0.0and passedbrew 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
| Component | Identity at the 2026-09-29 checkpoint | Scope notes |
|---|---|---|
| Application and docs | Barn 0.9.0 release candidate | Built from the renamed source tree prior to public tag release |
| CLI and configuration | barn, barn.yml, BARN_* | Clean break from earlier internal names |
| State and host resources | ~/.barn, Barn networking, and barn-hosts-helper | Uses fresh ~/.barn state without migrating pre-rename development directories |
| Image repository | /barn on the official endpoints | Requires 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
/barnimage endpoints, andbarn.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 sstarting 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, andprobechecks 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,
sshdhardening, disk and per-VM subnet isolation, DNS, outbound HTTPS, exit-code propagation,execargument boundaries, bidirectional shared-folder writes, cleanstop/start,configure, enforcement of the two-VM running limit,recreateidentity rotation, desktop window display, two-way plain-text clipboard sync, idempotentup, anddestroy. - Manual timing and recovery checks: First boot from a prepared base image reached SSH readiness in
22 s; clean shutdown completed in6.5 s; subsequent starts reached SSH readiness in6–12 s; forced power-off completed in0.7 s. Also verified booting into macOS Recovery (--recovery), changing--subnetwhile preserving the pinned SSH host key, and connecting viassh mac1through installed~/.ssh/barn-mac_configentries.
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 uporbarn 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 artifact | Path | Last verified | Result |
|---|---|---|---|
Two Linux amd64 hosts (m0, m3) | KVM, 7 guest distributions per host | 2026-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 host | 2026-09-21 (0.8.0) | Full 7-distro lifecycle checks plus 7-node ansible all -m ping passed |
Catalog 2026092001 | 9 families, 37 artifacts (September Debian/Ubuntu refresh) | 2026-09-21 | Embedded, 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 amd64 | KVM, QEMU 10.2.1, Ubuntu 24.04 guest | 2026-09-16 (0.7.0 recovery) | Corrupt data-disk reset, failed probes, busy mounts, retained-disk recreation, share recovery, and idempotent up passed |
macOS arm64 | HVF, Ubuntu 24.04.4 guests | 2026-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 arm64 | HVF, QEMU 11.1, socket_vmnet | 2026-09-01 (v0.2.0) | Selected node create/SSH/stop/start, incremental cached create, full status, and full destroy passed |
macOS 26.6.2 arm64 | HVF, QEMU 11.1, socket_vmnet | 2026-08-27 | Single-node and additive four-node lifecycle passed |
Ubuntu 26.04 amd64 (mx) | KVM, QEMU 10.2.1, NetworkManager | 2026-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, NetworkManager | 2026-08-27 | Host setup, single-node, additive four-node, and network uninstall passed |
macOS arm64 | HVF host, TCG rule for Rocky Linux 8.10 arm64 | 2026-08-28 | Boot, stop/start, and SSH readiness in 44.2 s passed |
Published Catalog 2026090501 | 9 families, 27 qcow2 artifacts | 2026-09-05 | Artifact verification, embedded/public byte equality, and signed barn update against both official endpoints passed |
Published Catalog 2026082903 | 9 families, 27 signed qcow2 artifacts | 2026-08-29 | Full 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 freshsystemd-networkdhost replay. - Physical host reboot persistence across active deployments.
- Live hypervisor runs on
darwin/amd64andlinux/arm64hosts beyond cross-build and package verification. - End-to-end
el7VM lifecycle replay on nativelinux/amd64. - Full Pigsty
configure → barn up → install.ymlplaybook execution. - Fresh-host
setupand 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 inchecksums.txt, and isolated user-prefix installs ondarwin/arm64andlinux/amd64verified0.8.0(320a32a). - Homebrew tap: Commit
9c34019updatedpgsty/infra/farrowto0.8.0across all four targets and passed localbrew fetch, audit, and tap CI. - Four-host 7-distro acceptance: Clean initialization was run at baseline commit
6d7870e26cb2f4082a00c188f746783fc027687eacross two Linuxamd64hosts (m0,m3, installed from the.debpackage) and two macOSarm64hosts (m1,m5, installed from the verified archive), booting the 7-distroproinventory from a local LAN repository. Runtime candidate1c054a027420b5410c6f6feb344e27e001ae1af1(adding the macOS Homebrew authentication-order fix) was then installed in place on all four hosts and verified across idempotentup(preserving running QEMU processes, VM UUIDs, and disk inodes), two rounds of guest SSH,stop/start,/datadisk mounts, Debian locale/XFS checks, control-to-peer SSH, and Ansible inventory reads (ansible all -m pingon 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 ondarwin/arm64andlinux/amd64, andpgsty/infra/farrowpassed localbrew upgradeandbrew test. - Ubuntu
amd64/KVM storage & bootstrap recovery: Tested corruptext4/XFSdata-disk resets (3.2 srecovery while keeping the QEMU process alive), persistent disk retention acrossrecreate, transient probe failures and busy mounts (preserving existing disk data and UUIDs), read-only 9p share fallback, and resuming a0.6.0VM whose initial egress probe had failed (3.3 srecovery, surfacing the expectedcontrol-sshwarning where0.6.0had already removed the staged control key; see the 0.7.0 Release Notes). Catalog2026090501remained 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 Go1.27.1source CI, packaging checks (13d9d70), and the release tag workflow, producing 20 verified release assets. An isolateddarwin/arm64installation verified upgrading from0.5.0to0.6.0via the public installer, plusfarrow initandfarrow plan. - macOS
arm64/HVF lifecycle acceptance: Verified initial boot, scale-out without restarting the control node, control-to-peer SSH,stop/start,reload, selectiverecreate, scale-in, guest/etc/hostsrefresh, preflight rejection of invalidreloador conflicting partialrecreatebefore stopping existing VMs, degradedstatusreporting, and SSH exit code255passthrough. - Catalog
2026090501: Switched the default image tou24:stableand incorporated the Debian/Rocky updates from2026090302across all 27 verifiedqcow2artifacts 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 sto readiness) while keeping the two healthy nodes’ boot IDs unchanged. - QEMU-free catalog inspection: Decoupled
farrow image listandmake checkfrom requiringqemu-imgonPATHwhen no local cachedqcow2files 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
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:
| Input | Resolution |
|---|---|
BARN_HOME | Relative paths, ~/, and directory symlinks; may also be the working directory |
Inventory and provision --script | Symlinks to regular files; each file retains its 4 MiB limit |
Linux vm_shares.host | Relative to the inventory’s real file, or an absolute/~/ path; directory symlinks work |
Local image repository and image import | Relative paths, ~/, and symlink inputs |
catalogexport output | Relative paths and ~/, directory aliases, and automatic parent creation; target must be absent |
BARN_MAC_RUNNER and local socket_vmnet archive | Relative 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:
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
| Area | New behavior |
|---|---|
| Linux node count | No separate 20-node ceiling; nodes need distinct usable addresses in the deployment’s /24 and sufficient host resources |
| External inventory hosts | vm_skip: true entries may use hostnames or IPv6 keys; managed VMs still use IPv4, and at least one managed node is required |
| Linux capacity strings | Case-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 size | No 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 imports | Arbitrary source filenames; new cache entries use local/<sha256>.qcow2, so same-name files with different contents coexist and identical contents reuse the cache |
| Local aliases | No 256-alias ceiling; updates exceeding the 1 MiB registry metadata limit fail before writing. Reimporting an existing alias preserves its old cache path |
| Local repositories | Relative or linked roots and shared writable directories work; repo.yaml may be a symlink to a regular file |
| Mac logs | Any positive --lines count; requested lines are no longer silently clipped at 1 MiB or 10,000 lines |
| Fallback ports | Try 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
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, commitb2cc8da8983e710255d504bf26bf5d7b3f182790. - 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 reusetests/mac-live-acceptance.pywith 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
| Stage | Operations | Pass condition |
|---|---|---|
| U01 Upgrade baseline | Record the old version, node identities, public SSH fingerprints, and data sentinels; stop Linux and Mac VMs | Reviewable baseline; every target stops cleanly |
| U02 Local installation | brew upgrade pgsty/infra/barn; check version, helper, signatures, notarization, and brew test | Normal PATH resolves to public 1.1.0; CLI, helper, and App match |
| U03 Upgrade recovery | Start existing VMs and compare identities, data, and SSH; then remove old VMs | Upgrade preserves identities and data; explicit disposal succeeds |
| L01 First run | Run barn up from an empty directory; check generated inventory, confirmation, progress, and SSH | Default native Ubuntu 24.04 guest becomes ready |
| L02 Inventory and catalog | Four templates; valid/invalid YAML; -I/-A and aliases; both signed official repositories; metadata and cache | Valid input resolves consistently; failures have correct classification and exit codes; overrides leave inventory unchanged |
| L03 Two nodes and storage | Ubuntu/Debian pair; persistent ext4, temporary data, XFS, space/Unicode paths, read-only and writable 9p shares | Filesystem types, permissions, and bidirectional reads/writes match the inventory |
| L04 Network and access | Fixed IPs, control-node SSH to its peer, DNS/HTTPS, SSH config, exec argument boundaries and remote exit codes | Correct addresses, targets, output streams, and exits |
| L05 Lifecycle | Repeated up, selected stop/start/restart, CPU/memory increase/decrease, reload, selected recreation | Idempotent calls retain PIDs; resources change in the guest; peers and persistent data remain intact |
| L06 Failures and deletion | Omitted nodes, missing share paths, interrupted guest process recovery, provision success/failure/timeout, purge cancellation | No implicit deletion; actionable failures; retries recover; cancellation preserves state |
| L07 Retention | Recreate, selected and whole destroy, create again, purge | Root/temporary data resets; persistent data follows each command’s retention rules |
| L08 Image matrix | Eight supported arm64 image families and Debian amd64 under TCG | SSH, architecture, OS identity, and data disk work; el8 arm64 uses expected TCG |
| M01 Multiple Macs and identity | Automated two-VM checks, independent identities and disks, immutable shared base | Identities differ; cloning and lifecycle operations preserve the base |
| M02 Mac networks and shares | Separate subnets, host access, guest isolation, DNS/HTTPS, VirtioFS, remote arguments | Network and sharing behavior matches the reference |
| M03 Mac lifecycle | Stop/start, resource configuration, third-running-VM limit, recreate identity rotation, selected destruction | Identity retention/rotation matches the operation; the peer remains intact |
| M04 Desktop and clipboard | Open desktop, verify login, copy text both ways, close the window, check SSH | Usable desktop; exact text transfer; window closure keeps the VM running |
| F01 Final state | Remove dedicated test VMs; check normal installation, state, diagnostics, and SSH config; index recordings | No 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
| Area | Result and evidence |
|---|---|
| Homebrew installation and upgrade | Passed; matching CLI/native components, signatures, notarization, and brew test; existing VM identities and persistent-path data survived |
| CLI, inventory, and catalogs | Passed; first run, four templates, architecture aliases, invalid inputs, both signed official sources, local catalog build/verification/import/pruning |
| Linux pair and lifecycle | Passed; fixed IPs, control-node SSH, DNS/HTTPS, arguments/exits, ext4/XFS, read-only/writable 9p, resource changes, recreation, persistent disk reattachment |
| Failures and recovery | Missing shares, provision failure/timeout, cancelled purge, and process interruption after disk sync passed; immediate power-loss readiness issue below |
| Native Mac automated suite | All 15 phases passed; separate identities/disks/networks, unchanged base, resource settings, running-VM limit, recreation, selected destruction |
| Normal Mac data path | Passed; 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 terminals | Linux and Mac passed; real guest TTY allocation and interactive shell exit 17 propagated; all three Linux log sources parsed as JSON |
| Desktop | Logged-in Finder desktop visually confirmed; closing the window kept the same VM process and SSH available; bidirectional clipboard remains unverified |
| Source checks | make check and make mac-native-test passed on the release commit |
| Final state | Zero 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.
| Image | Guest architecture | Accelerator | Result |
|---|---|---|---|
u22@20261020.0.1 | arm64 | hvf | Passed |
u24@20261017.0.1 | arm64 | hvf | Passed |
u26@20261016.0.1 | arm64 | hvf | Passed |
d12@20261026.2643.1 | arm64 | hvf | Passed |
d13@20261103.2651.1 | arm64 | hvf | Passed |
el8@8.10.20240528.3 | arm64 | tcg,thread=multi | Passed |
el9@9.8.20260525.2 | arm64 | hvf | Passed |
el10@10.2.20260525.0 | arm64 | hvf | Passed |
d13@20261103.2651.1 | amd64 | tcg,thread=single | Passed |
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:
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 -nrequired 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/hostswrites 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.