Barn documentation
4 minute read
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
Install Barn, boot your first Linux or macOS VM, then run, change, and script your lab.
Exact syntax, options, defaults, output formats, and file layouts for every part of Barn.
Supported platforms, design decisions, security model, contributing, and release records.