# Linux Quick Start

> Boot a Debian 13 VM, log in, and grow it into a four-node fixed-IP lab by editing one YAML file.

---

LLMS index: [llms.txt](/v1.5/llms.txt)

---

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](../macos/).

## Before you start {#install}

- [Install Barn](../installation/).
- 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; `sudo` may then ask for your password. For CI and other unattended runs, see [Automation](../automation/).
- In mainland China, add `--mirror` to the first `barn up` to download images from `repo.pigsty.cc`.

## Start a VM {#start}

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.

```bash
mkdir -p ~/barn-lab && cd ~/barn-lab
barn up -I d13
```

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:

```text
ITEM     STATE    MESSAGE
network  planned  prepare 10.10.10.0/24
config   planned  create /home/alice/barn-lab/barn.yml
sudo: network (root-owned barn0 bridge)
Continue with this setup? [Y/n]
```

Barn then downloads and verifies the Debian image, boots the VM, and waits until SSH answers:

```text
NAME  ADDRESS      STATE  MESSAGE
meta  10.10.10.10  ready  SSH ready: barn ssh meta
boot 1/1 nodes: 39s [DONE]
```

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](../troubleshooting/) covers the common cases.

## Log in and look around {#inspect}

```bash
barn ssh
```

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:

```bash
barn status
barn exec meta -- df -h / /data
```

The image version in the status output depends on your active catalog.

```text
NAME  ADDRESS      STATE    IMAGE                SPEC  ROOT
meta  10.10.10.10  running  d13@20261130.2678.1  1c2g  64 GiB
```

| 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](../storage/#what-survives-each-operation) 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](/v1.5/blog/design/one-deployment-no-projects/)).

## Grow it into a four-node lab {#scale}

Open `~/barn-lab/barn.yml`, which the first run wrote, and add three hosts under `nodes`. Use addresses in the same `/24` as `meta`:

```yaml {title="barn.yml"}
all:
  vars:
    admin_ip: 10.10.10.10
    vm_image: d13
  children:
    nodes:
      hosts:
        10.10.10.10: { nodename: meta }
        10.10.10.11: { nodename: node-1 }   # new
        10.10.10.12: { nodename: node-2 }   # new
        10.10.10.13: { nodename: node-3 }   # new
```

Preview the change, then apply it:

```bash
barn plan
barn up
```

`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 |
{.wide}

## Pick the image, size, or subnet {#customize}

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](../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 |
{.wide}

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:

```yaml {title="barn.yml"}
all:
  vars:
    admin_ip: 10.10.10.10
    vm_image: d13
    vm_cpu: 1
    vm_mem: 2GiB
  children:
    nodes:
      hosts:
        10.10.10.10: { nodename: meta }
```

Check the file before booting anything:

```bash
barn validate
barn plan
```

`validate` and `plan` need neither QEMU nor the host network, so you can check an inventory on any machine. [Linux Configuration](../../reference/configuration/) lists every variable, and [image and architecture settings](../../reference/configuration/#image-and-architecture) explains how `-I` and `-A` interact with the file.

## Stop, start, and clean up {#cleanup}

```bash
barn stop      # shut down every node; all disks are kept
barn start     # boot them again
barn destroy   # delete the lab; asks you to type "destroy"
```

`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](../uninstall/).

## Next steps {#next}

- [Daily Operations](../operations/) — Restart nodes, read logs, and apply inventory changes safely.
- [Storage and Access](../storage/) — Add persistent disks, copy files, and reach services in the guest.
- [Images](../images/) — Run Ubuntu, Rocky Linux, other Debian releases, or your own `qcow2`.
- [Automation](../automation/) — Drive Barn from scripts, CI, or Pigsty.
{.cards}
