Recipes
What you will learn
- Short, complete answers to the things a home lab asks most.
- Which keys to press, in order, and what to check at the end.
Each recipe is self-contained. The names (tank, backup, hub) are the running example from the cover; use your own.
Make a pool from new disks
- Disks: look at the serial numbers and compare them with the labels on the drives.
- Mark the disks you want with
Space. - Press
n, name the pool, and choose the redundancy (mirrorfor two disks; for three or more,raidz2is the safer choice with large disks). If the disks have 4096-byte sectors, put-o ashift=12in the options (chapter 8). - Read the command in the confirmation. Press
y, thenEnter. - Check: Pools shows
● ONLINE.
Then make datasets (Datasets, n) for the things you will treat differently. On OpenZFS 2.2 and later compression=on (lz4) is already the default; set a different value on the pool's root dataset to have children inherit it.
Protect a dataset with automatic snapshots
- Datasets: select it, press
J. - Prefix
hourly, Keep24, schedule0 * * * *. PressEnteron the last field. - Add a second job, prefix
daily, Keep14, schedule0 2 * * *. - Check: after the next hour, Snapshots shows
…@hourly-….
Scrub every pool monthly
Pools: select a pool, J, schedule 0 3 1 * *. Repeat for each pool (or for each host: pick the host in the form with F2). Check Jobs for the next run time.
Copy a dataset to another machine
- Make sure a snapshot job with prefix
hourlyruns on the source (above). - On the destination host, make a parent dataset to receive into (
backup). - Jobs,
R: source host and dataset, prefixhourly, destination host andbackup/tank-data, schedule30 * * * *. - Check: after the run, the panel shows
sent …/skipped: up to date, and the destination has the snapshots.
Do not write to the destination dataset: a receive fails if the destination changed since its last snapshot (unless you set Force).
Keep a dataset encrypted
- Datasets: press
E, give the name with its pool, keepaes-256-gcm, type a passphrase of 8 or more characters twice, then type the dataset's name to confirm. - Write the passphrase down somewhere safe. If it is lost the data cannot be recovered by anyone.
- To lock it: unmount it at the shell, then
U,y,Enter. To use it again:Land the passphrase. - Check: the Lock column says
openorLOCKED.
Replication and cloud mirrors refuse an encrypted source; restic backups work while it is open. A full walkthrough is in Datasets.
Back up to a USB disk, or the cloud
- Install restic; make a password file;
restic init(chapter 15). - Jobs,
B: the dataset, Sourcenew(it takes its own snapshot each run), the repository (/mnt/usb/restic-tank, orrclone:myremote:bucket/path), the password file, Keep7d 4w 12m, schedule30 3 * * *. - Check: Jobs shows
ok; runrestic snapshotson the repository. Restore one file as a test.
Replace a failed disk
- Hosts shows the host red (
tank DEGRADED); Pools shows▲ DEGRADED; pressEnterto see which disk isFAULTEDorUNAVAIL. - Check the serial number of that disk in Disks and find the physical drive.
- If the old disk still answers, leave it online: a replacement works as attach, resilver, then detach, so the old disk keeps helping until the new one is full. Take it offline (
o) only when you have to pull it. - If you have a free slot, connect the new drive first. Select the old entry in the vdev view, press
x, type the new device name (ada3), and confirm. If the old drive has to come out first, swap it and do the same. - Check: the pool resilvers (progress in the panel) and returns to
● ONLINE. Leave it alone until it is done.
Safety: replacing overwrites the new disk. Check its name against its serial number first.
Undo a bad upgrade
- Before upgrading: Boot Envs,
n, name itbefore-upgrade. - Upgrade and reboot. If the system misbehaves, at the boot menu choose the older boot environment, or from a working shell: select it in Boot Envs and press
a, then reboot. - Clean up with
dwhen you are sure.
Share a dataset with the family
- Datasets: select it, press
Nfor NFS (Linux and Unix clients) orMfor SMB (Windows and macOS). Visit Shares first. - NFS: give a network,
172.16.10.0/24. SMB: a share name, a Unix user and a Samba password. - Check: Shares lists it. From a client, mount it.
Get an email when something breaks
- Make sure
msmtp(or your mail command) works from a shell on the hub. - Alerts:
e, fill in your address and command, save; presstto send a test. - Check: the message arrives; the daily report arrives the next morning.
Add a machine to the lab
Chapter 5: create the account and authorise the key, add the host with n in Hosts, then zfsctl print-sudoers HOST and zfsctl check-host HOST.
Try it
Pick the recipe closest to a worry you have today and do it on the practice pool first.