How to Build a Minimal ZFS NAS without Synology, QNAP, TrueNAS

2 min read
zfsself-hostingnashomelab
View as Markdown
Originally from neil.computer
View source

My notes

Summary

A walkthrough for building a bare-metal ZFS NAS on plain Debian or RHEL instead of a full appliance OS like TrueNAS, using just zfs plus Samba. Covers disk aliasing for stable device paths, creating a RAIDZ1 pool with correct sector alignment, organizing data into datasets, and sharing over SMB including a proper macOS Time Machine target.

Key Insight

  • ZFS’s core advantage is self-description: all pool and RAID configuration lives on the disks themselves, not in host OS config. If the OS is wiped, move the drives to any machine with zfs installed and run zfs import, and the pool (including RAIDZ level) reassembles automatically. No separate backup of “how the array was configured” is needed.
  • Raw device names (/dev/nvme1, /dev/sda) are not guaranteed stable across reboots or when new drives are added. Fix: map serial-number-based /dev/disk/by-id/ paths to friendly aliases via /etc/zfs/vdev_id.conf, then run udevadm trigger to activate them, and the aliases appear under /dev/disk/by-vdev/. This file is a convenience only; losing it does not break the pool.
  • Set ashift=12 at pool creation time, because it cannot be changed later. Many drives report a legacy 512-byte sector size for backwards compatibility even though physical sectors are 4KB or larger (for example, the Samsung 990 Pro); using the wrong ashift silently costs significant write performance.
  • Treat ZFS datasets as more than folders: each one carries its own properties (compression, quotas, encryption) and can be individually snapshotted or replicated to a remote host. Practical pattern: create one dataset per major data category (for example, pool/docs and pool/backups) at the top level rather than subfolders inside a single dataset, so any category can be sent or replicated independently.
  • For macOS Time Machine over SMB, the Samba share needs specific flags beyond a normal share: vfs objects = catia fruit streams_xattr, fruit:time machine = yes, fruit:aapl = yes, spotlight = yes, and inherit acls = yes. A plain SMB share works for general files but will not register as a Time Machine destination without these.
  • Example spec used: RAIDZ1 (single-drive redundancy) across 4x4TB NVMe SSDs, 4-core Xeon, 16GB ECC RDIMM RAM, no encryption, positioned as “good enough” rather than enterprise and explicitly skipping the GUI and feature layer that TrueNAS, Synology, and QNAP add.