Skip to main content
this section: |

dory - a big memory homelab

blog ~101 m

featured

dory — Family Storage System Setup

  • Version: 3.3
  • Date: November 2026
  • Hostname: dory.local
  • Hardware: Raspberry Pi 5 in Argon ONE M.2 case, 256GB NVMe boot, ORICO 5-bay USB - caddy with 4× Seagate ST4000NM0033 (4TB), 4TB USB daily backup drive
  • Goal: Open Source, mendable, reliable family file sync with daily local backups, with future drive expansion
  • Audience: Anyone tech-savvy enough to follow careful instructions. No prior Linux experience assumed — explanations are inline at first use.

Allow 4–6 hours, and split it across more than one sitting if you like. Each phase ends with a check that tells you where you got to. Disc size barely changes that, because the array is built empty. Loading your existing files comes on top and is set by how much you have: hours per terabyte.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

How to Read This Guide

The guide is sequential. Each phase assumes the previous one passed. The Phase 2 system check should pass before you do anything else.

Names in this guide

Throughout, the machine is dory.local and the administrative account is pi. If you are building a second box, or you gave yours a different name, substitute your own hostname and username wherever those appear — nothing in the guide depends on those particular strings.

Command prompts

Commands are shown exactly as you should type them, with no leading $ or # — those are shell conventions that confuse syntax highlighting and break the copy button.

Commands that need administrator access show sudo explicitly:

1
sudo apt install -y something

Commands that don’t need administrator access show nothing in front:

1
systemctl status syncthing

When you see a command without sudo, run it as your normal user (pi). When you see sudo, the system will ask for your password the first time you use it in a session.

Multi-line file creation

A block like this:

1
2
3
4
sudo tee /etc/somewhere/somefile <<'EOF'
content line 1
content line 2
EOF

creates a file (/etc/somewhere/somefile) with the content between the EOF markers. You can paste the whole thing in one go — bash reads everything up to the closing EOF and pipes it into tee, which writes the file. The sudo is on the tee command, not the content lines.

What to do when something fails

Stop and read the output. Don’t blindly retry. Linux tools usually tell you what’s wrong — Permission denied, No such file, device is busy — if you let them. If you genuinely don’t understand the error, search for it; the answer is almost always on Stack Exchange or the project’s docs.

Linux concepts that come up often

You’ll meet these in nearly every phase:

  • sudo — runs the next command as the system superuser (“root”). Needed for system-wide changes. The pi user can use sudo by default; the system asks for your password the first time you use it in a session.
  • apt — Debian’s package manager. apt install X installs software, apt update refreshes the catalogue, apt upgrade upgrades what’s installed. Always sudo apt.
  • systemd — manages background services (called “units”, “services”, or “daemons” — all mean the same thing here). You interact via systemctl:
    • systemctl status X — show the state and recent log lines
    • systemctl start X / stop X / restart X — manual control
    • sudo systemctl enable --now X — start it now AND make it auto-start at boot
  • journalctl — reads system logs.
    • journalctl -u X -n 100 — last 100 log lines for service X
    • journalctl -u X -f — follow the log live (Ctrl-C to stop)

Filesystem layout you’ll see

  • /etc/ — configuration files
  • /var/log/ — log files
  • /opt/ — third-party / locally-installed software (scripts go here)
  • /mnt/ — where filesystems are mounted; /mnt/raid is the storage array
  • /home/pi/ — your home directory; safe to mess around in
  • /usr/local/bin/ — locally-installed executables (the SeaweedFS weed binary lives here)

References

Where upstream docs are cited, permalinks are used. If a link rots, search the project’s docs site for the page title.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

System Overview

graph TB
    subgraph Pi5["Raspberry Pi 5 (Argon ONE M.2)"]
        OS[Pi OS Desktop 64-bit<br/>NVMe 256GB]
        OS --> CK[Cockpit<br/>:9090]
        OS --> SY[Syncthing<br/>:8384]
        OS --> SW[SeaweedFS native<br/>S3 :8333]
        OS --> SMB[Samba / NFS]
        OS --> VNC[wayvnc desktop<br/>:5900]
        OS --> RAID[Btrfs RAID10]
    end

    subgraph Caddy["ORICO 5-bay caddy (USB 3.0)"]
        D1[Slot 1: 4TB] --> RAID
        D2[Slot 2: 4TB] --> RAID
        D3[Slot 3: 4TB] --> RAID
        D4[Slot 4: 4TB] --> RAID
        D5[Slot 5: empty - future 12TB]
    end

    subgraph Backup["4TB USB drive"]
        BK[LUKS-encrypted Btrfs<br/>daily snapshots]
    end

    RAID -->|nightly btrfs send| BK

    subgraph Net["Network"]
        ETH[Gigabit Ethernet - primary]
        WIFI[WiFi - failover]
    end

    Pi5 --- ETH
    Pi5 -.- WIFI

| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 0 — Hardware Review

Before any software, verify the physical setup. The single biggest cause of trouble in storage systems is hardware that was never quite right to begin with.

0.1 Argon ONE M.2 Case

The Argon ONE M.2 NVMe case combines:

  • An NVMe daughterboard that connects to the Pi’s PCIe lane
  • A controllable fan (PWM, configured via the argononed daemon — Phase 5)
  • A power button on the back of the case with safe-shutdown behaviour
  • An IR receiver (unused here)

Visual check before powering on:

  • The NVMe drive is fully seated in the daughterboard.
  • The fan spins freely (gently nudge with a finger — nothing should rub).
  • The power button on the back of the case clicks.
  • All four case screws are present.

Reference: https://argon40.com/products/argon-one-m-2-case-for-raspberry-pi-4

The Argon ONE M.2 fits the Pi 5 with the same daughterboard but ships in a slightly different SKU; either way, the fan control software is identical.

0.2 ORICO 5-bay Caddy

The caddy needs its own mains power supply — USB cannot deliver enough current to spin up four 7200 RPM enterprise drives simultaneously.

Connection:

  1. Plug the caddy’s mains PSU into the wall first.
  2. Connect the USB 3.0 cable from the caddy to one of the Pi 5’s blue USB-A ports (USB 3.0). The black ports are USB 2.0 and will throttle every drive in the caddy to ~35 MB/s — slow enough to make backups take days instead of hours.
  3. Power the caddy on.

If the caddy has a “RAID mode” jumper or switch, set it to JBOD / single-disc / PM (port multiplier) — anything except hardware RAID. We want each drive to appear individually so Btrfs can manage them itself.

0.3 Drive Labeling

The 4× Seagate ST4000NM0033 drives are physically identical. When one fails (and one will, eventually), you need to know which one to pull. Label every drive before insertion.

Use a silver paint marker (or a printed sticker) on the top metal surface. Write three things:

Slot 1
Installed: 2026-05
Serial: ……XXXX  (last 4 chars of full serial)

The full serial is on the manufacturer’s label on the side of the drive — copy the last four characters somewhere readable once the drive is in the caddy. The matching command-line view is ls /dev/disk/by-id/ (Phase 6.1), where each drive appears as ata-ST4000NM0033-...XXXX.

Map of the caddy:

+---------+---------+
|  Slot 1 |  Slot 2 |
+---------+---------+
|  Slot 3 |  Slot 4 |
+---------+---------+
|  Slot 5 (empty)   |
+-------------------+

Slot 5 is left empty for the future 12TB drive (Phase 11). Do not move drives between slots after labeling.

0.4 Daily Backup Drive (4TB USB)

A separate 4TB USB drive plugs directly into the Pi (not the caddy) for nightly snapshots. Label it:

dory daily backup
LUKS encrypted
Passphrase: family Bitwarden

Plug it into the other blue USB 3.0 port on the Pi (the one not used by the caddy). This keeps the caddy and the backup drive on separate USB controllers and avoids contention.

0.5 Network

Plug Gigabit Ethernet into the Pi’s RJ45 port. WiFi is configured later as failover (Phase 3.4) so the box stays reachable if someone trips on the Ethernet cable.

0.6 Power-on Order

  1. Caddy mains PSU on.
  2. Backup drive on (plug in / power switch).
  3. Pi 5 power on.

This order ensures the drives are spun up and ready before the Pi’s kernel enumerates them. Doing it the other way around occasionally causes drives to be missed at boot.

0.7 Physical First-Boot Check

Pi OS Desktop 64-bit is installed on the NVMe. For this initial session you need a keyboard, mouse, and HDMI monitor plugged directly into the Pi. This is the only time physical access is required — after Phase 1, everything is managed remotely over SSH.

Why Desktop rather than Lite? Pi OS Lite is terminal-only. Using the Desktop edition means the Pi can always be administered from its own screen and keyboard, no matter what state the network is in. It also lets a family member log into Bitwarden from the Pi’s browser to retrieve credentials — the “Bruce-hit-by-bus” scenario. After Phase 1, the Pi is switched to CLI boot so RAM is not wasted on an idle desktop during normal operation; the desktop remains available and can be started manually when needed.

Boot to desktop

Power on and wait. The Pi should boot to the Raspberry Pi OS desktop within about 30 seconds. If a first-boot wizard appears (locale, keyboard, username), work through it. The default user is pi; set a strong password and note it in family Bitwarden under “dory pi user password”.

Verify SSH is enabled

Open a terminal from the desktop (taskbar → Terminal, or right-click desktop → Open Terminal):

1
2
sudo systemctl enable --now ssh
sudo systemctl status ssh

The status line should say active (running). SSH is now confirmed on.

Open Chromium and log into family Bitwarden

Open Chromium (taskbar globe icon or Applications → Internet → Chromium). Navigate to https://vault.bitwarden.com and log into the family Bitwarden group. Verify you can see the shared vault. You’ll come back here in Phase 1.4 to save the SSH key.

Verify network

In the terminal:

1
2
ip -br addr show eth0
ping -c 3 1.1.1.1

eth0 should be UP with an IPv4 address and the ping should succeed. If not, check the Ethernet cable and the router.

Note the Pi’s IP address

1
ip -br addr show eth0

Write down the IPv4 address shown (e.g. 192.168.1.42). You’ll use it from your workstation in Phase 1.6 (SSH) and Phase 1.8 (VNC) if raspberrypi.local doesn’t resolve yet.

After these checks pass, leave the keyboard, mouse, and monitor plugged in — you’ll need them in Phase 1.4 to save the SSH key in Bitwarden, and the monitor again in Phase 1.8 when you turn on VNC, before switching to headless operation.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 1 — SSH First Connection

From this point onward, everything is managed over SSH from your workstation — you type commands on your laptop, they execute on the Pi, output comes back to your screen.

SSH uses a keypair for authentication: a private key you keep secret, and a public key that lives on the Pi. Anything signed by your private key is verified by the public key — that’s how passwordless login works.

The SSH key for dory is stored in the family Bitwarden group so that any family member with Bitwarden access can connect, regardless of which workstation they’re on.

1.1 Generate the family SSH key (on the Pi)

Open a terminal on the Pi’s desktop. Generate the key:

1
ssh-keygen -t ed25519 -C "dory-family-key" -f /tmp/dory-family

Press Enter when asked for a passphrase (no passphrase — the key is protected by Bitwarden instead of a per-key password, which makes it accessible to any authorised family member without coordination).

You now have two files:

  • /tmp/dory-family — the private key (secret; goes into Bitwarden)
  • /tmp/dory-family.pub — the public key (not secret; goes into authorized_keys on the Pi)

1.2 Add the public key to authorized_keys

Still in the Pi terminal:

1
2
3
4
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cat /tmp/dory-family.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

(chmod 600 means only the owner can read or write the file — SSH refuses to use authorized_keys if it’s readable by others.)

1.3 Display the private key for Bitwarden

1
cat /tmp/dory-family

Keep this terminal window open. You’ll copy this output into Bitwarden in the next step.

1.4 Save the private key to family Bitwarden

In Chromium on the Pi’s desktop, go to your family Bitwarden vault and create a new item:

  • Type: SSH Key
    (If SSH Key type is not available in the web vault, use type “Secure Note” and paste the key as the note body. Bitwarden’s desktop app on your workstation will still be able to load it as an SSH key — see 1.6 Method A.)
  • Name: dory SSH key
  • Private key: paste the entire output of cat /tmp/dory-family (including the -----BEGIN...----- and -----END...----- lines)
  • Save

Also save the public key in the same item’s notes or a custom field — you’ll need it again if you ever rebuild the Pi:

1
cat /tmp/dory-family.pub

1.5 Clean up the private key from the Pi

The key now lives in Bitwarden. Remove the temporary copy from the Pi’s filesystem:

1
rm /tmp/dory-family /tmp/dory-family.pub

1.6 Connect from your workstation

You need an SSH client. You probably already have one:

  • macOS and Linux: built in. Open Terminal.
  • Windows 10+: open Windows Terminal or PowerShell. The ssh command is built in.
  • Older Windows: install PuTTY — or upgrade Windows.

Two methods are described below. Method A (Bitwarden SSH Agent) is recommended for day-to-day use and makes the key available on any workstation with Bitwarden installed. Method B (file-based) is the fallback if the Bitwarden desktop app is not available.


Method A — Bitwarden SSH Agent

The Bitwarden desktop app can act as an SSH agent, automatically offering stored keys to SSH connections. This is the preferred method: the key never sits in a file on your workstation’s filesystem, and any family member with Bitwarden access can use it immediately.

  1. Install the Bitwarden desktop app (not just the browser extension) from https://bitwarden.com/download/ . The SSH agent feature is only available in the desktop app.

  2. Open the Bitwarden app, log into the family vault, and unlock it.

  3. Enable the SSH agent: Settings → App Settings → SSH Agent → Enable SSH Agent. Restart the app if prompted.

  4. Confirm the dory SSH key item is visible in the vault. Bitwarden automatically loads all SSH Key type items into the agent when the vault is unlocked.

  5. Test the connection from your workstation terminal:

    1
    
    ssh pi@raspberrypi.local
    

    (Use the Pi’s IP address instead if mDNS doesn’t resolve yet — Phase 0.7 recorded it.)

    The first time, you’ll see a fingerprint prompt — type yes and Enter. Bitwarden may pop up a notification asking whether to allow the SSH key to be used; click Allow. You should land at pi@raspberrypi:~ $ without typing a password.

  6. From here, all subsequent phases use ssh pi@dory.local (after the hostname is set in Phase 3.2).

Reference: https://bitwarden.com/help/ssh-agent/


Method B — File-Based SSH Key

Use this if the Bitwarden desktop app is not installed on the workstation, or as a standalone fallback.

  1. In Bitwarden (browser vault or desktop app), open the dory SSH key item and copy the private key text.

  2. On your workstation, create the key file:

    On macOS / Linux:

    1
    2
    
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
    

    Open a text editor, paste the private key, and save it as ~/.ssh/dory-family. Then:

    1
    
    chmod 600 ~/.ssh/dory-family
    

    On Windows (PowerShell):

    1
    2
    3
    
    New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.ssh"
    # paste the key into Notepad and save as C:\Users\you\.ssh\dory-family
    # no chmod equivalent needed; Windows SSH respects NTFS permissions
    
  3. Add a shortcut to your SSH config so you don’t have to specify the key every time:

    On macOS/Linux, append to ~/.ssh/config (create it if it doesn’t exist):

    Host dory.local
      User pi
      IdentityFile ~/.ssh/dory-family
    
  4. Test:

    1
    
    ssh pi@raspberrypi.local
    

    You should connect without being asked for a password.


1.7 Disable password authentication

Now that the key works, lock the door behind you. Anyone trying to brute-force the pi password over the network will be denied.

Safety-net workflow: keep your current working SSH session open while you do this. Open a second terminal window and SSH in again to verify the key works before you close the original.

On the Pi (via SSH from your workstation, or still in the Pi’s desktop terminal):

1
2
sudo sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart ssh

Open that second terminal and connect:

1
ssh pi@raspberrypi.local

