Skip to content

Linux Lifecycle

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

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

Choosing a command

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

The full retention rules are in What survives each operation.

Selecting nodes

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

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

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

barn plan

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

barn plan [node...] [flags]

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

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

Aliases: pl.

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

barn up

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

barn up [node...] [flags]

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

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

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

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

barn start

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

barn start [node...] [flags]

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

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

barn stop

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

barn stop [node...] [flags]

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

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

barn restart

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

barn restart [node...] [flags]

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

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

barn reload

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

barn reload [node...] [flags]

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

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

barn resize

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

barn resize [node...] [flags]

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

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

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

barn recreate

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

Warning

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

barn recreate [node...] [flags]

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

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

Aliases: rc.

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

barn status

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

barn status [node...] [flags]

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

Aliases: st.

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

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

barn destroy

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

Warning

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

barn destroy [node...] [flags]

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

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

Aliases: de.

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

barn purge

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

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

Caution

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

barn purge [flags]

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

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

Implementation

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

Table reader