Daily Operations
7 minute read
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.