If you connect without prompts, it’s working. Close the original session. If you get “Permission denied (publickey)”, the key isn’t set up correctly — fix it from the still-open original session by re-reading Phase 1.6 carefully.

1.8 Remote desktop with VNC

SSH gives you a terminal. VNC gives you the Pi’s graphical desktop on your workstation’s screen — useful when you need a browser on the Pi itself (the Bitwarden “Bruce-hit-by-bus” scenario), or a GUI tool that has no command-line equivalent, without dragging a keyboard and monitor to the Pi.

Do this now, while the monitor is still attached and the Pi is still booted to the desktop. Section 1.9 switches the Pi to console boot, which changes how VNC behaves — that interaction is explained there.

What’s running: Raspberry Pi OS drives the desktop with Wayland — the compositor is labwc, X11 is gone — and the VNC server it ships is wayvnc. RealVNC’s viewer will not connect to it; Raspberry Pi’s own documentation recommends the TigerVNC viewer, which is what we use below.

1.8.1 Turn on the VNC server (on the Pi)

In a terminal on the Pi’s desktop, or over SSH:

1
sudo raspi-config

Navigate with the arrow keys: Interface Options → VNC → <Yes>. Tab to Finish.

The same change without the menus:

1
sudo raspi-config nonint do_vnc 0

Check the state, and that the server is up and listening on port 5900:

1
2
3
sudo raspi-config nonint get_vnc     # 0 = enabled
systemctl status wayvnc
ss -ltn | grep 5900

systemctl status should say active (running), and ss should show a socket listening on *:5900. (ss -ltn = show listening tCP sockets, numeric ports.)

Worth knowing what that service actually is, because it explains the behaviour in 1.9: wayvnc.service is a system service that runs as the dedicated vnc user and starts wayvnc --detached. Detached means it comes up at boot, listening, whether or not anyone is logged into the desktop, and attaches to a Wayland session if and when one appears.

Its configuration is /etc/wayvnc/config:

use_relative_paths=true
address=::
enable_auth=true
enable_pam=true
private_key_file=tls_key.pem
certificate_file=tls_cert.pem
rsa_private_key_file=rsa_key.pem

In plain terms: listen on every interface (:: is the IPv6 any-address, which also accepts IPv4), require authentication, and do that authentication through PAM — the system’s normal login stack, i.e. real Linux usernames and passwords. The three key files next to it are generated on first boot by wayvnc-generate-keys.service and give the session TLS encryption. You do not need to edit this file.

Set a resolution for when no monitor is attached. With the HDMI cable unplugged, the desktop has no display to size itself against and you can end up with a postage-stamp-sized VNC session. In raspi-config, choose Display Options → D3 VNC Resolution and pick 1920x1080. The alternative — worth the few pounds if you want the Pi to behave identically headless and attached — is an HDMI dummy plug (a “headless display emulator”) left in the Pi’s HDMI port.

1.8.2 Install the TigerVNC viewer (on your workstation)

TigerVNC is a viewer only — nothing is installed on the Pi for this step.

macOS:

1
brew install --cask tigervnc-viewer

Or download the .dmg from https://github.com/TigerVNC/tigervnc/releases . If macOS refuses to open a downloaded build because it’s from an unidentified developer, right-click the app → Open → Open, which allows it once and remembers the choice.

Windows: download vncviewer64-*.exe from https://github.com/TigerVNC/tigervnc/releases . It is a single standalone executable — no installer, no admin rights. Put it somewhere permanent (e.g. C:\Tools\) and make a shortcut.

Linux:

1
sudo apt install tigervnc-viewer

1.8.3 Connect

Start the viewer and enter the Pi’s address with the VNC port:

raspberrypi.local:5900

(Use the IP address you noted in Phase 0.7 if mDNS doesn’t resolve — e.g. 192.168.1.42:5900. After Phase 3.2 renames the Pi, this becomes dory.local:5900.)

Three things happen on a first connection:

  1. A certificate warning. wayvnc encrypts the session with a self-signed certificate generated on the Pi, which no certificate authority has vouched for. On your own LAN this is expected — accept it.
  2. A username and password prompt. This is the Pi’s Linux login: user pi, and the password you set in Phase 0.7 and stored in Bitwarden as dory pi user password — that is what enable_pam=true in 1.8.1 means. It is not the SSH key; VNC authenticates against the system account, which is one more reason password authentication over SSH stays off and VNC stays on the LAN.
  3. The desktop appears, mirroring whatever is on the Pi’s own monitor — the same session, not a second one. Anything you do in VNC is visible on the physical screen and vice versa.

Useful once connected: F8 opens TigerVNC’s menu (full screen, scaling, clipboard transfer, disconnect).

Notes and gotchas:

  • TigerVNC does not save passwords. Every connection asks. That is by design; keep the password in Bitwarden.

  • If the screen is garbled or painfully slow on Windows, open Options → Compression and change Preferred encoding from Tight to Hextile.

  • If the viewer connects but the screen stays black, no desktop session is running on the Pi — see 1.9.

  • Keep VNC on the LAN. Do not forward port 5900 through the router. If you need the desktop from outside the house, tunnel it over SSH instead:

    1
    
    ssh -L 5900:localhost:5900 pi@dory.local
    

    then point the viewer at localhost:5900, which travels inside the SSH connection you have already secured with a key.

1.8.4 Open a terminal inside the GUI session

You now have two different ways to reach a shell on the Pi, and it matters which one you’re in — a program started from an SSH shell has no desktop to draw on, so GUI applications launched there fail with errors like cannot open display.

Inside the VNC window, open a terminal the same way you would sitting at the Pi:

  • the Terminal icon in the taskbar, or
  • right-click the desktop → Open Terminal, or
  • Ctrl+Alt+T — labwc ships that binding (C-A-t in /etc/xdg/labwc/rc.xml), and it launches LXTerminal.

Confirm you really are inside the graphical session and not an SSH shell:

1
2
echo $XDG_SESSION_TYPE
echo $WAYLAND_DISPLAY

Inside the GUI session these print wayland and something like wayland-0. Over SSH the first prints tty and the second is empty.

Test it by launching a GUI application from that terminal — it should appear in the VNC window:

1
chromium https://vault.bitwarden.com &

(The trailing & runs the browser in the background so the terminal stays usable.)

That is the full “no keyboard, no monitor, still have a browser on the Pi” path.

1.9 Switch to CLI boot mode

The desktop was needed for the Bitwarden step. For normal operation as a server, booting to a CLI saves ~300MB of RAM and removes the idle desktop compositing overhead. The desktop remains installed and can be started manually at any time with startx.

Via SSH from your workstation:

1
sudo raspi-config

Navigate with arrow keys: System Options → Boot / Auto Login → Console. Tab to Finish and reboot when prompted.

After reboot, the Pi boots straight to a terminal login — no desktop. SSH still works exactly as before. To start the desktop manually if you need it (e.g. for a Bitwarden browser session during maintenance): plug in keyboard, mouse, and monitor, log in at the console, and run startx.

What this does to VNC. wayvnc attaches to a running desktop session; it does not create one. Booting to console means there is no session to attach to.

The confusing part is that nothing looks broken: because the service runs --detached (1.8.1), it still starts at boot and still listens on 5900, so systemctl status wayvnc reports active (running) and ss shows the socket. A healthy service is therefore not evidence that the desktop is reachable — the viewer connects and finds no desktop to show. The check that actually answers the question is whether a graphical session exists:

1
2
loginctl list-sessions
wlr-randr

A desktop session shows a seat0 entry, and wlr-randr lists an output. Two ways to get one back:

  • Temporarily, over SSH: sudo raspi-config → System Options → Boot / Auto Login → Desktop Autologin, reboot, connect with VNC, and switch back to Console when you’re done. Headless, this needs the resolution setting or dummy plug from 1.8.1.
  • At the Pi: keyboard, mouse, and monitor, log in at the console, run startx. VNC then works again for as long as that session lasts.

If you expect to want the GUI regularly — for family members who need Bitwarden in a browser on the Pi — leave the Pi on Desktop Autologin and accept the ~300MB. On a Pi 5 with 8GB, that trade is a reasonable one to make.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 2 — Pre-Flight System Check

Pi OS Desktop 64-bit is already installed on the NVMe and updated. This phase confirms the basics are sound before installing anything new. Run each command and check the output matches the expected pattern.

2.1 OS and kernel

1
2
cat /etc/os-release
uname -a

Expected: PRETTY_NAME="Raspberry Pi OS ...", kernel version 6.6 or newer, architecture aarch64.

2.2 Boot is from NVMe, not SD

1
findmnt /

(findmnt shows the filesystem mounted at a given path.)

The SOURCE column should show something under /dev/nvme0n1 (typically /dev/nvme0n1p2). If you see /dev/mmcblk0… instead, the Pi is booting from an SD card and the NVMe is being ignored — stop and fix the boot order via sudo raspi-config → Advanced → Boot Order before continuing.

2.3 Throttling and temperature

1
2
sudo vcgencmd get_throttled
sudo vcgencmd measure_temp

get_throttled should print throttled=0x0. Anything else is a bit field, and it is worth decoding rather than panicking — the low bits are happening now, the high bits happened at some point since boot:

BitMeaning
0x1under-voltage right now
0x2Arm frequency capped right now
0x4throttled right now
0x8soft temperature limit active right now
0x10000under-voltage has occurred since boot
0x20000frequency capping has occurred since boot
0x40000throttling has occurred since boot
0x80000soft temperature limit has been hit since boot

So throttled=0x50000 — a real reading from a Pi 5 with a loaded caddy — is 0x10000 + 0x40000: under-voltage and throttling have both happened since boot, but neither is happening now. That is still a power problem worth fixing, just not an emergency mid-command. Anything in the bottom four bits means it is degrading performance as you watch.

Use the official 27W USB-C PSU; cheap chargers are the most common cause. Remember the caddy has its own mains supply (Phase 0.2) — if it is not plugged in, the Pi tries to power four spinning drives through its USB ports and under-voltage is the guaranteed result.

measure_temp at idle should be under 60°C. The Argon fan is not yet configured, so 60–70°C at idle is acceptable for now and will improve in Phase 5.

2.4 NVMe health

1
2
sudo apt install -y smartmontools
sudo smartctl -a /dev/nvme0n1 | grep -E "Model|Health|Temperature|Percentage Used|Available Spare"

Look for SMART overall-health self-assessment test result: PASSED. Percentage Used is the controller’s own estimate of NVMe wear; a freshly installed drive should be at 0–1%.

2.5 Network — Ethernet

1
2
3
ip -br addr show eth0
ping -c 3 1.1.1.1
ping -c 3 raspberrypi.com

eth0 should be UP with an IPv4 address. The two pings test raw connectivity (1.1.1.1 is Cloudflare’s resolver) and DNS resolution respectively. If the second fails but the first succeeds, DNS is broken — usually a router/DHCP issue.

2.6 USB enumeration

The caddy and backup drive are connected (Phase 0) but unformatted, so they show up as devices but not as filesystems.

1
lsblk -o NAME,SIZE,TYPE,TRAN,MODEL

(lsblk lists block devices — disks, partitions, etc. The columns ask for device name, size, type, transport (USB/NVMe/SATA/etc.), and model.)

Expected output, before anything has been formatted:

NAME          SIZE TYPE TRAN   MODEL
loop0           2G loop
zram0           2G disk
sda           3.6T disk usb    ST4000NM0033-9ZM170
sdb           3.6T disk usb    ST4000NM0033-9ZM170
sdc           3.6T disk usb    ST4000NM0033-9ZM170
sdd           3.6T disk usb    ST4000NM0033-9ZM170
sde           3.6T disk usb    <backup drive model>
nvme0n1     238.5G disk nvme   THNSN5256GPUK NVMe TOSHIBA 256GB
├─nvme0n1p1   512M part nvme
└─nvme0n1p2   238G part nvme

You should see all four caddy drives plus the backup drive, all on the usb transport. If a caddy drive is missing, it is almost always a power issue with the caddy — recheck the caddy PSU.

Four things in that output surprise people:

  • The 4TB drives say 3.6T. Nothing is missing. Drive manufacturers sell in decimal terabytes (4,000,000,000,000 bytes); lsblk reports in binary ones (1T = 2⁴⁰ bytes). 4 × 10¹² ÷ 2⁴⁰ ≈ 3.64. Likewise the “256GB” NVMe shows as 238.5G.
  • loop0 and zram0 are not disks. A loop device is a file being presented as a block device, and zram0 is compressed swap living in RAM. Both are normal; ignore them here and everywhere else in this guide.
  • The NVMe already has two partitions — a small boot partition and the root filesystem. That’s the OS disk you are running from, exactly as it should be.
  • The caddy drives have no partition lines yet. If yours do, those drives carry data from a previous life; Phase 6.2 wipes them deliberately, so check them before you get there.

The listing order is not slot order, and it is not stable either: the kernel device names (sda, sdb, …) can change between boots if you unplug things. From Phase 6 onward we use stable names from /dev/disk/by-id/ instead.

The obvious command here is to read every USB device’s speed:

