Raspberry Pi 4 NAS on Alpine Linux with ZFS
Author: -fab- <fab@redterminal.org>
License: CC BY-SA 4.0
Published on: Fri, 04 Feb 2022 12:56:18 +0100
Last updated: Fri, 04 Feb 2022 12:56:18 +0100
I prefer to build up my backup solution myself instead of buying some SOHO NAS systems. So I'm in full control. Here I want to show my setup and what's possible with a little effort.
Setup
My NAS backup solution consists of a Raspberry Pi 4 (8GB RAM) and a 4-bay USB3 harddisk storage case with 4x4TB Seagate Ironwolf HDDs. I also own another Pi4 (8GB) with one 4TB HDD connected to it, as secondary backup. The secondary RPi4 also has a fast 480GB SSD connected to it.
I Installed Alpine Linux on both of them. Alpine Linux for RPi4 supports ZFS after installing the necessary packages ("zfs", "zfs-rpi4", "zfs-openrc"). On a standard install ZFS utilizes half of the RAM for its ARC cache, so its best to buy a 8GB RPi4, if you want to use ZFS. Make also sure you have 64bit support. I started using Raspberry Pi OS at first, and it did always panic on a scrub! Alpine Linux has support for aarch64 and there is no such behavior.
Alpine Linux on a Raspberry Pi
ZFS
Because I wanted some redundancy for my NAS, ZFS was a good way to achieve this. ZFS has a lot of neat features like snapshots, encryption, data checksums and send/receive of snapshots.
I created a 4-drive raidz1 on the NAS so one drive can completely fail without loosing data. It is checked (scrub) every 1st thursday a month. The external HDD of the second Pi has a one disk ZFS setup. I check it manually every couple of weeks.
sshd
The only service running on my NAS is sshd. It supports all needed functionality: BorgBackup, rsync, my local git repositories and sftp for file storage/archive and media distribution throughout my network. It's also reachable from outside my network to support backups from my VPSes.
BorgBackup
BorgBackup is a deduplicating backup application, similar to restic. All my external VPSes and home servers push daily backups to my NAS via BorgBackup. On wednesdays and saturdays I update all my local machines, and additional backups of the home directories of my laptop and workstation are pushed to the NAS.
The NAS server also distributes my media files throughout my network via sftp. My FireTV Cube (I know, I know...) can easily stream them to my TV. No need to set up a kodi server or Open Media Vault or something like that.
Secondary Backup Server
Every sunday morning a snapshot of my NAS is made and all the additional data collected over the week is sent incrementally (ZFS send/receive) to my secondary backup server. The HDD on it is quite small and I need to buy a new, bigger one soon. A 8-10 TB HDD would be great.
SyncThing
My secondary backup server also serves as a SyncThing instance with a fast 480GB SSD. I have configured it like a client/server setup. My laptop and workstation synchronize my documents, images, configs and working directories with it. The synced files are also pushed to the NAS with BorgBackup every night.
Final Words
You won't get the full 1Gbit throughput with such a setup. Especially if you use ZFS encryption this slows down the connections a bit. But for my backups, GIT repos and the occasional media streaming it serves me really well.
All in all - have fun!
--
Back to index
Homepage