This is the multi-page printable view of this section. .
Command Reference
- 1: Preparation and Utilities
- 2: Linux Lifecycle
- 3: Guest Access and Hosts
- 4: Image Commands
- 5: Repository Commands
- 6: Host Network Commands
- 7: macOS Commands
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 Barn 1.2.0, released on 2026-11-12 from 90f6158. Its 57 operation commands and 174 local option entries were checked against the CLI help output in both languages.
| Label | Availability | Behavior |
|---|---|---|
| 1.1.0 | Options available in both 1.1.0 and 1.2.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 now 1 vCPU / 2 GiB |
To preserve the previous defaults when upgrading, 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 validation.
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 |
| Refresh catalog | update, image sync, image reset |
| Manage Linux images | image list, info, pull, 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, 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.
1 - Preparation and Utilities
Initialize inventories, prepare the host, validate configuration, and inspect the CLI.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the global options.
barn setup
Prepare host packages, the fixed-IP network, images, and the selected inventory. It does not create the Linux VMs: run barn up afterward. With no template or -f, reuse the discovered inventory or generate meta. The templates meta, dual, trio, and full contain 1, 2, 3, and 4 nodes. -c and specification flags customize a generated template; explicit specification flags cannot be used to rewrite an existing inventory. In 1.2.0, specification environment variables are also ignored when setup reuses an inventory.
--dry-run previews the transaction. Applying it requires terminal confirmation or --yes; operating-system privilege prompts can still occur. On a fresh unedited default template, setup may choose a free private /24 and save barn.yml.before-network-change if the default subnet conflicts. Explicit inventories retain their subnet. On Linux, foreign-architecture QEMU emulators and firmware need separate installation.
Aliases: s.
| 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
Generate a Pigsty-compatible YAML inventory. The default is the one-node meta template in ./barn.yml; dual, trio, and full add nodes at .11, .12, and .13. The control node is .10. Existing files require --force; -o - prints the inventory. This command does not download images or prepare the host.
Stable 1.1.0 defaults to 2 vCPUs and 4 GiB per node; 1.2.0 defaults to 1 vCPU and 2 GiB. Both use a 64 GiB root and a separate 128 GiB /data disk. The 1.2.0 templates persist all six specification fields, including vm_scale. See specification defaults.
| 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
Read one inventory, validate the fields Barn consumes, and report the resolved nodes. It accepts no node selectors. Discovery checks barn.yml, barn.yaml, pigsty.yml, then pigsty.yaml in the current directory; no inventory means an error even if applied state exists. Overrides affect this validation only. Use --json to inspect the resolved specification, and plan to compare it with an existing deployment.
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
Probe QEMU, native acceleration, firmware, OpenSSH, a short accelerated boot test, and host networking. This is a host diagnostic and takes no inventory or node arguments. Missing compute capabilities fail the command; missing network setup is reported as informational. Inspect barn network status for the detailed network plan and barn mac doctor for native macOS VMs.
Aliases: dt.
No local options beyond --help; global presentation options still apply.
barn version
Print version, source commit, build time, host OS, and architecture. Development builds normally report dev; release identity comes from the build stamp. Use this report when matching documentation or filing an issue. The root shortcut barn --version is also available.
Aliases: ver.
No local options beyond --help; global presentation options still apply.
barn completion
Require one shell name: bash, zsh, fish, or powershell. Print its completion script to stdout; the command does not install the script. Completion includes scoped flags, templates, image aliases, and best-effort node names. Reload it after upgrading Barn. Use text output when sourcing shell code.
No local options beyond --help; global presentation options still apply.
Implementation
command_setup.go · command_misc.go · command_root.go
The version baseline identifies the released source and the changes since 1.1.0.
2 - Linux Lifecycle
Plan, create, start, resize, inspect, and explicitly remove Linux virtual machines.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the global options.
Node arguments are resolved names such as meta and node-1. Omit them to select all nodes in the command’s inventory/applied scope. IP addresses, groups, and vm_alias are not selectors. plan, up, reload, resize, and recreate read -f, then the current directory’s inventory, then applied state. Other lifecycle commands use applied state directly.
Specification overrides, scaling, and their environment variables are defined in Configuration. The 1.2.0 concurrency option applies only where --parallel is listed; plan, resize, and status do not accept it. For structured results and exit codes, see CLI contracts.
barn plan
Compare the effective desired inventory with applied state without changing VMs or downloading images. Report exact images, resources, per-disk actions, and nodes needing 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 the plan was produced, including plans blocked by omitted nodes. Automation must inspect action, blocked, and the change arrays. Explicit selectors retain the applied definitions of unselected peers. Planning output describes the result.
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
Create missing nodes, start stopped nodes, and retry unfinished guest setup while keeping healthy running VMs alive. It waits for management SSH unless --no-wait is set, and refreshes host SSH aliases and guest host/control-node entries. Non-fatal guest setup problems appear in warnings; ready nodes still succeed.
On an interactive first run, it can prepare missing host dependencies and generate meta when no inventory or applied deployment exists. Scripts should run setup --yes first. Existing definition changes require resize or recreate; inventory omissions require explicit destroy. --rollback only removes safe, uncommitted artifacts from 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
Start selected stopped nodes from applied state and wait for SSH. It works from any directory using the same BARN_HOME, without reading an inventory or creating nodes. It refreshes SSH access; use up to retry unfinished guest setup on an already-running VM. An unavailable share fails its node while 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
Stop selected running Linux VMs using their recorded process identities. It retains root disks, data disks, keys, and deployment state. With no names, stop the whole Linux deployment; it does not stop named macOS VMs or remove the host network.
| 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
Stop and start existing nodes using applied state. Inventory edits are not read. Use reload to re-read an inventory, or resize/recreate to apply changed definitions. It waits for SSH 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
Validate the desired specification and startup dependencies before stopping selected nodes, then converge them through up. It can create newly added nodes. Changes requiring resize or recreation, and omitted applied nodes, fail preflight before any VM stops. Use restart when you want only the recorded configuration.
| 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
Apply CPU and memory changes while preserving VM identity, disks, and SSH keys. Supported increases use hotplug; decreases or unsupported live changes use a stop/start fallback. Stable 1.1.0 reads CPU/memory changes from the inventory. Image, architecture, data-disk, network, share, create, and remove changes cannot be applied by resize.
Barn 1.2.0 additionally accepts resource flags and grows the existing root with -D 128GiB. Root growth stops QEMU, expands its image, boots the guest to grow and verify a last plain ext4/XFS root partition, then restores an initially stopped VM to stopped. Targets must grow and align to 512 bytes. Retry an interrupted growth with the same target; shrinking, LVM, encrypted roots, and non-last partitions are unsupported. See root growth and recovery. CLI overrides do not rewrite the inventory.
| 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
Replace the selected VMs from the desired inventory. This deletes their root disks and non-persistent data disks; compatible persistent data disks are reattached. Inspect plan first. A terminal asks you to type recreate; scripts require --yes or --force (no -y).
No selector means the whole inventory. If it omits an applied node, the operation fails before stopping VMs; explicitly destroy that node or restore it in the inventory. Selected recreation preserves unselected peers. A successful recreation 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
Inspect recorded node configuration and live QEMU process identity without requiring the inventory directory. running reports a verified VM process, not an SSH readiness probe. --verbose adds runtime details; --json exposes node records, active-operation notes, and failures. A degraded node can produce exit 5 while healthy peers are still listed. The 1.2.0 text output uses compact SPEC values such as 2c4g.
Aliases: st.
No local options beyond --help; global presentation options still apply.
barn destroy
Delete selected VMs, or the whole deployment without selectors. Root and non-persistent data disks are deleted; persistent data disks are retained unless a whole-deployment deletion flag is explicit. Terminal confirmation requires typing destroy; scripts need --yes or --force, with no -y.
--delete-persistent and --purge require whole-deployment scope. --purge also removes deployment keys and state. The image cache, host network, and native Mac VMs remain. Removing the control node promotes the first remaining 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
Immediately delete the entire Linux deployment, including root disks, persistent data disks, keys, state, and the default SSH fragment. It takes no node names and reads no inventory. It has no --yes, -y, or --force: use --ask when you want to review the scope and confirm with y/yes (Enter cancels).
Cached images, host networking, and Mac VMs remain. An absent deployment is an idempotent success; ambiguous retained artifacts still require identity checks. The 1.2.0 --parallel flag 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
command_lifecycle.go · main.go
The version baseline identifies the released source and the changes since 1.1.0.
3 - Guest Access and Hosts
Connect to Linux guests, run scripts, read logs, and publish SSH or hosts entries.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the global options.
barn ssh
Open an interactive SSH session on the selected prepared node, defaulting to the prepared control node (or first prepared node). Remote commands require --; arguments after it are joined for the remote shell like ordinary ssh. Put Barn options before the separator. Node selectors are resolved node names, not IP addresses, aliases, or groups.
A remote command returns its exit status unchanged. Structured interactive SSH sends session output to stderr and the final report to stdout. See SSH argument rules.
No local options beyond --help; global presentation options still apply.
barn exec
Run one remote command on the selected prepared node, with the same default-node selection as ssh. -- and a non-empty first command argument are required. Separate arguments preserve spaces, quotes, and later empty values. Use sh -c for pipelines, redirection, or variable expansion; a single command string is also accepted as compatibility shell shorthand.
Text mode forwards the child output and exit status. Structured output includes success, exit_code, stdout, and stderr. A nonzero remote exit is passed through, so inspect that result before interpreting the number as a Barn error class.
Aliases: ex.
No local options beyond --help; global presentation options still apply.
barn logs
Read the selected node’s serial console or QEMU diagnostic log, defaulting to the prepared control/first node. --source events selects the deployment-wide bounded event log and takes no node argument; it can be read before deployment state exists. Following logs emits a stream rather than one final document. -f means follow here, not inventory. QEMU argv is hidden unless verbose output is enabled.
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
Stream a local Bash script over the verified deployment SSH connection to selected running nodes, or all nodes if no names are supplied. The script is not left behind as a guest file; its digest is recorded for auditing. It does not create or start VMs.
--script is required. The default concurrency is 1 and the timeout is one hour for the operation. Unlike development lifecycle concurrency, --parallel 0 is invalid. --sudo uses noninteractive guest sudo -n; ensure the guest user has the required permission. Review per-node output and failures in structured mode.
| 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 Linux deployment’s OpenSSH fragment. --install writes a fragment and one Include in ~/.ssh/config; printing and installation accept node selectors. --remove removes only the named Barn fragment, needs no deployment state, and takes no nodes. Install and remove are mutually exclusive.
The default prefix is barn and its fragment is ~/.ssh/barn_config. Normal lifecycle commands maintain the default fragment automatically. If the user’s SSH configuration cannot be safely edited, Barn reports the manual Include instruction; direct barn ssh remains usable.
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
Publish applied node names and aliases in the Barn-owned block of the host’s /etc/hosts, using the digest-matched privileged helper. On a terminal it shows the change and asks before applying; in noninteractive or structured mode it only previews unless --yes is passed. An unchanged block requires no privilege. This file is not automatically published by up.
Barn 1.2.0 adds -f pigsty.yml, publishing inventory nodes plus all.vars.vm_hosts before VM creation. It replaces the whole Barn block, so a later call without -f drops inventory-only service names. See local service names.
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 only the Barn-owned /etc/hosts block while retaining other entries. It needs no inventory or deployment state. Terminal mode displays a plan and asks; noninteractive/structured mode previews unless --yes is supplied. Removing the block does not delete VMs or change guest DNS configuration.
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
command_root.go · command_access.go · main.go
The version baseline identifies the released source and the changes since 1.1.0.
4 - Image Commands
Refresh signed catalogs, inspect or download images, import local files, and prune caches.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the 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 use local metadata and never update it implicitly. 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 (u24), channel (u24:stable), or numeric version prefix (el9@9). Architecture defaults to native. 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. 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 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 .minisig 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. --yes deletes candidates; it is mutually exclusive with --dry-run. The selected active catalog, applied node base-image digests, and registered local aliases protect their referenced files. Stale recognized staging files can also be removed; quarantined .corrupt-* files remain.
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 version baseline identifies the released source and the changes since 1.1.0.
5 - Repository Commands
Scan, build, and verify static image repositories from repo.yaml and qcow2 artifacts.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the global options.
barn repo scan
Scan one repository root containing repo.yaml and a flat images/ directory. Report tracked, missing, untracked, and unsafe qcow2 files without changing them or requiring qemu-img. Successful scanning exits 0 even with findings; automation must inspect missing and unsafe rather than rely on the exit code alone.
No local options beyond --help; global presentation options still apply.
barn repo build
Validate repo.yaml, inspect the declared qcow2 artifacts with qemu-img, calculate final digests/sizes, and atomically generate catalog.json. Missing or unsafe artifacts fail the build; untracked files are omitted. repo.yaml and image bytes are preserved.
This command does not sign or publish a catalog. Increment the revision for changed contents, keep artifact filenames immutable, and use the separate contributor signing tools before publication. See repository format.
No local options beyond --help; global presentation options still apply.
barn repo verify
Rebuild the expected catalog in memory and require byte-for-byte agreement with the existing catalog.json, using repo.yaml and actual image bytes. Requires qemu-img. It checks repository consistency; detached-signature verification belongs to catalog activation and the signing tools.
No local options beyond --help; global presentation options still apply.
Implementation
The version baseline identifies the released source and the changes since 1.1.0.
6 - Host Network Commands
Inspect, install, and remove the fixed-IP network used by Linux guests.
This reference covers Barn 1.2.0. Option tables distinguish options also available in 1.1.0 from additions in 1.2.0; see the version baseline. All commands inherit the global options.
barn network status
Inspect the one host-wide Linux-guest network: backend, installed CIDR, ownership, health, and lifecycle preflight findings. --cidr checks an expected subnet; omitting it inspects the installed one. It is read-only. This network is separate from each native Mac VM’s private network.
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
Inspect or install the host-wide backend: socket_vmnet on macOS or barn0 through the active Linux network manager. On a terminal it shows a privileged plan and asks; structured/noninteractive calls only preview unless --yes is supplied. On a fresh Mac, use setup to obtain the pinned socket_vmnet archive first.
--archive and --interface-id are macOS-only. host/shared are macOS vmnet modes; Linux rejects shared. An existing network must match the chosen configuration; review status before changing subnet or mode.
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 |
barn network uninstall
Remove only Barn-owned network configuration and restore recorded host settings. Stop running Linux guests first: the operation refuses a live deployment. Terminal mode asks after showing the plan; structured/noninteractive calls preview unless --yes is set. This does not delete VM disks or native Mac networks.
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 version baseline identifies the released source and the changes since 1.1.0.
7 - macOS Commands
Manage named native macOS VMs, desktop access, restore images, and shared bases.
All options below are present in 1.1.0 and the reviewed development tree.
Native macOS VMs require Apple Silicon, macOS 27+, and the matching Barn.app native app bundle, invoked as the logged-in desktop user. Their state lives under $BARN_HOME/mac and is independent of the Linux inventory.
For an optional name, Barn selects the sole existing VM or mac1; multiple VMs without mac1 require an explicit name. configure, recreate, and destroy always require names. start and stop accept multiple names or --all. At most two macOS VMs can run concurrently across apps on the host, including an active base installation. See machine rules, networking, output, and files.
Mac resource sizes use binary units even for GB, unlike Linux inventory decimal GB; a bare Mac size is bytes. These commands ignore Linux BARN_IMAGE/BARN_ARCH/BARN_CPU/BARN_MEM/BARN_SCALE/BARN_DISK overrides.
barn mac ls
Show every machine: its state, address, SSH readiness, macOS version and resources. It reads local records and asks each running machine, and never creates, downloads or starts anything.
Running barn mac without a subcommand also lists machines.
Aliases: list, status, st.
No local options beyond --help; global presentation options still apply.
barn mac up
Create the named machine (mac1 by default), start it, and wait until SSH and passwordless sudo work. Without a prepared macOS base, up first downloads the restore image from Apple after confirmation and installs it once; later machines clone that base.
Creation options apply to a new machine. For an existing machine, up starts it and rejects options that differ from its configuration; use configure for supported setting changes.
--no-wait returns once the VM is running. First-boot provisioning may still be in progress; run barn mac up NAME again to wait for SSH and finish initialization.
| 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
Start existing machines and wait for SSH without creating machines or downloading images. --recovery boots macOS Recovery with its desktop shown.
Select names or --all, not both. Ordinary start requires completed first-boot initialization; use up to finish an uninitialized VM.
| 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
Shut machines down normally through macOS. A machine that has not stopped after two minutes is powered off, and the result says so. --force powers off at once, like holding a 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
Shut a machine down normally and start it again, applying configuration changes.
Accepts at most one name; there is no --all. Omitted names follow the default-machine rule above.
| 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
Change settings of an existing machine without touching its disk or account. CPUs, memory, shared folders and the network change while the machine is stopped; the clipboard setting can change anytime. Saved configuration, including clipboard changes, applies at the next start; use the menu-bar control to toggle clipboard sharing in the current session.
An explicit name is required. Omitted flags retain their values. --share adds or replaces a named share; --unshare removes one.
| 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
Erase the machine’s disk and start a fresh macOS with the same name, account, resources, shared folders and address. --update uses the newest prepared base (see barn mac image update). Its files, apps and settings are lost.
A terminal asks you to type recreate; scripts require --yes or --force, with no -y shorthand.
| 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
Power machines off and delete them: disk, keys, password and settings. The shared macOS base and other machines are kept; barn mac image prune removes unused bases.
Explicit names are required. A terminal asks you to type destroy; scripts require --yes or --force, with no -y. Shared host folders are retained.
| 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
Show the machine’s desktop window, starting the machine first when it is stopped. Closing the window keeps the machine running in the background; the clipboard is shared while the window is focused.
An uninitialized running VM can be viewed here; for a stopped uninitialized VM use mac up NAME --open.
No local options beyond --help; global presentation options still apply.
barn mac ssh
Connect with the machine’s own key and pinned host key. Everything before – must be empty or one known machine name, apart from Barn flags. A remote command requires –, and its first argument must not be empty. For exec, pass the program and its arguments separately to preserve argument boundaries, including later empty values. Use sh -c explicitly for shell expressions. A single command string remains supported as shell shorthand for compatibility. exec requires a command. ssh passes the command line to the remote shell like plain ssh. Without a command, ssh opens an interactive session.
No local options beyond --help; global presentation options still apply.
barn mac exec
Connect with the machine’s own key and pinned host key. Everything before – must be empty or one known machine name, apart from Barn flags. A remote command requires –, and its first argument must not be empty. For exec, pass the program and its arguments separately to preserve argument boundaries, including later empty values. Use sh -c explicitly for shell expressions. A single command string remains supported as shell shorthand for compatibility. exec requires a command. ssh passes the command line to the remote shell like plain ssh. Without a command, ssh opens an interactive session.
No local options beyond --help; global presentation options still apply.
barn mac password
Show the password of the machine’s login account, needed for the lock screen and administrator prompts in its desktop. It 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
Print the OpenSSH fragment that lets ssh, scp, rsync and editors reach each machine by name with its own key and pinned host key. The first machine to become ready installs it 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.
--install and --remove are mutually exclusive. This command takes no machine selectors.
| 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
Show the last lines of the machine’s runtime log: startup, network, shutdown and Apple Virtualization errors.
--lines/-n must be positive and defaults to 100. There is no follow flag; -n means lines, not no-wait.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --lines int |
number of recent lines (default 100) | 1.1.0 |
barn mac setup
Download macOS from Apple after you confirm, or read –ipsw, and install it once into the unbooted base that every machine is cloned from. up does this automatically; setup lets you do it ahead of time.
| Option | Meaning / default | Available in |
|---|---|---|
--disk size |
Base capacity, minimum 32 GiB and default 100 GiB | 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
List restore images and bases with their state, disk usage and the machines that use them.
This local-state query does not invoke the native runner.
Aliases: list.
No local options beyond --help; global presentation options still apply.
barn mac image update
Ask Apple for the newest macOS 27 restore image, download it after you confirm, and install it as the default base for new machines. Existing machines keep their base until barn mac recreate –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
List unused bases except the current default base. --installers also includes downloaded restore images and partial downloads. Deletion requires --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
Check 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.
No local options beyond --help; global presentation options still apply.
Implementation
The version baseline identifies the released source and the changes since 1.1.0.