1
for d in /sys/bus/usb/devices/*/speed; do echo "$d: $(cat $d 2>/dev/null)"; done | grep -v ': $'

It works, but it answers the wrong question. It lists every USB device — keyboards, mice, audio adapters, root hubs — with no indication of which entry is a disk:

/sys/bus/usb/devices/1-1.4/speed: 12
/sys/bus/usb/devices/2-2/speed: 12
/sys/bus/usb/devices/4-2/speed: 1.5
/sys/bus/usb/devices/5-1/speed: 5000
/sys/bus/usb/devices/usb3/speed: 5000

A keyboard reporting 1.5 or 12 is perfectly healthy; only the storage devices need to be at 5000. So walk the other way — start from each disk and find the USB device it hangs off:

1
2
3
4
5
6
7
for dev in /sys/block/sd*; do
  disk=$(basename "$dev")
  p=$(readlink -f "$dev/device")
  while [ "$p" != "/" ] && [ ! -e "$p/speed" ]; do p=$(dirname "$p"); done
  printf '%-5s port %-6s %6s Mb/s  %s\n' \
    "$disk" "$(basename "$p")" "$(cat "$p/speed" 2>/dev/null)" "$(cat "$p/product" 2>/dev/null)"
done

(Each disk in /sys/block/ links to its controller deep in the device tree. The loop climbs up parent directories until it finds one with a speed file — that directory is the USB device the disk is plugged into.)

Expected:

sda   port 5-1      5000 Mb/s  External USB 3.0
sdb   port 5-1      5000 Mb/s  External USB 3.0
sdc   port 5-1      5000 Mb/s  External USB 3.0
sdd   port 5-1      5000 Mb/s  External USB 3.0
sde   port 3-1      5000 Mb/s  <backup drive>

Every storage line must say 5000. Anything reporting 480 is on a USB 2.0 port (a black one) — move it to a blue port now, not after the system is in production.

Why all four caddy drives share one port. 5-1 means bus 5, port 1, and all four report it because the caddy is a single USB device — a JMicron SATA bridge in port-multiplier mode — presenting four drives down one cable. There is no per-drive USB port to find. The backup drive, plugged straight into the Pi, gets a port of its own on a different bus.

Which bay is which, then? Not the port — the SCSI LUN:

1
lsblk -d -o NAME,HCTL,SIZE,TRAN,MODEL,SERIAL
NAME    HCTL         SIZE TRAN   MODEL                 SERIAL
sda     0:0:0:0      3.6T usb    ST4000NM0033-9ZM170   S1Z2B61Z
sdb     0:0:0:1      3.6T usb    ST4000NM0033-9ZM170   S1Z2B5ZW
sdc     0:0:0:2      3.6T usb    ST4000NM0033-9ZM170   S1Z2B5R4
sdd     0:0:0:3      3.6T usb    ST4000NM0033-9ZM170   S1Z2B5RW

HCTL is Host:Channel:Target:LUN, and the last number is the caddy bay the bridge reports — LUN 0 through 3 for bays 1 through 4. Unlike sda/sdb, that ordering comes from the caddy hardware rather than the order the kernel happened to spot things, so it is stable across reboots.

Check it once against physical reality: compare the SERIAL column with the labels you wrote in Phase 0.3. If sda’s serial is the drive you labelled bay 1, the mapping holds and you can trust it when a drive fails later. If you didn’t label them, or the mapping looks wrong, identify a drive by making it work — run sudo dd if=/dev/sda of=/dev/null bs=1M count=2000 and watch which bay’s activity LED lights up.

That serial is also why replacing a failed drive is safe: those same serials appear in /dev/disk/by-id/ as ata-ST4000NM0033-9ZM170_S1Z2B61Z, which is what Phase 6.1 uses instead of the shifting sdX names.

2.8 Internet bandwidth

Bandwidth limits how often you can do large cloud backups, so it’s worth knowing:

1
2
sudo apt install -y speedtest-cli
speedtest-cli --simple

Note the upload number — it determines how long large cloud backups take.

2.9 Available disk space on NVMe

1
df -h /

You want at least 50GB free. Almost everything we install lives on the RAID, but the NVMe holds container images, logs, and the LUKS keyfile.

2.10 What state are the caddy drives in?

Phase 6 destroys everything on the four caddy drives. Before you get there, find out what is on them — the answer decides whether you carry on through the guide or stop and take a different route entirely.

1
lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS

FSTYPE and LABEL are the interesting columns: a filesystem type means something has been written to that drive, and a label usually says what wrote it.

Then ask wipefs what signatures it can see:

1
for d in /dev/sd[a-d]; do echo "--- $d"; sudo wipefs -n "$d"; done

The -n is important: it is a dry run. wipefs prints the signatures it would erase and changes nothing. (Without -n it erases them, which is what Phase 6.2 does deliberately.)

Your drives are in one of three states.

State 1 — bare. No FSTYPE, no LABEL, and wipefs -n prints nothing at all:

sda           3.6T
sdb           3.6T
sdc           3.6T
sdd           3.6T

New drives out of the box. Nothing to do — carry on.

State 2 — dirty. Partitions, filesystems, or stray signatures from a previous life. This is what a set of second-hand drives that once held a ZFS pool looks like:

sda           3.6T
├─sda1        3.6T zfs_member  dory-pool
└─sda9          8M
DEVICE OFFSET        TYPE UUID LABEL
sda    0x200         gpt
sda    0x3a3817d5e00 gpt
sda    0x1fe         PMBR

Reformatting will be required. States 1 and 2 both end up in the same place — Phase 6.2 wipes every signature and Phase 6.3 builds the Btrfs RAID10 from scratch — but state 2 deserves a pause first. Those old labels are your only clue to what the drives used to be, and once Phase 6.2 runs, everything on them is gone with no undo. Read the labels, satisfy yourself that nothing on those drives is wanted by anyone, and only then continue. A leftover pool name from a machine you retired years ago is fine; a label you half-recognise is worth ten minutes with the drive on another computer.

State 3 — a working store in a new Pi. All four drives show btrfs with the label krustyraid:

sda           3.6T btrfs       krustyraid
sdb           3.6T btrfs       krustyraid
sdc           3.6T btrfs       krustyraid
sdd           3.6T btrfs       krustyraid

This is a previous dory’s RAID10 — the family’s files are almost certainly still on it, and you are rebuilding around it because the Pi died, not the drives. Do not run Phase 6. Skip to recovering a crashed store , which mounts the existing array instead of creating a new one.

The one ambiguous case is a partial state 3: two drives labelled krustyraid and two bare, or two dirty. That means an array that lost members. It is still a recovery job, not a fresh build — go to recovering a crashed store and do not format anything until you have read it.

A caveat on tooling: btrfs filesystem show would answer this more directly, but btrfs-progs is not installed until Phase 3.3, so at this point lsblk and wipefs are what you have. Once Phase 3 is done you can confirm with:

1
sudo btrfs filesystem show

If all checks pass, proceed.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 3 — Base System Preparation

3.1 Update once more

1
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y

(&& chains commands so each only runs if the previous one succeeded. autoremove cleans up packages that were installed as dependencies but are no longer needed.)

3.2 Set hostname to dory

Check the Pi’s hostname in case it’s not what you expect

1
2
# Check the current hostname
sudo hostnamectl status

I the Pi needs renaming it, e.g. to dory:

1
2
3
# Check the current hostname
sudo hostnamectl set-hostname dory
sudo sed -i 's/127\.0\.1\.1.*/127.0.1.1\tdory/' /etc/hosts

Log out (exit) and SSH back in as pi@dory.local. The shell prompt should now say pi@dory.

3.3 Install base packages

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sudo apt install -y \
    btrfs-progs \
    smartmontools \
    hdparm \
    samba samba-common-bin \
    nfs-kernel-server \
    podman \
    cryptsetup \
    rsync rclone \
    htop tmux vim git curl wget jq tree \
    avahi-daemon \
    unattended-upgrades apt-listchanges

Notes on choices:

  • podman rather than docker for the few things that get containerised. (Currently nothing in this base setup, but the tooling is in place.)
  • avahi-daemon makes dory.local resolvable on the LAN via mDNS, so family devices don’t need to know IP addresses.
  • unattended-upgrades applies security patches automatically every night.
  • htop is a friendlier process viewer; tmux lets long-running commands survive disconnects; tree shows directory structure visually. None are strictly necessary but you’ll want them within a week.

3.4 Configure WiFi as Ethernet failover

Pi OS Desktop uses NetworkManager. We configure both connections, set Ethernet as preferred, and let NetworkManager handle the failover automatically.

First, see what already exists. If you set up WiFi in Raspberry Pi Imager or during the first-boot wizard, the connection is already there and you only need the priority step below:

1
nmcli -f NAME,TYPE,DEVICE,ACTIVE connection show
NAME                     TYPE      DEVICE  ACTIVE
netplan-eth0             ethernet  eth0    yes
netplan-wlan0-sloth-net  wifi      wlan0   yes
lo                       loopback  lo      yes

Write down the exact names in the first column. They are not predictable — depending on how the Pi was set up you may see Wired connection 1, preconfigured, or netplan-eth0 as above. Every command below refers to connections by these names, so substitute your own.

Add the WiFi connection (skip this if it is already listed). The obvious one-liner is:

1
sudo nmcli device wifi connect YOUR_SSID password 'YOUR_PSK'

That works on a stock NetworkManager setup, but on a Pi where NetworkManager stores its profiles through netplan — which you can spot by netplan-* connection names, an empty /etc/NetworkManager/system-connections/, and files in /etc/netplan/90-NM-*.yaml — it fails like this:

Error: 802-11-wireless-security.key-mgmt: property is missing.

The one-liner leaves NetworkManager to infer the security type from the scan, and that inference is lost in the netplan round-trip. Spell the security out instead, which works on both kinds of system:

1
2
3
4
5
6
sudo nmcli connection add type wifi ifname wlan0 \
    con-name YOUR_SSID \
    ssid YOUR_SSID \
    wifi-sec.key-mgmt wpa-psk \
    wifi-sec.psk 'YOUR_PSK' \
    connection.autoconnect yes

wifi-sec.key-mgmt wpa-psk is precisely the property the error complained about. Use single quotes around the passphrase — without them, spaces split it into separate arguments and any $, ! or " is mangled by the shell before nmcli ever sees it.

Confirm it came up:

1
nmcli -f NAME,TYPE,DEVICE,ACTIVE connection show

Set priorities. Higher number wins — use the names from the first column, not the SSID:

1
2
sudo nmcli connection modify "netplan-eth0" connection.autoconnect-priority 100
sudo nmcli connection modify "netplan-wlan0-sloth-net" connection.autoconnect-priority 10

Verify:

1
2
nmcli connection show --active
ip route show default

The default route should be via eth0. If you can, unplug the Ethernet cable briefly and watch it switch to wlan0, then plug back in and watch it switch back. That’s the only test that matters.

Reference: https://networkmanager.dev/docs/api/latest/nm-settings-nmcli.html

3.5 Enable unattended security upgrades

1
sudo dpkg-reconfigure -plow unattended-upgrades

Choose Yes. The defaults install security updates automatically and email root on failure (which goes nowhere by default — the fact that the box still boots is the main signal).


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 4 — Cockpit

Cockpit is the web dashboard. It handles storage, services, networking, logs, software updates, container management, and a terminal — all from a browser. Non-technical family members can use it without learning the command line, and you can use it instead of SSH for most maintenance.

Cockpit runs natively, not in a container. Its job is to manage the host (systemd, block devices, networking, package manager, user accounts), and doing that from inside a container would require so many privilege grants and namespace shares that you’d end up with a “container” with full host root anyway. Native install is simpler, more reliable, and the upstream-recommended deployment for Debian-family systems.

4.1 Install

1
2
3
4
5
6
sudo apt install -y \
    cockpit \
    cockpit-storaged \
    cockpit-networkmanager \
    cockpit-packagekit \
    cockpit-podman

The packages: cockpit-storaged adds Btrfs and LUKS support to the Storage panel; cockpit-networkmanager exposes the Ethernet/WiFi failover config from Phase 3.4; cockpit-packagekit shows available updates; cockpit-podman lets you manage containers from the dashboard.

4.2 Enable

1
sudo systemctl enable --now cockpit.socket

4.3 Access

From any browser on the LAN: https://dory.local:9090

Accept the self-signed certificate warning — it’s expected. The browser warns because the certificate isn’t signed by a public authority; on a home LAN that’s fine. Log in with your pi user credentials.

The first thing to bookmark is the Storage page. It will show the NVMe and the four caddy drives once Phase 6 completes.

Reference: https://cockpit-project.org/documentation.html

4.4 Cockpit users for the family

Each family member who needs access gets a Linux account, and Cockpit reuses those accounts:

1
2
sudo adduser alice
sudo adduser bob

(adduser is interactive — it prompts for the new user’s password and a few optional name fields.)

For Cockpit access, that’s all you need. The account works for SSH and Samba too (Phase 9).

To give a family member admin access (so they can restart services in Cockpit):

1
sudo usermod -aG sudo alice

(-aG means “append to group”, so existing groups are preserved. Without this, Cockpit shows them everything in read-only mode.)


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 5 — Argon ONE Fan Control

Without the fan daemon, the fan runs at 100% all the time (loud) or not at all (hot). The official daemon installs a small service that reads CPU temperature and adjusts fan speed using a configurable curve.

5.1 Install argononed

The vendor distributes the install script via their CDN. Always inspect a script before running it as root, even from a known vendor — this is general hygiene:

1
2
3
curl -sSL https://download.argon40.com/argon1.sh -o /tmp/argon1.sh
less /tmp/argon1.sh
sudo bash /tmp/argon1.sh

(less shows the file one page at a time; press q to quit. The script installs systemd services, a configuration tool, and a shutdown integration that wires the case power button to a clean shutdown -h now.)

5.2 Configure the fan curve

1
sudo argonone-config

Reasonable defaults for a storage server:

  • Below 55°C: fan off
  • 55–65°C: 30% (audible but not annoying)
  • 65–75°C: 60%
  • Above 75°C: 100%

The Pi 5 will sit around 50–60°C under storage load with these settings.

5.3 Verify

1
2
sudo vcgencmd measure_temp
systemctl status argononed

vcgencmd needs sudo. It talks to the firmware through /dev/vcio, which is mode 600 and owned by root:root — being in the video group does not help, whatever older Pi guides say. Without sudo you get:

Can't open device file: /dev/vcio_gencmd

The service should be active (running). To watch the temperature while the system works, force some I/O with find / 2>/dev/null > /dev/null and watch the fan respond. Rather than watch sudo …, read the same sensors without root:

1
watch -n 2 sensors

cpu_thermal is the temperature the fan curve reacts to, and pwmfan shows the fan’s RPM and duty cycle changing as it climbs — you should see it kick in around 55°C. (Ctrl-C exits watch. lm-sensors comes from 5.4 below; watch -n 2 cat /sys/class/thermal/thermal_zone0/temp works without it, in thousandths of a degree.)

Reference: https://argon40.com/blogs/argon-blog/getting-started-with-argon-one-raspberry-pi-4-case

5.4 Cockpit plugin

There is no first-party Argon Cockpit plugin at the time of writing. Fan curve changes are made via sudo argonone-config over SSH or in the Cockpit terminal. CPU temperature is visible via the standard Cockpit “Sensors” page once lm-sensors is installed:

1
2
sudo apt install -y lm-sensors
sensors

Do not run sensors-detect on a Pi. Every guide written for x86 tells you to, and on Arm it fails like this:

modprobe: FATAL: Module cpuid not found in directory /lib/modules/6.12.75+rpt-rpi-2712

Nothing is broken and the Pi is fine. sensors-detect probes for x86 hardware — it walks the ISA and SMBus buses and loads cpuid and msr, kernel modules that expose x86-only CPU instructions. There is no cpuid instruction on Arm, so there is no module to load, and /lib/modules/…/kernel/arch/ on this machine contains exactly one entry: arm64.

The probing is also unnecessary. On a Pi the sensors are described in the device tree and their drivers load automatically at boot, so sensors works the moment the package is installed:

rp1_adc-isa-c8000
Adapter: ISA adapter
in1:           1.49 V
in2:           2.44 V
in3:           1.38 V
in4:           1.41 V
temp1:        +49.7°C

pwmfan-isa-000c
Adapter: ISA adapter
fan1:        3011 RPM
pwm1:             38%  MANUAL CONTROL

cpu_thermal-virtual-0
Adapter: Virtual device
temp1:        +55.6°C

rpi_volt-isa-0000
Adapter: ISA adapter
in0:              N/A

nvme-pci-10100
Adapter: PCI adapter
Composite:    +45.9°C  (low  = -20.1°C, high = +84.8°C)
                       (crit = +81.8°C)
Sensor 1:     +45.9°C  (low  = -20.1°C, high = +84.8°C)

That is more than the fan service alone gives you: cpu_thermal is the SoC, pwmfan is the Argon fan reporting real RPM and duty cycle, nvme is the boot drive’s own thermal sensor, and rp1_adc is the Pi 5’s I/O controller. Cockpit’s Sensors page reads the same hwmon devices.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 6 — Btrfs RAID10 across 4 Drives

This phase formats the four caddy drives. It is destructive — anything on those drives is erased. Read every command before running it.

A short orientation on Btrfs concepts:

  • Filesystem: the on-disk structure that organises files. Btrfs is a modern Linux filesystem with built-in RAID, snapshots, compression, and checksums.
  • RAID10: data is striped across mirrored pairs of drives. With 4 drives you can lose one drive per mirror pair and the array survives. Half of total raw capacity is usable.
  • Subvolume: a lightweight independent section of a Btrfs filesystem. Like a directory, but you can snapshot it, set quotas on it, and mount it separately.
  • Snapshot: a frozen-in-time view of a subvolume. Btrfs uses copy-on-write so a snapshot costs near zero space at creation; it grows only as the live data diverges.

6.1 Identify drives by serial number

/dev/sda, /dev/sdb, etc., can change order between boots. Stable IDs do not:

1
ls -l /dev/disk/by-id/ | grep -E 'ata-ST4000NM0033' | grep -v part

Expected output (one line per drive):

... ata-ST4000NM0033-..._XXXX -> ../../sda
... ata-ST4000NM0033-..._YYYY -> ../../sdb
... ata-ST4000NM0033-..._ZZZZ -> ../../sdc
... ata-ST4000NM0033-..._AAAA -> ../../sdd

Cross-check the four-character suffixes against the stickers from Phase 0.3. If any drive’s label has no matching entry here, the slot is dead — investigate before proceeding.

Capture the four IDs as shell variables (shell variables only live in the current session):

1
2
3
4
DRIVE1=/dev/disk/by-id/ata-ST4000NM0033-XXXXXX_XXXX  # slot 1
DRIVE2=/dev/disk/by-id/ata-ST4000NM0033-YYYYYY_YYYY  # slot 2
DRIVE3=/dev/disk/by-id/ata-ST4000NM0033-ZZZZZZ_ZZZZ  # slot 3
DRIVE4=/dev/disk/by-id/ata-ST4000NM0033-AAAAAA_AAAA  # slot 4

(Those serials are placeholders — substitute your own.)

Check all four before you go any further:

1
2
3
4
5
for v in DRIVE1 DRIVE2 DRIVE3 DRIVE4; do
  p=${!v}
  if [ -b "$p" ]; then echo "$v  OK   $p -> /dev/$(basename $(readlink -f $p))"
  else echo "$v  BAD  '${p:-<unset>}'"; fi
done

You want four OK lines pointing at four different devices:

DRIVE1  OK   /dev/disk/by-id/ata-ST4000NM0033-9ZM170_S1Z2B5RW -> /dev/sda
DRIVE2  OK   /dev/disk/by-id/ata-ST4000NM0033-9ZM170_S1Z2B61Z -> /dev/sdb
DRIVE3  OK   /dev/disk/by-id/ata-ST4000NM0033-9ZM170_S1Z2B5R4 -> /dev/sdd
DRIVE4  BAD  '<unset>'

That fourth line is the failure this check exists to catch. A typo’d or unset variable expands to nothing — the shell simply drops it, so wipefs quietly skips a drive and mkfs.btrfs builds the array from three devices instead of four, without ever complaining. You find out much later, when a drive fails and there is no mirror to recover from. (${!v} is bash’s indirect expansion: the value of the variable named by $v.)

Fix any BAD line before continuing.

6.2 Wipe (destructive)

First do a dry run to be sure it’s going to work

1
sudo wipefs -a -n $DRIVE1 $DRIVE2 $DRIVE3 $DRIVE4 #dry run

Now wipe the discs if you’re happy

1
sudo wipefs -a $DRIVE1 $DRIVE2 $DRIVE3 $DRIVE4

(wipefs -a removes any existing filesystem signatures from a block device. After this, the drives appear blank to the kernel.)

Confirm it worked — FSTYPE and LABEL should now be empty for all four, with no partition rows underneath:

1
lsblk -o NAME,SIZE,FSTYPE,LABEL

If a drive still shows partitions (common with ex-ZFS drives, which leave a GPT plus an 8MB partition 9), the signatures inside those partitions survived. Wipe the partitions as well, then the disk again:

1
2
sudo wipefs -a ${DRIVE1}-part1 ${DRIVE1}-part9   # adjust to what lsblk shows
sudo wipefs -a $DRIVE1

6.3 Create RAID10

1
sudo mkfs.btrfs -L krustyraid -d raid10 -m raid10 $DRIVE1 $DRIVE2 $DRIVE3 $DRIVE4

What this means:

  • -L krustyraid — filesystem label, used in /etc/fstab.
  • -d raid10 — data uses RAID10: striped across mirror pairs.
  • -m raid10 — same for metadata.

Usable capacity with 4× 4TB in RAID10 is ~8TB.

Check the summary it prints. Two lines matter:

Number of devices:  4
Filesystem size:    14.55TiB

If it says Number of devices: 3, one of your $DRIVE variables was empty — the array is short a drive. Nothing is lost at this stage: sudo wipefs -a the devices and start 6.1 again with the check in place.

About the page size warning. On a Pi 5 you will see this, and it is not a problem:

WARNING: sectorsize 4096 does not match host CPU page size 16384, with kernels 6.x and up
	 the 4KiB sectorsize is supported on all architectures but other combinations
	 may fail the filesystem mount, use "--sectorsize 16384" to override that

Pi OS on the Pi 5 runs a 16KiB-page kernel, while mkfs.btrfs has defaulted to a 4KiB sector size since btrfs-progs 6.7. Modern kernels handle that mismatch through btrfs’s subpage support, so the filesystem mounts and runs normally — getconf PAGESIZE will confirm your page size is 16384.

Do not take the --sectorsize 16384 suggestion. A 16KiB-sector filesystem can only be mounted by a kernel running with 16KiB pages. That trades away the thing this whole design exists to protect: if the Pi dies, you want to be able to plug the caddy into an x86 desktop, a different Pi, or a rescue USB stick and read the family’s files. Those all run 4KiB pages and would refuse to mount it. Keeping the 4KiB default costs nothing and keeps the array portable — see Appendix D.

The one real trade-off is compression: in subpage mode btrfs only compresses fully page-aligned ranges, so some small writes go uncompressed under the compress=zstd:3 mount option in 6.4. That affects space efficiency slightly, never correctness.

Reference: https://btrfs.readthedocs.io/en/latest/Subpage.html

Reference: https://btrfs.readthedocs.io/en/latest/mkfs.btrfs.html

6.4 Mount and add to fstab

/etc/fstab lists filesystems to mount at boot. We need the filesystem UUID:

1
sudo blkid $DRIVE1 -s UUID -o value

Copy the UUID. Create the mount point and update fstab:

1
2
3
4
5
6
sudo mkdir -p /mnt/raid
sudo chattr +i /mnt/raid
echo "UUID=<paste-the-uuid> /mnt/raid btrfs defaults,noatime,compress=zstd:3,autodefrag,nofail,x-systemd.device-timeout=90s 0 0" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo mount /mnt/raid
df -h /mnt/raid

(The echo | sudo tee -a pattern is used because a plain >> redirect runs before sudo takes effect, so it would fail with “Permission denied”. tee -a appends as root.)

Why chattr +i on an empty directory. /mnt/raid is a real directory on the NVMe; the array is mounted on top of it. If the array ever fails to mount, anything that writes to /mnt/raid/... would quietly write to the NVMe instead — a fresh, empty SeaweedFS store, a Samba share with nothing in it. +i (immutable) makes the bare directory unwritable, even by root, so those writes fail loudly instead. It does not affect the mounted array at all. Check it with lsattr -d /mnt/raid while the array is unmounted: the flags column shows an i.

Why nofail and the timeout — the boot lock. Without nofail, a failed mount stops the boot in emergency mode. That happens more easily than it sounds: the caddy’s drives spin up slowly over USB, or one drive has died and Btrfs refuses to mount an array with a member missing. With no monitor attached, a Pi in emergency mode looks exactly like a dead Pi. nofail lets the boot carry on to SSH, so you can log in and see what is wrong; x-systemd.device-timeout=90s gives slow USB drives a fair chance before it gives up.

Do not add degraded to this line, tempting as it is. It would let the array mount with a drive missing and carry on as if nothing had happened, with no redundancy, until the next drive fails. Mounting degraded is a deliberate act during recovery ( recovering a crashed store , D.4), never a default. Phases 8 and 9 make sure nothing starts serving files while the array is not mounted.

Built dory from an earlier version of this guide? Add nofail,x-systemd.device-timeout=90s to the existing /mnt/raid line with sudo nano /etc/fstab, then daemon-reload and findmnt --verify as below. For chattr, the array must be unmounted first — on a mounted array, chattr +i /mnt/raid would freeze the array’s own top directory instead of the bare mount point beneath it:

1
2
3
4
5
6
sudo systemctl stop seaweedfs-s3 seaweedfs-filer seaweedfs-volume seaweedfs-master smbd nfs-server backup-daily.timer btrfs-scrub.timer
systemctl --user stop syncthing
sudo umount /mnt/raid
sudo chattr +i /mnt/raid && lsattr -d /mnt/raid
sudo mount /mnt/raid
sudo reboot

Then add the guards from 8.3 (the RequiresMountsFor line in each SeaweedFS unit), 9.5 and 10.10. The reboot brings every service back in the right order.

Why the daemon-reload. systemd does not read /etc/fstab directly at mount time — a generator turns each line into a .mount unit when systemd starts, and those units are what actually run. Edit fstab and systemd is still working from the version it read at boot. Skip the reload and the mount succeeds anyway, but with a warning:

mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

systemctl daemon-reload re-runs the generators so systemd’s view matches the file. It is harmless to run at any time, and worth doing after every fstab edit in this guide.

Check fstab before you reboot. A malformed entry can leave the Pi stuck in emergency mode at boot — with no monitor attached, that looks identical to a dead Pi:

1
sudo findmnt --verify
0 parse errors, 0 errors, 0 warnings

Warnings here are your last chance to fix a typo cheaply. (If you have not done the daemon-reload yet, this is where the same hint shows up as 1 warning.)

Mount option choices:

  • noatime — don’t update file access times on every read; large write reduction.
  • compress=zstd:3 — transparent compression, level 3 (good ratio, low CPU cost).
  • autodefrag — opportunistic background defragmentation; useful for mixed workloads.

6.5 Subvolume layout

1
2
3
4
5
6
sudo btrfs subvolume create /mnt/raid/family-data
sudo btrfs subvolume create /mnt/raid/seaweedfs-store
sudo btrfs subvolume create /mnt/raid/snapshots

sudo chown -R pi:pi /mnt/raid/family-data /mnt/raid/seaweedfs-store
sudo mkdir -p /mnt/raid/family-data/{phones,computers,tablets,iot-configs,shared}

(chown -R user:group path changes ownership recursively. The {a,b,c} brace expansion in the last line creates all five directories in one shot.)

6.6 2TB quota on the SeaweedFS store

1
2
3
sudo btrfs quota enable /mnt/raid
sudo btrfs qgroup limit 2T /mnt/raid/seaweedfs-store
sudo btrfs qgroup show -re /mnt/raid

6.7 Monthly scrub

A scrub reads every block and verifies its checksum, repairing from the redundant copy if a block is bad — the way to catch silent disk corruption before it spreads.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sudo tee /etc/systemd/system/btrfs-scrub.service <<'EOF'
[Unit]
Description=Btrfs scrub on /mnt/raid
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/usr/bin/btrfs scrub start -B /mnt/raid
EOF

sudo tee /etc/systemd/system/btrfs-scrub.timer <<'EOF'
[Unit]
Description=Run Btrfs scrub monthly

[Timer]
OnCalendar=monthly
Persistent=true

[Install]
WantedBy=timers.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now btrfs-scrub.timer

(A systemd timer is a scheduled trigger — like cron, but integrated with the rest of systemd. The .timer unit triggers the matching .service unit on schedule.)

Verify and run once now:

1
2
3
systemctl list-timers btrfs-scrub.timer
sudo systemctl start btrfs-scrub.service
sudo btrfs scrub status /mnt/raid

Reference: https://btrfs.readthedocs.io/en/latest/Scrub.html


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 7 — Syncthing

7.1 Install from upstream repo

The upstream Syncthing repo is more current than the Pi OS packages and signed by the project itself:

1
2
3
4
5
6
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://syncthing.net/release-key.gpg \
    | sudo tee /etc/apt/keyrings/syncthing-archive-keyring.asc > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.asc] https://apt.syncthing.net/ syncthing stable" \
    | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt update && sudo apt install -y syncthing

(That sequence: download the project’s signing key, register a new package source that uses it, refresh the catalogue, install.)

Reference: https://apt.syncthing.net/

7.2 Run as a user service

Syncthing should run as the pi user, not root. systemd user services handle exactly this:

1
2
systemctl --user enable --now syncthing.service
sudo loginctl enable-linger pi

(enable-linger means user services keep running even when pi is not logged in — necessary for a server.)

7.3 Expose the GUI on the LAN

By default Syncthing only listens on 127.0.0.1:8384 (localhost — only reachable from the Pi itself). Confirm that, and change it, through Syncthing’s own CLI:

1
2
3
syncthing cli config gui raw-address get
syncthing cli config gui raw-address set 0.0.0.0:8384
systemctl --user restart syncthing

The first command should print 127.0.0.1:8384, the second changes it. (0.0.0.0 means “listen on all network interfaces”.) Verify:

1
ss -ltn | grep 8384

You want 0.0.0.0:8384 rather than 127.0.0.1:8384.

Why not edit config.xml directly? Older guides — including earlier versions of this one — tell you to sed the file at ~/.config/syncthing/config.xml, which now fails:

sed: can't read /home/pi/.config/syncthing/config.xml: No such file or directory

Nothing is wrong: Syncthing is not running as root and does not need initialising through the GUI first. As of Syncthing 1.27 the config moved to the XDG state directory, so on a default install it is:

~/.local/state/syncthing/config.xml

Never guess the location — ask:

1
syncthing --paths

The syncthing cli commands above avoid the question entirely, and have the further advantage of talking to the running daemon through its API, so the file is written in a form Syncthing agrees with rather than patched behind its back.

Open http://dory.local:8384 in a browser. On first access, Syncthing prompts to set a GUI username and password — do this immediately: between the restart above and setting that password, anyone on your LAN can drive Syncthing. Save the credentials in family Bitwarden under “dory syncthing gui”.

7.3.1 Name the Syncthing device dorysync

By default the Syncthing daemon takes its device name from the hostname, so every family device sees a bare dory when pairing — the same string as the Cockpit host, the Samba host and the SSH target. Name the Syncthing identity separately, so it is obvious in a device list which entry is the sync hub:

Settings → General → Device Name → dorysync → Save.

From here on, dorysync means the Syncthing identity and dory.local means the machine — the GUI is still at http://dory.local:8384, and family devices still reach the daemon at dory.local:22000.

This is worth doing because devices exchange their configured name when they connect. A client that pairs with dory and leaves its own Device Name field blank picks up dorysync automatically — so you set the name here, once, and every family device agrees without anyone typing it. The client guide tells readers to leave that field empty for exactly this reason.

(There is a syncthing cli config devices route to the same setting, but the subcommand has moved between releases — check syncthing cli config devices --help on your own install rather than copying an incantation. This whole section exists because an older version of this guide documented a config.xml edit that stopped working.)

7.4 Folder structure

First, raise the inotify watch limit

Do this before adding folders, or you will hit it as soon as the array has a real number of directories on it:

Please increase inotify limits, see https://docs.syncthing.net/users/faq.html#inotify-limits

Syncthing watches the filesystem for changes rather than re-reading everything on a timer, and on Linux that means inotify — a kernel facility that reports file events. Each watched directory consumes one watch, and the kernel caps how many watches a single user may hold. The default is typically 8192, which a family media tree blows through easily.

Raise it. Modern Debian keeps these in drop-in files rather than editing /etc/sysctl.conf directly:

1
2
3
4
5
sudo tee /etc/sysctl.d/90-syncthing-inotify.conf <<'EOF'
fs.inotify.max_user_watches=204800
EOF

sudo sysctl --system

(204800 is the value Syncthing’s own FAQ recommends. sysctl --system reloads every drop-in immediately, so no reboot is needed — the upstream FAQ says to reboot because it documents the /etc/sysctl.conf route.)

Confirm it took, and restart Syncthing so it re-establishes its watches:

1
2
sysctl fs.inotify.max_user_watches
systemctl --user restart syncthing

You want fs.inotify.max_user_watches = 204800, and the warning gone from the GUI.

Verified, August 2026 — no reboot needed. On a Raspberry Pi 5 Model B running Pi OS (Debian 13 “trixie”, kernel 6.18.39+rpt-rpi-2712, aarch64) with Syncthing v1.30.0 “Gold Grasshopper” from the apt repo in 7.1, writing the drop-in and running sudo sysctl --system raised the live value immediately, and restarting the user service cleared the GUI warning. The upstream FAQ says to reboot because it documents appending to /etc/sysctl.conf; the drop-in plus sysctl --system route does not need one.

Only max_user_watches needs changing. fs.inotify.max_user_instances (default 128) is a separate limit on how many watch sets a user may open, and Syncthing uses very few of them — leave it alone.

The limit is per user, and Syncthing runs as pi (7.2), so this is pi’s budget — shared with anything else that watches files. Each watch costs a small amount of permanently-resident kernel memory, so this is not a setting to raise arbitrarily high on a 8 GB Pi; 204800 is a considered number, not a shrug.

⚠️ This matters more than it looks, and it is why the step is here rather than in Appendix A. Without a working watcher, Syncthing falls back on the periodic full scan to notice changes at all — and Phase 13.5 tells you to raise rescanIntervalS and rely on the watcher instead. Do both, and you get a box that misses changes for hours and wakes the parked array to do a full scan when it finally looks. The two settings are only safe together.

The rule that decides the layout

Before typing anything, understand the one rule that decides the whole layout:

⚠️ A Syncthing folder is shared whole. Every device you share a folder with gets the entire tree — every file, every subdirectory. There is no way to share only part of a folder with a particular device.

So a single folder called “Computers” holding everyone’s laptops is exactly wrong: share it with two laptops and each one downloads the other’s files. The unit of sharing has to be one Syncthing folder per device, per directory that device syncs.

The two names, and which one matters

FieldScopeRule
Folder IDCluster-wideMust match exactly on dory and on the client. This is the join key — it is what makes two folders “the same folder”. Set it once and do not change it; changing it means removing and re-adding the folder everywhere.
Folder LabelPer deviceCosmetic. The human name in the GUI. Change it freely; it does not have to match.
PathPer deviceIndependent on every device. dory’s path and the laptop’s path have nothing to do with each other.

That last row is the answer to “how does the directory tree get built”: there is no mapping table anywhere. The tree on dory exists purely because you typed those paths into dory’s folder configs. Syncthing creates the directory if it does not exist.

The convention

Folder ID <device>-<what>, and a path that nests device under device class:

/mnt/raid/family-data/<class>/<device>/<what>

So for a laptop called dinolappy syncing its presentations:

On doryOn dinolappy
Folder IDdinolappy-presentationsdinolappy-presentations ← identical
Labeldinolappy presentationsPresentations
Path/mnt/raid/family-data/computers/dinolappy/presentations~/Presentations
Shared withdinolappy only—
TypeSend & ReceiveSend & Receive

Repeat per device-directory pair. A worked family layout:

Folder IDdory pathShared with
dinolappy-presentations…/computers/dinolappy/presentationsdinolappy
dinolappy-documents…/computers/dinolappy/documentsdinolappy
hannahs-pixel-camera…/phones/hannahs-pixel/camerahannahs-pixel
iot-configs…/iot-configsthe boxes that need it
family-shared…/sharedeveryone

family-shared is the deliberate exception — one folder, shared with every device, because that is the point of it. Everything else is per-device, so nobody’s laptop fills up with someone else’s work.

The computers/, phones/ and tablets/ levels are just directories on dory, created by the paths above. They are not Syncthing folders and are never shared as such — which is what stops the whole tree leaking to one device.

Auto-accept, and why it does not give you this layout

Syncthing can add folders for you: edit a remote device → Auto Accept Folders. When that device shares a new folder, dory creates it automatically.

It lands under dory’s default path, named after the folder’s label — or its ID if the label collides. That produces a flat layout (…/dinolappy-presentations), not the nested one above. So:

  • Want the nested tree, and control over what dory accepts? Create each folder manually on dory, as in the table. Recommended for a family box.
  • Want the family to self-serve and do not care about the layout? Turn on auto-accept and set the default path to /mnt/raid/family-data/auto/, then tidy up later.

Do not turn on auto-accept and then expect the nested paths; the two approaches do not combine.

Versioning

For each folder on dory: edit → File Versioning → Staggered → versions path /mnt/raid/family-data/.stversions, max age 365 days. This keeps deleted and changed file versions for a year on the RAID, and is the only thing standing between “someone deleted it on their phone” and the file being gone everywhere.

Set it on dory, where there is disk. Leave it off on phones, where there is not.

Reference: https://docs.syncthing.net/users/versioning.html

7.5 Adding family devices

dory’s side of this is small. Each device sends its Device ID; on dory’s GUI you Add Remote Device, paste the ID, and name it after the machine — dinolappy, hannahs-pixel. Then, per 7.4, create that device’s folders at their …/<class>/<device>/<what> paths and share each one with that device only, plus family-shared with everyone. Repeat per device.

The client end has to use the same Folder ID for each one, and picks its own local path. Those IDs are the only thing that must match — hand them over along with dory’s Device ID.

The other side — installing and configuring Syncthing on each laptop, desktop and phone, pairing them, ignore patterns, conflicts, and stopping it eating phone battery — is a guide of its own: Syncthing on your computers and phones .

One expectation to set before you start: the first sync of a phone full of photos can take hours over WiFi. Let it run overnight.

7.6 Adding a folder later — the household routine

7.4 and 7.5 get the first folders running. This is what happens every time afterwards, when someone in the house wants a new one. It is six steps and two people, and it is worth writing on the fridge because the failure mode — everyone inventing their own Folder IDs — makes a mess that is tedious to unpick.

#WhoWhereWhat
1UseranywhereAsks the admin for a new sync folder
2AdmindoryCreates the folder on the array
3AdmindoryShares it with the one device that owns the files
4Usertheir deviceAccepts, using the Folder ID, and picks their local path
5Usertheir deviceSets a display label and how their copy behaves
6——Clicks OK and lets the drives chatter

1. The user asks

The admin needs three things to answer, and it is quicker to ask for all three up front:

  • Which device owns the files — dinolappy, hannahs-pixel.
  • What the folder is for, in one word — presentations, camera, taxreturns.
  • Roughly how big it is. A 4 GB documents folder and a 400 GB video library are the same amount of clicking and very different amounts of waiting.

2. Admin creates it on dory

The device that owns the files is the source of truth — the canonical copy lives there, and dory’s job is to hold a faithful, versioned duplicate. Naming follows 7.4 exactly:

  • Add Folder
  • Folder ID: dinolappy-presentations — <device>-<what>, lowercase, hyphens
  • Path: /mnt/raid/family-data/computers/dinolappy/presentations
  • File Versioning: Staggered, /mnt/raid/family-data/.stversions, max age 365 days

dory creates the directory itself; you do not need to mkdir anything first.

3. Admin shares it with that device only

On the folder’s Sharing tab, tick dinolappy. Nothing else.

⚠️ This is the step where a slip is expensive. Ticking every device does not “make it available” — it hands every device a full copy of the folder, immediately, and undoing it means removing the folder from each one. Share with one device, or with everyone deliberately (family-shared), and never by accident.

Then send the user the Folder ID, exactly as typed. That one string is the whole handover — no path, no ID card, nothing else has to match.

4. User accepts and sets their path

If the two devices are already paired, dory offers the folder and a notification appears on the user’s machine. Otherwise they add it by hand with Add Folder and the ID from step 3.

Either way they set the path — the source of truth on their device:

~/Documents/presentations

That path is theirs alone. It does not have to resemble dory’s path, and nothing needs telling about the difference.

⚠️ The Folder ID must match character for character. A typo does not error — it quietly creates a second, unrelated folder that syncs with nothing, and the symptom is simply that nothing ever happens.

5. User sets a label and a replication strategy

  • Folder Label — the name they see in their own interface. Presentations. Purely local; it does not have to match dory’s label.
  • Folder Type — how their copy behaves:
    • Send & Receive — the normal choice. Edits flow both ways, so the folder is the same on both machines.
    • Send Only — their device publishes and never accepts. Right when they want dory to hold a copy but never to alter the original.
    • Receive Only — accepts and never publishes. Right for a second device that should mirror without being able to change anything.
  • Versioning — leave it off on the client. dory holds the versions (step 2), which is the point of having dory.

6. Click OK and let the drives chatter

Both ends show Syncing, then Up to Date. A documents folder takes seconds; a media library takes hours and looks stuck while it works.

If dory has been put on the archive-duty schedule in Phase 13, the first sync of anything large should be started inside the nightly window, or the array will be woken and held awake for hours in the middle of the day.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 8 — SeaweedFS

SeaweedFS provides an S3-compatible object store backed by the RAID. It is core to bare metal — a long-running storage daemon with no good reason to be containerised — so it runs as a set of native systemd services.

8.1 Download and install the binary

Check https://github.com/seaweedfs/seaweedfs/releases for the latest release; substitute the version below:

1
2
3
4
5
6
cd /tmp
SW_VERSION=3.79
curl -fLO "https://github.com/seaweedfs/seaweedfs/releases/download/${SW_VERSION}/linux_arm64.tar.gz"
tar -xzf linux_arm64.tar.gz
sudo install -m 0755 weed /usr/local/bin/weed
weed version

(tar -xzf extracts a gzipped tar archive. sudo install -m 0755 copies the file with executable permissions in one step.)

8.2 Data directories

1
2
sudo mkdir -p /mnt/raid/seaweedfs-store/{master,volume,filer}
sudo chown -R pi:pi /mnt/raid/seaweedfs-store

8.3 systemd unit files

SeaweedFS runs as four cooperating services that start in order: master → volume → filer → s3.

Two flags in these units are easy to get wrong and both produce baffling failures later:

  • -ip is an identity, not a bind address. SeaweedFS advertises whatever you put in -ip to every other component and to clients, which then dial it. Set it to 0.0.0.0 and the master announces itself as master@0.0.0.0:9333 and the filer registers as .filer@0.0.0.0:8888 — addresses nothing can connect to. Use the hostname for -ip and put 0.0.0.0 in -ip.bind, which is the flag that actually means “listen on all interfaces”.
  • -defaultStoreDir on the filer. Without it the filer creates its embedded LevelDB store at the relative path ./filerldb2. systemd runs services from /, which pi cannot write to, so the filer dies at startup and systemd restarts it forever.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
sudo tee /etc/systemd/system/seaweedfs-master.service <<'EOF'
[Unit]
Description=SeaweedFS Master
After=network-online.target
RequiresMountsFor=/mnt/raid
Wants=network-online.target

[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/weed master \
    -mdir=/mnt/raid/seaweedfs-store/master \
    -defaultReplication=001 \
    -ip=dory.local -ip.bind=0.0.0.0 -port=9333
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

sudo tee /etc/systemd/system/seaweedfs-volume.service <<'EOF'
[Unit]
Description=SeaweedFS Volume
After=seaweedfs-master.service
Requires=seaweedfs-master.service
RequiresMountsFor=/mnt/raid

[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/weed volume \
    -dir=/mnt/raid/seaweedfs-store/volume \
    -max=200 \
    -mserver=localhost:9333 \
    -ip=dory.local -ip.bind=0.0.0.0 -port=8080
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

sudo tee /etc/systemd/system/seaweedfs-filer.service <<'EOF'
[Unit]
Description=SeaweedFS Filer
After=seaweedfs-volume.service
Requires=seaweedfs-master.service
RequiresMountsFor=/mnt/raid

[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/weed filer \
    -master=localhost:9333 \
    -ip=dory.local -ip.bind=0.0.0.0 -port=8888 \
    -defaultStoreDir=/mnt/raid/seaweedfs-store/filer \
    -defaultReplicaPlacement=001
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

sudo tee /etc/systemd/system/seaweedfs-s3.service <<'EOF'
[Unit]
Description=SeaweedFS S3
After=seaweedfs-filer.service
Requires=seaweedfs-filer.service

[Service]
Type=simple
User=pi
ExecStart=/usr/local/bin/weed s3 \
    -filer=localhost:8888 \
    -ip=dory.local -ip.bind=0.0.0.0 -port=8333
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now seaweedfs-master seaweedfs-volume seaweedfs-filer seaweedfs-s3
systemctl --no-pager status seaweedfs-master seaweedfs-volume seaweedfs-filer seaweedfs-s3

All four must reach active (running), and activating is not good enough — it means the service is crash-looping under Restart=on-failure. Check the ports rather than trusting the status:

1
2
systemctl is-active seaweedfs-master seaweedfs-volume seaweedfs-filer seaweedfs-s3
ss -ltn | grep -E '9333|8080|8888|8333'

You want four active lines and all four ports listening. If the filer is missing, read its log — sudo journalctl -u seaweedfs-filer -n 30 — before going any further; nothing in 8.4 or 8.5 can work without it.

Why RequiresMountsFor=/mnt/raid. The master, volume and filer keep everything they own under /mnt/raid/seaweedfs-store. RequiresMountsFor means “do not start unless the array is mounted, and stop if it goes away”. A plain After=mnt-raid.mount only orders the start: if the mount failed, the services would start anyway and try to build a new, empty store on the bare mount point (which chattr +i in Phase 6.4 now refuses). Check it took:

1
systemctl show -p RequiresMountsFor seaweedfs-master seaweedfs-volume seaweedfs-filer

8.4 S3 credentials

Generate strong credentials and save them in family Bitwarden under “dory seaweedfs s3”:

1
2
openssl rand -hex 16   # access key
openssl rand -hex 32   # secret key

S3 identities are stored in the filer, so weed shell has to know where the filer is. Started bare, it connects to the master only, and any s3.configure fails with:

error: getOrCreateConnection : fail to dial : failed to exit idle mode:
passthrough: received empty target in Build()

That message is weed dialling an empty filer address. Give it both:

1
weed shell -master=localhost:9333 -filer=localhost:8888

The prompt shows what it managed to connect to — master: localhost:9333 filer: localhost:8888. An empty filer: there is the failure above, waiting to happen.

Don’t paste multi-line commands into the shell. It is a simple REPL: line continuations and bracketed paste do not survive it reliably, especially over a terminal on the Pi’s own desktop. Pipe the command in as a single line instead, which is also repeatable and scriptable:

1
2
echo "s3.configure -access_key=<ACCESS> -secret_key=<SECRET> -user=admin -actions=Read,Write,List,Tagging,Admin -apply" \
    | weed shell -master=localhost:9333 -filer=localhost:8888

Confirm it landed:

1
echo "s3.configure -apply" | weed shell -master=localhost:9333 -filer=localhost:8888

That prints the current identity list, which should now contain admin with the five actions.

8.5 Test

1
2
3
4
5
6
7
8
sudo apt install -y awscli
aws configure set aws_access_key_id <ACCESS>
aws configure set aws_secret_access_key <SECRET>
aws configure set default.region us-east-1

aws --endpoint-url=http://localhost:8333 s3 mb s3://test
echo "hello" | aws --endpoint-url=http://localhost:8333 s3 cp - s3://test/hello.txt
aws --endpoint-url=http://localhost:8333 s3 ls s3://test/

If those four commands succeed (make-bucket, copy-from-stdin, list), S3 is working. The --endpoint-url flag tells the AWS CLI to talk to dory instead of Amazon.

8.6 Buckets used by other systems

Pre-create the Home Assistant bucket (see disaster-home-assistant.md):

1
aws --endpoint-url=http://localhost:8333 s3 mb s3://ha

Reference: https://github.com/seaweedfs/seaweedfs/wiki/Amazon-S3-API


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 9 — Samba and NFS

Samba serves files over the SMB protocol — what Windows and macOS Finder use natively. NFS is the equivalent for Linux.

9.1 Family group

1
2
3
sudo groupadd -f family
sudo usermod -aG family pi
sudo usermod -aG family alice    # repeat for each user from Phase 4.4

Set group ownership on the shared directories:

1
2
sudo chgrp -R family /mnt/raid/family-data
sudo chmod -R g+rws /mnt/raid/family-data

(g+s is the “set-group-ID” flag — new files inside automatically inherit the family group.)

9.2 Samba configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
sudo tee -a /etc/samba/smb.conf <<'EOF'

[Family-Data]
   comment        = Family shared files
   path           = /mnt/raid/family-data/shared
   valid users    = @family
   writable       = yes
   browseable     = yes
   create mask    = 0664
   directory mask = 0775
   force group    = family

[Family-Phones]
   comment        = Phone-synced files
   path           = /mnt/raid/family-data/phones
   valid users    = @family
   writable       = yes
   create mask    = 0664
   directory mask = 0775
   force group    = family

[Family-Computers]
   comment        = Computer-synced files
   path           = /mnt/raid/family-data/computers
   valid users    = @family
   writable       = yes
   create mask    = 0664
   directory mask = 0775
   force group    = family
EOF

sudo testparm -s
sudo systemctl enable --now smbd nmbd

(testparm parses the config and reports any errors. smbd is the file server, nmbd makes shares visible in Windows’ “Network” view.)

9.3 Samba passwords

Samba has its own password database, separate from Linux passwords:

1
2
sudo smbpasswd -a pi
sudo smbpasswd -a alice

Each user picks their Samba password. It can be the same as their Linux password — but they’re separate databases, so changing one does NOT change the other.

9.4 NFS for Linux clients

1
2
3
4
echo "/mnt/raid/family-data/shared 192.168.1.0/24(rw,sync,no_subtree_check,all_squash,anonuid=1000,anongid=1000)" \
    | sudo tee -a /etc/exports
sudo exportfs -ra
sudo systemctl enable --now nfs-kernel-server

Replace 192.168.1.0/24 with your LAN’s CIDR if different.

9.5 Never share an unmounted array

If the array ever fails to mount (Phase 6.4 explains why the boot now carries on regardless), Samba and NFS would happily share the empty mount point, and the family would see their files “gone”. A systemd drop-in — a small file that adds settings to a unit without editing the packaged one — makes both refuse to start without the array:

1
2
3
4
5
6
7
for unit in smbd nfs-server; do
    sudo mkdir -p /etc/systemd/system/$unit.service.d
    printf '[Unit]\nRequiresMountsFor=/mnt/raid\n' \
        | sudo tee /etc/systemd/system/$unit.service.d/needs-raid.conf
done
sudo systemctl daemon-reload
systemctl show -p RequiresMountsFor smbd nfs-server

Both lines should end in /mnt/raid. (nfs-server is the real name of the unit that nfs-kernel-server points to.)

Syncthing needs no such guard. Every folder it shares carries a hidden .stfolder marker; if the marker is missing — as it would be on an empty mount point — Syncthing stops that folder with a “folder marker missing” error rather than treating the emptiness as mass deletion.

References:


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 10 — Daily Backup Drive (LUKS-encrypted)

The 4TB USB drive permanently attached to dory receives a snapshot of family-data every night. It is LUKS-encrypted (LUKS = Linux Unified Key Setup, the standard Linux full-disk encryption format) so that if it is ever removed — theft, repair, accidental disposal — the data on it stays protected.

The LUKS passphrase goes into the family Bitwarden group under “dory daily backup drive — LUKS passphrase”. This is the recovery path: if dory’s NVMe ever dies, you need that passphrase to mount the backup drive on a different machine. Without the Bitwarden entry, the data on this drive is unrecoverable.

For day-to-day operation, dory unlocks the drive automatically using a keyfile stored on its NVMe — so the passphrase is only needed for disaster recovery, not for nightly backups.

10.1 Identify the drive

1
lsblk -o NAME,SIZE,TYPE,TRAN,MODEL,SERIAL

Find the 4TB drive on the usb transport that is not in the caddy:

1
ls -l /dev/disk/by-id/ | grep usb | grep -v part | grep -v ST4000NM0033

There should be one entry. Capture it:

1
BACKUP_DRIVE=/dev/disk/by-id/usb-<your-drive-id>

10.2 Create the LUKS volume (destructive)

Generate a strong passphrase and put it in Bitwarden before running the format command:

1
openssl rand -base64 32

Then format (cryptsetup will prompt for the passphrase):

1
2
sudo wipefs -a $BACKUP_DRIVE
sudo cryptsetup luksFormat --type luks2 $BACKUP_DRIVE

Type YES (capital letters, exactly) to confirm, then enter the passphrase (twice).

Reference: https://gitlab.com/cryptsetup/cryptsetup/-/wikis/FrequentlyAskedQuestions

10.3 Add an unattended-unlock keyfile

Generate a 4KB random keyfile on the NVMe. Because it lives on the NVMe (only readable when dory is running), it’s a reasonable secondary unlock method for the automatic nightly backup:

1
2
3
sudo install -d -m 0700 /etc/luks-keys
sudo dd if=/dev/urandom of=/etc/luks-keys/backup-daily.key bs=4096 count=1
sudo chmod 0400 /etc/luks-keys/backup-daily.key

Add the keyfile as an additional LUKS slot (you’ll be prompted for the passphrase to authorise it):

1
sudo cryptsetup luksAddKey $BACKUP_DRIVE /etc/luks-keys/backup-daily.key

Now both the passphrase (slot 0) and the keyfile (slot 1) can unlock the drive. The keyfile is what dory uses for nightly auto-unlock; the passphrase is what a human uses if dory’s NVMe is gone.

10.4 Open and format

1
2
3
4
5
6
7
sudo cryptsetup open --key-file /etc/luks-keys/backup-daily.key \
    $BACKUP_DRIVE backup-daily
sudo mkfs.btrfs -L backup-daily /dev/mapper/backup-daily
sudo mkdir -p /mnt/backup-daily
sudo mount /dev/mapper/backup-daily /mnt/backup-daily
sudo mkdir /mnt/backup-daily/snapshots
sudo chown pi:pi /mnt/backup-daily/snapshots

(cryptsetup open creates /dev/mapper/backup-daily — a virtual block device that decrypts on read and encrypts on write. Everything else treats it like a regular drive.)

10.5 Auto-unlock and auto-mount on boot

Add the backup drive to /etc/crypttab for unattended unlock:

1
2
echo "backup-daily  /dev/disk/by-id/usb-<your-drive-id>  /etc/luks-keys/backup-daily.key  luks,nofail" \
    | sudo tee -a /etc/crypttab

Get the Btrfs UUID of the now-unlocked device:

1
sudo blkid /dev/mapper/backup-daily -s UUID -o value

Add to /etc/fstab:

1
2
echo "UUID=<paste>  /mnt/backup-daily  btrfs  defaults,noatime,nofail  0  0" \
    | sudo tee -a /etc/fstab

nofail on both lines means the system still boots if the drive is missing — important, because if you ever pull this drive you don’t want the Pi to drop into emergency mode.

Test the full autoboot path:

1
2
3
4
5
sudo umount /mnt/backup-daily
sudo cryptsetup close backup-daily
sudo systemctl daemon-reload
sudo mount -a
findmnt /mnt/backup-daily

If findmnt shows the mount, the autoboot path works.

10.6 Nightly backup script

The backup uses btrfs send/receive for incremental, block-level transfer. First run is full; every subsequent run sends only the changes.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
sudo install -d -m 0755 /opt/backup-scripts
sudo tee /opt/backup-scripts/backup-daily.sh <<'EOF'
#!/bin/bash
# Daily backup of /mnt/raid/family-data to the LUKS-encrypted 4TB drive
# at /mnt/backup-daily. Uses Btrfs snapshots and incremental send/receive.
#
# Run by systemd timer at 03:00 every night. Logs to /var/log/backup/.
#
# Reliability over speed: the script aborts on any error, never silently
# half-completes, and refuses to run if the backup drive is missing.

# 'set -e' aborts on any command failure.
# 'set -u' aborts on use of an unset variable.
# 'set -o pipefail' makes a pipeline fail if any stage fails (not just the last).
set -euo pipefail

SOURCE_SUBVOL=/mnt/raid/family-data
LOCAL_SNAP_DIR=/mnt/raid/snapshots
BACKUP_MOUNT=/mnt/backup-daily
BACKUP_SNAP_DIR="${BACKUP_MOUNT}/snapshots"
LOG_DIR=/var/log/backup
KEEP_LOCAL=14    # keep 2 weeks of source-side snapshots
KEEP_BACKUP=90   # keep 3 months on the backup drive

mkdir -p "$LOG_DIR"
LOG="${LOG_DIR}/daily-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee -a "$LOG") 2>&1

log()   { echo "[$(date '+%F %T')] $*"; }
abort() { log "ERROR: $*"; exit 1; }

log "=== daily backup starting ==="

mountpoint -q "$BACKUP_MOUNT" \
  || abort "backup drive not mounted at $BACKUP_MOUNT"

today=$(date +%Y%m%d)
new_snap="${LOCAL_SNAP_DIR}/daily-${today}"

# A snapshot for today already exists if we are re-running on the same day.
# Reuse it rather than creating a duplicate.
if [ ! -d "$new_snap" ]; then
    btrfs subvolume snapshot -r "$SOURCE_SUBVOL" "$new_snap"
    log "created snapshot $new_snap"
else
    log "reusing existing snapshot $new_snap"
fi

# Find the most recent snapshot that exists on BOTH source and backup;
# that is the parent for the incremental send.
parent=""
for candidate in $(ls -1 "$BACKUP_SNAP_DIR" 2>/dev/null | sort -r); do
    if [ -d "${LOCAL_SNAP_DIR}/${candidate}" ] \
       && [ "${candidate}" != "daily-${today}" ]; then
        parent="${LOCAL_SNAP_DIR}/${candidate}"
        break
    fi
done

if [ -z "$parent" ]; then
    log "no shared parent found; sending full snapshot (slow first time)"
    btrfs send "$new_snap" | btrfs receive "$BACKUP_SNAP_DIR"
else
    log "incremental send, parent=${parent}"
    btrfs send -p "$parent" "$new_snap" | btrfs receive "$BACKUP_SNAP_DIR"
fi

log "pruning local snapshots, keep last ${KEEP_LOCAL}"
ls -1 "$LOCAL_SNAP_DIR" | grep '^daily-' | sort \
  | head -n -"$KEEP_LOCAL" | while read old; do
    btrfs subvolume delete "${LOCAL_SNAP_DIR}/${old}"
done

log "pruning backup snapshots, keep last ${KEEP_BACKUP}"
ls -1 "$BACKUP_SNAP_DIR" | grep '^daily-' | sort \
  | head -n -"$KEEP_BACKUP" | while read old; do
    btrfs subvolume delete "${BACKUP_SNAP_DIR}/${old}"
done

log "=== daily backup completed ==="
EOF
sudo chmod +x /opt/backup-scripts/backup-daily.sh

10.7 systemd timer

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
sudo tee /etc/systemd/system/backup-daily.service <<'EOF'
[Unit]
Description=Nightly backup of /mnt/raid/family-data to LUKS USB drive
RequiresMountsFor=/mnt/raid /mnt/backup-daily

[Service]
Type=oneshot
ExecStart=/opt/backup-scripts/backup-daily.sh
Nice=10
IOSchedulingClass=idle
EOF

sudo tee /etc/systemd/system/backup-daily.timer <<'EOF'
[Unit]
Description=Run nightly backup at 03:00

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true
RandomizedDelaySec=15min

[Install]
WantedBy=timers.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now backup-daily.timer
systemctl list-timers backup-daily.timer

Nice=10 and IOSchedulingClass=idle tell the kernel to give backup work the lowest possible priority, so a backup running at 3 AM doesn’t wake the family by hammering the disks while someone is streaming.

10.8 First run

Trigger the first run manually so you know it works:

1
2
sudo systemctl start backup-daily.service
journalctl -u backup-daily.service -f

Initial full backup of an empty family-data is fast. As family data grows, expect first-run completion in hours. The Seagate drives sustain ~150 MB/s on sequential writes and the USB 3.0 link tops out around 400 MB/s practical.

After completion:

1
2
ls -lh /mnt/backup-daily/snapshots/
tail /var/log/backup/daily-*.log

10.9 Where the offsite/cloud backups fit

The two rotating offsite drives (“North” and “South”) and cloud sync are covered in backup.md. They are independent of this daily local backup — the local one protects against accidental deletion and Btrfs corruption; the offsite ones protect against fire, theft, and complete dory failure.

10.10 Save dory’s own configuration

Everything so far protects the family’s files. dory’s own setup lives on the NVMe, and if the NVMe dies it goes with it. The painful loss is Syncthing’s identity: its key pair is dory’s device ID, and without it the rebuilt dory is a stranger that every phone and laptop has to be paired with again by hand. Samba passwords, share definitions and the service units are lost the same way.

So every night, just before the backup, dory saves a small archive of its own configuration onto the array — which is what survives when the Pi does not — and a copy onto the backup drive, in case it is the array that is lost. Recovering a crashed store restores from it.

What goes in, and why:

SavedWhy
~pi/.local/state/syncthing/ cert.pem, key.pem, config.xmldory’s Syncthing device ID, its paired devices and folder settings — no re-pairing after a rebuild
/etc/fstab, /etc/crypttab, /etc/exports, /etc/samba/smb.confmounts and shares
/var/lib/samba/private/passdb.tdbthe family’s Samba passwords
/etc/systemd/system/ SeaweedFS, scrub and backup units, plus the 9.5 drop-insthe services
/etc/sysctl.d/90-syncthing-inotify.conf, /opt/backup-scripts/the tuning and the scripts
the passwd lines for pi and each family member, and the family and sudo groupsfile ownership on the array is stored as numbers (UIDs and GIDs); a rebuild must recreate the same numbers or everyone’s files belong to someone else

Deliberately not saved: the LUKS keyfile (/etc/luks-keys/backup-daily.key). The array is not encrypted, so anything on it can be read by whoever holds the caddy. A keyfile there would let a thief who took the caddy and the backup drive unlock the backup too. Recovery uses the passphrase from Bitwarden instead and enrols a new keyfile.

The archive goes in its own directory, /mnt/raid/dory-config, readable by root only and outside family-data — so Samba, NFS and Syncthing never share it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
sudo tee /usr/local/sbin/dory-config-save <<'EOF'
#!/bin/bash
# Save dory's own configuration to the array (and the backup drive, if mounted).
# Restored by Appendix D of the dory guide.
set -euo pipefail

OUT_DIR=/mnt/raid/dory-config
COPY_DIR=/mnt/backup-daily/dory-config
KEEP=14
stamp=$(date +%F)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT

# Numeric identities: pi, every member of the family group, and the
# family and sudo groups (who is in them, and family's number).
members=$(getent group family | cut -d: -f4 | tr ',' ' ')
getent passwd pi $members > "$work/passwd.dory"
getent group family sudo > "$work/group.dory"

# Only paths that exist on this box; a missing optional file is not an error.
paths=()
for p in /home/pi/.local/state/syncthing/cert.pem \
         /home/pi/.local/state/syncthing/key.pem \
         /home/pi/.local/state/syncthing/config.xml \
         /etc/fstab /etc/crypttab /etc/exports /etc/samba/smb.conf \
         /var/lib/samba/private/passdb.tdb \
         /etc/sysctl.d/90-syncthing-inotify.conf \
         /etc/systemd/system/seaweedfs-*.service \
         /etc/systemd/system/btrfs-scrub.* \
         /etc/systemd/system/backup-daily.* \
         /etc/systemd/system/dory-config-save.service \
         /etc/systemd/system/*.service.d \
         /opt/backup-scripts /usr/local/sbin/dory-config-save; do
    [ -e "$p" ] && paths+=("$p")
done

install -d -m 0700 "$OUT_DIR"
archive="$OUT_DIR/dory-config-$stamp.tar.gz"
tar -czf "$archive" -C / "${paths[@]#/}" -C "$work" passwd.dory group.dory
chmod 0600 "$archive"

# keep the newest $KEEP
ls -1 "$OUT_DIR"/dory-config-*.tar.gz | sort | head -n -"$KEEP" | xargs -r rm -f

# a copy on the backup drive covers losing the array itself
if mountpoint -q /mnt/backup-daily; then
    install -d -m 0700 "$COPY_DIR"
    cp "$archive" "$COPY_DIR/"
    ls -1 "$COPY_DIR"/dory-config-*.tar.gz | sort | head -n -"$KEEP" | xargs -r rm -f
fi
echo "saved $archive"
EOF
sudo chmod 0750 /usr/local/sbin/dory-config-save

Run it as its own service, and have the nightly backup pull it in first. It only needs the array, so it still runs on a night the backup drive is missing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sudo tee /etc/systemd/system/dory-config-save.service <<'EOF'
[Unit]
Description=Save dory's configuration to /mnt/raid/dory-config
RequiresMountsFor=/mnt/raid

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/dory-config-save
EOF

sudo mkdir -p /etc/systemd/system/backup-daily.service.d
printf '[Unit]\nWants=dory-config-save.service\nAfter=dory-config-save.service\n' \
    | sudo tee /etc/systemd/system/backup-daily.service.d/save-config-first.conf
sudo systemctl daemon-reload

No timer of its own: it rides the 03:00 backup, so the array still wakes once a night (Phase 13.5). Run it once now and look inside:

1
2
3
sudo systemctl start dory-config-save.service
sudo ls -l /mnt/raid/dory-config/
sudo sh -c 'tar -tzf "$(ls -1 /mnt/raid/dory-config/dory-config-*.tar.gz | tail -1)"'

(The whole line runs inside sudo sh -c because the directory is root-only: as pi, the shell could not even expand the * to find the file.)

The listing should include home/pi/.local/state/syncthing/key.pem, etc/samba/smb.conf, passwd.dory and group.dory. If Syncthing’s files are missing, check where your version keeps them with syncthing --paths and adjust the script.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 11 — Future Drive Expansion

Two future transitions are anticipated. Both are online — the filesystem stays mounted and accessible throughout.

11.1 Stage 1 — add a 12TB drive in slot 5

Once the array starts to fill, the first move is to add a 12TB drive in the empty slot 5.

Before:                              After Stage 1:
+---+---+   slots 1-4: 4TB           +---+---+   slots 1-4: 4TB
| 1 | 2 |   slot 5: empty            | 1 | 2 |   slot 5: 12TB
+---+---+   usable: ~8TB             +---+---+   usable: ~10TB
| 3 | 4 |                            | 3 | 4 |
+---+---+                            +---+---+
| 5 |                                | 5 (12T)|
+---+                                +--------+

Btrfs handles mixed sizes in RAID10 by allocating chunks across the largest available pairings. With one 12TB and four 4TB drives, usable space rises from ~8TB to roughly 10TB — the 12TB has no equally-large partner to mirror against, so much of its extra capacity sits unallocated until Stage 2.

Procedure:

  1. Label the new drive (Phase 0.3 conventions).
  2. Insert into slot 5 with the system running.
  3. Identify the new drive:
    1
    
    ls -l /dev/disk/by-id/ | grep -i seagate
    
    The new drive is the one not matching $DRIVE1..$DRIVE4:
    1
    
    DRIVE5=/dev/disk/by-id/<new-drive-id>
    
  4. Wipe (new drive only):
    1
    
    sudo wipefs -a $DRIVE5
    
  5. Add to the array:
    1
    
    sudo btrfs device add $DRIVE5 /mnt/raid
    
  6. Rebalance — redistributes existing data across all five drives. Takes many hours:
    1
    2
    
    sudo btrfs balance start --bg /mnt/raid
    sudo btrfs balance status /mnt/raid
    
  7. Verify:
    1
    
    sudo btrfs filesystem usage /mnt/raid
    

Reference: https://btrfs.readthedocs.io/en/latest/Volume-management.html

11.2 Stage 2 — replace the 4TB in slot 4 with a 12TB

Btrfs replace streams the old drive’s data onto the new drive directly — faster than delete + add, and preserves redundancy throughout.

Option A — replace via temporary USB-SATA adapter (preferred):

  1. Connect the new 12TB drive via a USB 3.0 SATA adapter.
  2. Identify it:
    1
    
    ls -l /dev/disk/by-id/ | grep -i seagate
    
  3. Run replace:
    1
    2
    3
    
    sudo btrfs replace start /dev/disk/by-id/<old-slot4-drive> \
         /dev/disk/by-id/<new-12TB-via-adapter> /mnt/raid
    sudo btrfs replace status /mnt/raid
    
  4. When complete, shut down:
    1
    
    sudo shutdown -h now
    
  5. Physically swap: remove old 4TB from slot 4, move new 12TB from the USB adapter into slot 4.
  6. Power on. Verify the array:
    1
    
    sudo btrfs filesystem show /mnt/raid
    
  7. Claim the extra space:
    1
    
    sudo btrfs filesystem resize max /mnt/raid
    
  8. Update the physical drive label on the old slot-4 drive (new install date, new last-4 of serial).

Option B — delete old, add new: If you don’t have a USB-SATA adapter, btrfs device delete the slot-4 drive (redistributes data to others), physically swap, then btrfs device add the new drive. Slower, and leaves the array briefly with reduced redundancy. Procedure on request.

11.3 Subsequent stages

Repeat Stage 2 for slots 1, 2, and 3 over time. End state: 5× 12TB → ~30TB usable in RAID10. The daily backup drive will need to grow at that point too.


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 12 — Verification

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# RAID
df -h /mnt/raid
sudo btrfs filesystem show /mnt/raid
sudo btrfs device stats /mnt/raid

# Services (each should print 'active')
systemctl is-active cockpit.socket smbd nmbd nfs-kernel-server \
    seaweedfs-master seaweedfs-volume seaweedfs-filer seaweedfs-s3 \
    argononed
systemctl --user is-active syncthing

# Boot-lock guards (Phases 6.4, 8.3, 9.5) - each line ends in /mnt/raid
findmnt --fstab -no OPTIONS /mnt/raid | tr ',' '\n' | grep -E '^(nofail|x-systemd.device-timeout)'
systemctl show -p RequiresMountsFor seaweedfs-master seaweedfs-volume seaweedfs-filer smbd nfs-server

# Timers
systemctl list-timers | grep -E 'btrfs-scrub|backup-daily'

# dory's own configuration (Phase 10.10) - a dated archive from last night
sudo ls -l /mnt/raid/dory-config/

# Backup drive
findmnt /mnt/backup-daily
sudo cryptsetup status backup-daily

# Network
nmcli connection show --active
ping -c 3 1.1.1.1

# Cockpit reachable
curl -k https://localhost:9090/ping

Verify from a family device:

  • Cockpit: https://dory.local:9090
  • Syncthing: http://dory.local:8384
  • Samba: \\dory.local\Family-Data (Windows) or smb://dory.local/Family-Data (Mac/Linux)
  • VNC desktop (only while a desktop session is running — Phase 1.9): dory.local:5900 in TigerVNC

| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Phase 13 — Optimising for Archive Duty

Everything so far builds a NAS that is always awake and always ready. dory does not need to be. It is archive-first: the family’s files land on it, the nightly backup runs, and for most of the day nothing reads a byte. This phase trades instant availability for quiet, cool, cheap running — and consolidates every background job into a single nightly window so the drives wake once instead of five times.

Do this only once Phase 12 passes. Idle management on a system that is not yet working correctly makes debugging much harder.

13.1 Where the power actually goes

Rough steady-state figures for this build — check your own drives’ datasheets, but the shape is what matters:

ComponentActiveIdle (spinning)Standby (spun down)
4× ST4000NM0033~9W each~7W each<1W each
ORICO caddy (bridge + fan)~3W~3W~3W
Pi 5 + NVMe~7W~4W~4W

The drives are the whole story: roughly 28W spinning versus 4W parked. Spinning them down while leaving the Pi up captures most of the available saving and costs you nothing but a few seconds of latency on the first access. Powering the Pi off as well saves another ~4W and costs you the ability to reach it at all — a much bigger trade, covered in 13.3.

Note that the caddy has its own mains PSU (Phase 0.2), so it keeps drawing power whatever the Pi does. Only a smart plug or the caddy’s own switch turns that off.

13.2 Spin the drives down when idle

Try the ATA route first. The JMicron bridge in this caddy passes ATA identity through — that is why the drives appear as ata-ST4000NM0033-… in /dev/disk/by-id/ — so it may pass power management too:

1
2
sudo hdparm -S 120 $DRIVE1        # 120 × 5s = 10 minutes
sudo hdparm -C $DRIVE1            # active/idle | standby

Wait past the timeout with the array unused, then check again. drive state is: standby means it worked. If the setting is silently ignored — common through USB bridges — use hd-idle, which watches /proc/diskstats and issues the spin-down itself:

1
sudo apt install -y hd-idle

Configure it in /etc/default/hd-idle, using by-id names so a reordered sdX cannot point the timer at the wrong disk:

HD_IDLE_OPTS="-i 0 -a /dev/disk/by-id/ata-ST4000NM0033-9ZM170_XXXX -i 600 ..."

-i 0 disables the default for all disks, then each -a names a disk and the -i after it sets that disk’s idle timeout in seconds. Repeat the pair for all four drives, and leave the NVMe out of it entirely.

To make an hdparm setting stick across reboots, put it in /etc/hdparm.conf rather than a startup script — udev applies it as devices appear.

What keeps the drives awake. A spin-down timer is useless if something touches the array every minute. In this build the culprits are:

  • Btrfs commits. The default is every 30 seconds. Adding commit=300 to the mount options in /etc/fstab batches metadata writes into 5-minute groups. The trade: up to five minutes of writes at risk in a power cut, which for an archive that is backed up nightly is a reasonable bet — but it is a bet.
  • autodefrag. It writes in the background by design. Consider dropping it from the mount options for archive workloads; it earns its keep on databases and VM images, neither of which live here.
  • The SeaweedFS filer store, which Phase 8.3 puts on the array at /mnt/raid/seaweedfs-store/filer. Its LevelDB touches disk constantly. Move -defaultStoreDir to the NVMe (/var/lib/seaweedfs/filer) and the array stops being woken by S3 metadata; the volume data stays on the array where it belongs.
  • Syncthing scans — see 13.5.
  • smartd, if you installed it, polls every 30 minutes by default. Set -n standby in /etc/smartd.conf so it skips drives that are parked instead of waking them to ask how they are.

After a night of this, confirm it is working rather than assuming:

1
for d in $DRIVE1 $DRIVE2 $DRIVE3 $DRIVE4; do sudo hdparm -C $d; done

13.3 Powering the Pi down — and the Wake-on-LAN problem

A Raspberry Pi 5 cannot do Wake-on-LAN. The Ethernet MAC has no standby power path when the board is halted, so there is nothing listening for a magic packet. Confirm it on your own board rather than taking it on trust:

1
sudo ethtool eth0 | grep -i wake

Supports Wake-on: d (d = disabled, nothing else supported) is the answer that closes this option off. Any plan built on wakeonlan dory.local will not work, no matter how the guide is configured.

Three things do work on a Pi 5, in increasing order of usefulness for a family NAS:

a. Scheduled wake from the on-board RTC. The Pi 5 has a real-time clock that stays powered while the board is halted, and it can trigger a power-on. First make sure a halt really cuts power:

1
sudo rpi-eeprom-config --edit

Set POWER_OFF_ON_HALT=1, keep WAKE_ON_GPIO=1 so the power button still works, save, and reboot. Then, to shut down now and come back at 01:00:

1
2
3
echo 0 | sudo tee /sys/class/rtc/rtc0/wakealarm            # clear any old alarm
date -d '01:00 tomorrow' +%s | sudo tee /sys/class/rtc/rtc0/wakealarm
sudo halt

Wrap that in a dory-nightly-window unit (13.4) and dory can sleep from, say, 09:00 to 01:00, wake for the sync and backup window, and halt again. Verify the wake actually happens before you rely on it — with the Pi halted and no monitor, a failed alarm is indistinguishable from a dead board, and the only recovery is the power button. Fit the RTC battery to the Pi 5’s connector if you have not; without it the clock does not survive a mains cut.

b. The power button. A press wakes it from halt. Fine when someone is standing next to it, useless from a phone.

c. A smart plug. With POWER_OFF_ON_HALT=1, applying power boots the Pi. So halt from software, then have a smart plug cut and restore mains when you want it back — that is the only remote, on-demand “wake” available on this hardware, and it doubles as the way to power the caddy down. Put the Pi and the caddy on the same plug and dory becomes genuinely off between windows.

Whatever you choose, the family needs to know that dory is not always on. A share that vanishes at 09:00 generates support calls; a share that is documented as “awake 01:00–06:00, plus whenever you press the button” does not.

13.4 The idle timer as a Cockpit entity

Cockpit has no built-in idle manager, but it renders systemd units beautifully — the Services page gives you start, stop, enable, disable and the unit’s journal for free. So the idle timer should be a systemd unit, and it appears in Cockpit with no plugin at all.

The shape:

  • /usr/local/sbin/dory-idle — a script that decides whether the box is idle. Sources of truth worth checking, in rough order of reliability: reads and writes since last poll (/proc/diskstats for the four drives), logged-in users (who), established connections on the service ports (ss -tn state established '( sport = :445 or sport = :8384 or sport = :8333 )'), and whether the backup or scrub units are currently active (systemctl is-active backup-daily.service btrfs-scrub@*). Idle means all of them quiet for N consecutive polls.
  • /etc/default/dory-idle — the knobs: IDLE_MINUTES, ACTION=spindown|halt, WAKE_AT=01:00, QUIET_HOURS. Keeping configuration in a file that Cockpit’s file editor can reach means the family’s “leave it on this weekend” is a one-line edit rather than a code change.
  • dory-idle.service (Type=oneshot) plus dory-idle.timer (OnUnitActiveSec=5min) — the timer appears under Cockpit’s Services page, where it can be disabled for a weekend of heavy use and re-enabled afterwards without touching a terminal.

Two things to get right: make the script refuse to halt while backup-daily.service is running, and log every decision to the journal with systemd-cat so Cockpit shows why dory went to sleep at 14:00.

If you later want a real Cockpit panel — a toggle and a countdown rather than a service entry — that is a plugin: a directory under /usr/share/cockpit/dory-idle/ containing manifest.json and an index.html, which Cockpit picks up on refresh. It is a genuinely small amount of code but it is front-end work, and the systemd-unit route above delivers most of the value for none of it.

TODO: the dory-idle script itself is not written yet. The decision logic above is the specification for it.

13.5 Overnight windows for phone syncing

Syncthing has no scheduler of its own. There are two places to add one, and they solve different halves of the problem.

On the phone, which is where it belongs. “Sync only while charging on home WiFi” produces an overnight window with no server-side scheduling at all, and stops the array being woken every time someone takes a photo in the park. Setting that up is client-side work — see Syncthing on your computers and phones .

On dory, for devices that cannot schedule themselves. Pause and resume folders on a timer:

1
2
3
syncthing cli config folders list
syncthing cli config folders <folder-id> paused set true      # daytime
syncthing cli config folders <folder-id> paused set false     # window opens

Wrap those in dory-sync-window-open.timer (OnCalendar=*-*-* 01:00) and dory-sync-window-close.timer (OnCalendar=*-*-* 06:00), both running as the pi user so they inherit the same Syncthing instance.

Also worth setting, whichever route you take:

  • Raise rescanIntervalS (default 3600) to a few hours and rely on the filesystem watcher for changes. Periodic full scans read every file and will wake a parked array on schedule. ⚠️ Only do this once the inotify watch limit is raised (Phase 7.4) and the GUI shows no watcher warning — with a broken watcher this setting stops changes being noticed at all, rather than merely delaying them.
  • Keep Syncthing’s own database on the NVMe, not the array — it is written constantly. It lives with the config (Phase 7.3, syncthing --paths), which is already on the NVMe by default; the thing to avoid is “helpfully” relocating it to /mnt/raid.

Line all the windows up. The point of this section is one wake per night, not five. The nightly backup (Phase 10), the monthly scrub (Phase 6.7), unattended-upgrades (Phase 3.5) and the sync window should all sit inside the same period the RTC alarm wakes dory for. Stagger them within it — backup after sync, scrub last, on its one night a month — so they do not fight for the same spindles:

01:00  RTC wake, drives spin up
01:05  Syncthing folders unpaused
04:00  Syncthing folders paused again
04:15  backup-daily.service
05:00  btrfs scrub (first Sunday only)
06:00  dory-idle halts, RTC alarm set for tomorrow

| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Appendix A — Where to Look When Something is Off

SymptomFirst place to look
Can’t reach dory.localRouter DHCP table; ping by IP; check Ethernet, then WiFi failover
Pi looks dead after a reboot, or the shares are emptySSH in first — it is usually alive. systemctl --failed: if mnt-raid.mount is listed, the array did not mount and everything that needs it was held back on purpose (Phases 6.4, 9.5). sudo btrfs filesystem show, then recovering a crashed store from D.2
nmcli says 802-11-wireless-security.key-mgmt: property is missingNetworkManager is storing profiles via netplan — use the nmcli connection add form with explicit wifi-sec.key-mgmt wpa-psk (Phase 3.4)
SSH refusedjournalctl -u ssh -n 50; is ~/.ssh/authorized_keys present and mode 600?
Bitwarden SSH agent not offering keyIs the Bitwarden vault unlocked? Settings → SSH Agent → enabled?
Cockpit gives 502systemctl status cockpit cockpit.socket
Syncthing not syncingjournalctl --user -u syncthing -n 100
Syncthing config file “not found”It moved to ~/.local/state/syncthing/config.xml in v1.27 — syncthing --paths tells you, or use syncthing cli (Phase 7.3)
Please increase inotify limitsfs.inotify.max_user_watches is at its 8192 default — raise it to 204800 (Phase 7.4). Until you do, the filesystem watcher is not working and changes are only caught by the periodic scan
S3 calls timing outsystemctl status seaweedfs-*
SeaweedFS filer stuck activatingjournalctl -u seaweedfs-filer; usually the embedded store defaulting to ./filerldb2 — needs -defaultStoreDir (Phase 8.3)
weed shell says received empty target in Build()Shell was started without -filer=localhost:8888 (Phase 8.4)
Drive missing from RAIDdmesg | tail -50; check caddy power; sudo btrfs device stats /mnt/raid
Backup didn’t runjournalctl -u backup-daily.service -n 200
LUKS won’t auto-unlock/etc/luks-keys/backup-daily.key mode 0400? /etc/crypttab entry correct?
Pi too hotsensors (no root needed) or sudo vcgencmd measure_temp, systemctl status argononed
sensors-detect fails with Module cpuid not foundExpected on Arm — sensors-detect is x86-only and unnecessary; just install lm-sensors (Phase 5.4)
Need desktop on PiPlug in keyboard/mouse/monitor, log in at console, run startx — or set Desktop Autologin and use VNC (Phase 1.8)
VNC connects but no desktopNo graphical session to attach to — loginctl list-sessions, wlr-randr; the Pi is on console boot, see Phase 1.9
VNC viewer won’t connect at allsystemctl status wayvnc; ss -ltn | grep 5900; RealVNC Viewer does not work with wayvnc — use TigerVNC
VNC desktop is tiny when headlessraspi-config → Display Options → D3 VNC Resolution, or fit an HDMI dummy plug (Phase 1.8.1)

| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Appendix B — Credentials Inventory

Every credential created by this setup goes into the family Bitwarden group:

  • dory pi user password — the pi Linux password (for console rescue, and for VNC logins — see Phase 1.8.3)
  • dory SSH key — the SSH private key (SSH Key type item); see Phase 1.4
  • dory cockpit — same as Linux account credentials
  • dory syncthing gui — username/password set on first GUI access
  • dory seaweedfs s3 — access key and secret
  • dory samba <user> — one entry per Samba user
  • dory daily backup drive — LUKS passphrase — the recovery passphrase from Phase 10.2

Without that last one, the daily backup drive is unreadable if dory’s NVMe ever fails.

| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Appendix C — Upstream References


| Read | Overview | Hardware | SSH | Pre-Flight | Base | Cockpit | Fan | RAID |
| Syncthing | S3 | Shares | Backup | Expand | Verify | Optimise | Fixes | Creds | Refs | Recovery |

Appendix D — Recovering a Crashed Store

The scenario: the drives are fine but the Pi is not — or seems not to be. You have a caddy full of drives carrying a krustyraid Btrfs RAID10 (state 3 in Phase 2.10), and the family’s files are on it.

Do not format anything. Phase 6.2 is the point of no return, and a Btrfs array that is merely unmounted is not a damaged one. Every step below until D.4 only reads the drives.

D.1 What actually died?

First, is it dead at all? Since Phase 6.4, a dory whose array fails to mount still boots — it just holds back everything that needs the array. Try ssh pi@dory.local. If you get in, run systemctl --failed; a failed mnt-raid.mount means the Pi is fine and the array is the patient — go straight to D.2.

If the Pi really is dead, what matters is the NVMe:

  • The Pi board died, the NVMe is fine. Move the NVMe (and the caddy and backup drive) to the new Pi and boot it. It is the same dory: same configuration, same Syncthing identity. Run Phase 12 and you are done.
  • The NVMe died, or you cannot tell. Build a fresh system on a new NVMe: follow Phases 0 to 5, skipping 4.4 (D.6 recreates the family’s accounts with their old numbers, which adduser would not), and skipping 6 entirely. Phase 2.10 will report state 3. Then carry on from D.2.

D.2 Identify the array without mounting it

1
sudo btrfs filesystem show

A healthy array:

Label: 'krustyraid'  uuid: 1c3e...
	Total devices 4 FS bytes used 1.21TiB
	devid    1 size 3.64TiB used 640.03GiB path /dev/sda
	devid    2 size 3.64TiB used 640.03GiB path /dev/sdb
	devid    3 size 3.64TiB used 640.03GiB path /dev/sdc
	devid    4 size 3.64TiB used 640.03GiB path /dev/sdd

Four devid lines: carry on to D.3. A degraded array says so, and one devid is absent:

	*** Some devices missing

Note the missing devid number — D.4 needs it. Then go to D.3 anyway: you mount read-only first either way.

D.3 Mount read-only and look

Prepare the mount point exactly as Phase 6.4 does, then mount read-only (ro), so nothing can change on the drives while you inspect them:

1
2
3
sudo mkdir -p /mnt/raid
sudo chattr +i /mnt/raid
sudo mount -o ro LABEL=krustyraid /mnt/raid

If a device is missing, that mount fails; add degraded, which tells Btrfs to mount with a member absent:

1
sudo mount -o ro,degraded LABEL=krustyraid /mnt/raid

Now check what you have:

1
2
3
4
sudo btrfs subvolume list /mnt/raid      # family-data, seaweedfs-store, snapshots, daily-...
sudo btrfs device stats /mnt/raid        # every counter should be 0
ls /mnt/raid/family-data                 # the family's folders
sudo ls -l /mnt/raid/dory-config/        # last night's configuration (Phase 10.10)

If the files are there and the counters are zero, the array is sound. Non-zero corruption_errs or read_io_errs on one device point at that drive — treat it as failing and replace it in D.4.

Never run btrfs check --repair to “tidy up”. It is a last resort the Btrfs developers themselves warn against, and it can turn a recoverable array into an unrecoverable one.

D.4 A degraded array: rebuild onto a new drive

Skip this if D.2 showed all four devices.

RAID10 keeps two copies of everything, so it survives losing one drive. It can survive two only if they happened to hold different copies — do not count on it. With one drive missing, the array is running on its last copy: replace the drive before anything else.

  1. Fit the new drive (same size or larger) in the empty bay and find its stable name, as in Phase 6.1:

    1
    
    ls -l /dev/disk/by-id/ | grep -v part
    
  2. Remount writable, still degraded — replace needs to write:

    1
    2
    
    sudo umount /mnt/raid
    sudo mount -o degraded LABEL=krustyraid /mnt/raid
    
  3. Rebuild onto the new drive. A missing drive has no path any more, so it is named by the devid you noted in D.2 (here 3):

    1
    2
    
    sudo btrfs replace start 3 /dev/disk/by-id/<new-drive> /mnt/raid
    sudo btrfs replace status /mnt/raid
    

    This copies a drive’s worth of data — hours per terabyte. status shows progress; wait for finished.

  4. Anything written while the array was degraded may have been stored with one copy. Convert it back to RAID10 — soft skips everything that is already right, so this is quick:

    1
    
    sudo btrfs balance start -dconvert=raid10,soft -mconvert=raid10,soft /mnt/raid
    
  5. Read and verify every block, then confirm the array is whole:

    1
    2
    
    sudo btrfs scrub start -B /mnt/raid
    sudo btrfs filesystem show /mnt/raid
    

Label the new drive as in Phase 0.3. If two drives are gone and the array will not mount even ro,degraded, go to D.8.

D.5 Make the mount permanent

The subvolumes and the SeaweedFS quota live on the array, so Phases 6.5 and 6.6 are already done — check rather than redo:

1
sudo btrfs qgroup show -re /mnt/raid     # seaweedfs-store still limited to 2T

Get the array’s existing UUID, unmount the temporary mount, and add the Phase 6.4 line:

1
2
3
4
5
6
sudo blkid -s UUID -o value /dev/disk/by-label/krustyraid
sudo umount /mnt/raid
echo "UUID=<paste-the-uuid> /mnt/raid btrfs defaults,noatime,compress=zstd:3,autodefrag,nofail,x-systemd.device-timeout=90s 0 0" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo findmnt --verify
sudo mount /mnt/raid

(No degraded here: by now the array is whole again.)

D.6 Restore dory’s configuration

Unpack last night’s archive into a scratch directory — never straight onto /, which would overwrite the new system’s files wholesale:

1
2
3
sudo install -d -m 0700 /root/restore
sudo sh -c 'tar -xzf "$(ls -1 /mnt/raid/dory-config/dory-config-*.tar.gz | tail -1)" -C /root/restore'
sudo cat /root/restore/passwd.dory /root/restore/group.dory

People, with their old numbers. The array stores file owners as numbers, so each account must come back with the same UID. pi is UID 1000 on every fresh Pi OS install, so it already matches. Create the family group with its old number, then each family member — adduser asks for their password, as in Phase 4.4:

1
2
3
4
5
sudo groupadd -g <family-gid> family          # 3rd field of the family line
sudo adduser --uid <uid> alice                # 3rd field of alice's passwd line
sudo usermod -aG family pi
sudo usermod -aG family alice                 # every member listed on the family line
sudo usermod -aG sudo alice                   # only those listed on the sudo line

Syncthing — same identity. Install it (Phase 7.1) and start it as a user service once (Phase 7.2), so its state directory exists. Then stop it, put dory’s identity back, and start it:

1
2
3
4
5
6
systemctl --user stop syncthing
sudo install -o pi -g pi -m 0600 /root/restore/home/pi/.local/state/syncthing/{cert.pem,key.pem,config.xml} \
    ~/.local/state/syncthing/
sudo install -m 0644 /root/restore/etc/sysctl.d/90-syncthing-inotify.conf /etc/sysctl.d/
sudo sysctl --system
systemctl --user start syncthing

Open http://dory.local:8384 and check Actions → Show ID: it is the device ID every family device already knows. They reconnect by themselves, no re-pairing. (The GUI address and password came back in config.xml; if the GUI only answers on the Pi itself, repeat Phase 7.3.) Skip the rest of Phase 7 — the folders, devices and GUI password came back in config.xml.

SeaweedFS. Install the binary (Phase 8.1), then restore its units. Skip 8.2 and 8.4: the data directories and the S3 identities are in the filer, on the array:

1
2
3
sudo cp /root/restore/etc/systemd/system/seaweedfs-*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now seaweedfs-master seaweedfs-volume seaweedfs-filer seaweedfs-s3

Then run the Phase 8.5 test with the keys from Bitwarden.

Samba and NFS (installed in Phase 3.3), with their guards from 9.5, and the scrub timer from 6.7:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sudo cp /root/restore/etc/samba/smb.conf /etc/samba/smb.conf
sudo cp /root/restore/var/lib/samba/private/passdb.tdb /var/lib/samba/private/
sudo cp /root/restore/etc/exports /etc/exports
sudo cp -r /root/restore/etc/systemd/system/smbd.service.d \
           /root/restore/etc/systemd/system/nfs-server.service.d /etc/systemd/system/
sudo cp /root/restore/etc/systemd/system/btrfs-scrub.* /etc/systemd/system/
sudo systemctl daemon-reload
sudo testparm -s
sudo exportfs -ra
sudo systemctl enable --now smbd nmbd nfs-kernel-server btrfs-scrub.timer

The family’s Samba passwords came back in passdb.tdb; nobody needs to set a new one.

D.7 Re-attach the backup drive

The backup drive’s keyfile was on the dead NVMe, so unlock it this once with the passphrase from Bitwarden (“dory daily backup drive — LUKS passphrase”), then retire the lost keyfile’s slot and enrol a new one:

1
2
BACKUP_DRIVE=/dev/disk/by-id/usb-<your-drive-id>     # as in Phase 10.1
sudo cryptsetup luksKillSlot $BACKUP_DRIVE 1          # the dead keyfile; asks for the passphrase

Now create and add a new keyfile exactly as in Phase 10.3. It goes at the same path as before, so the old crypttab and fstab lines for the backup drive work unchanged. Copy just those lines across, with the backup units:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sudo grep backup-daily /root/restore/etc/crypttab | sudo tee -a /etc/crypttab
sudo grep backup-daily /root/restore/etc/fstab | sudo tee -a /etc/fstab
sudo mkdir -p /mnt/backup-daily /opt/backup-scripts
sudo cp -r /root/restore/opt/backup-scripts/. /opt/backup-scripts/
sudo cp /root/restore/usr/local/sbin/dory-config-save /usr/local/sbin/
sudo cp -r /root/restore/etc/systemd/system/backup-daily.* \
           /root/restore/etc/systemd/system/dory-config-save.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo findmnt --verify
sudo systemctl enable backup-daily.timer
sudo reboot

(Only the backup-daily lines are copied: the old files’ other lines describe the dead NVMe, and copying /etc/fstab whole would stop the new Pi booting.)

The reboot proves the whole path at once — the array mounts, the drive unlocks with the new keyfile, every service comes up. Afterwards findmnt /mnt/backup-daily should show the mount.

The backup carries on incrementally: the newest snapshot exists in both /mnt/raid/snapshots and on the backup drive, so tonight’s run sends only what changed.

D.8 When the array cannot be saved

If two drives from the same mirror pair are gone, the array will not mount even ro,degraded, and the family’s files have to come back from the backup drive. This is the one time formatting is right:

  1. Fit four working drives and build a fresh array: Phase 6 in full.

  2. Unlock the backup drive by hand with the Bitwarden passphrase, and restore the newest snapshot. A received snapshot is read-only, so take a writable snapshot of it as the new family-data — the empty one Phase 6.5 created goes first:

    1
    2
    3
    4
    5
    6
    7
    8
    
    BACKUP_DRIVE=/dev/disk/by-id/usb-<your-drive-id>
    sudo cryptsetup open $BACKUP_DRIVE backup-daily        # asks for the passphrase
    sudo mkdir -p /mnt/backup-daily
    sudo mount /dev/mapper/backup-daily /mnt/backup-daily
    newest=$(ls -1 /mnt/backup-daily/snapshots | grep '^daily-' | sort | tail -1)
    sudo btrfs send /mnt/backup-daily/snapshots/$newest | sudo btrfs receive /mnt/raid/snapshots/
    sudo btrfs subvolume delete /mnt/raid/family-data
    sudo btrfs subvolume snapshot /mnt/raid/snapshots/$newest /mnt/raid/family-data
    
  3. Restore dory’s configuration from the copy on the backup drive, /mnt/backup-daily/dory-config/, following D.6 with that path in place of /mnt/raid/dory-config (people first), then D.7 for the keyfile. The next nightly backup runs incrementally from the snapshot you just restored.

The daily backup holds family-data only. The SeaweedFS store is not on it: its only other copy is whatever the offsite backups in Phase 10.9 hold. Anything the family keeps only in S3 is lost with the array.

D.9 Verify

Run all of Phase 12. Then, from a family phone, change a file in a synced folder and watch it arrive on dory: if it does without anyone re-pairing anything, the recovery is complete. Delete /root/restore when you are satisfied — it holds Samba’s password database and Syncthing’s private key.


Document Version: 3.3 Last Updated: November 2026 Hostname: dory.local

Once this setup completes and is verified, update backup.md, restore.md, and disaster.md to reflect the 4-drive starting configuration. That update has been deferred pending approval of this document.