Skip to main content

Storage & Backups

Create zpool10 Storage Pool

The host's rpool can be used for templates and whatnot but I want a big pool for storing all my data.

  • ashift=12 to use 4k blocks
  • failmode=continue to let us keep reading if a drive goes bad
  • compression=lz4 save save space and increase speed
  • xattr=sa be more efficient for linux attributes
  • encryption=aes-256-gcm use fast/secure encryption algorithm
  • keyformat=passphrase unlock with a passphrase
# zpool create -o ashift=12 -o failmode=continue -O compression=lz4 -O xattr=sa -O atime=off -O encryption=aes-256-gcm -O keyformat=passphrase -m /storage/zpool10 zpool10 raidz2 /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_JEKH3DVZ /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_2YK148SD /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_JEKH8RWZ /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_JEK6ESAN /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_JEK53ZHN /dev/disk/by-id/ata-WDC_WD100EMAZ-00WJTA0_2YK0HL0D

Setup ZFS Scrub

Automate ZFS scrubbing so the disks are monitored and I can replace one as soon as there is a problem detected.

Create Service/Timer (source)

# /etc/systemd/system/zpool-scrub@.timer
+ [Unit]
+ Description=Scrub ZFS pool weekly
+
+ [Timer]
+ OnCalendar=weekly
+ Persistent=true
+
+ [Install]
+ WantedBy=timers.target
# /etc/systemd/system/zpool-scrub@.service
+ [Unit]
+ Description=Scrub ZFS Pool
+ Requires=zfs.target
+ After=zfs.target
+
+ [Service]
+ Type=oneshot
+ ExecStartPre=-/usr/sbin/zpool scrub -s %I
+ ExecStart=/usr/sbin/zpool scrub %I

Enable ZFS Scrub

systemctl daemon-reload
systemctl enable --now zpool-scrub@rpool.timer
systemctl enable --now zpool-scrub@zpool10.timer

Setup Storage Layout

Setup my dataset layout.

  • zpool10/backups local backups of rpool
  • zpool10/downloads landing zone of downloads
  • zpool10/downloads/incomplete landing zone for bittorrent downloads (recordsize=16k for bittorrent)
  • zpool10/media storage for audio/tv/movies
  • zpool10/proxmox additional storage for proxmox
  • zpool10/proxmox/backups backup for proxmox containers/vms
  • zpool10/services storage for services (possibly databases, so use recordsize=16k)
zfs create zpool10/backups
zfs create zpool10/downloads
zfs create -o recordsize=16K zpool10/downloads/incomplete
zfs create zpool10/media
zfs create zpool10/proxmox
zfs create zpool10/proxmox/backups
zfs create -o recordsize=16K zpool10/services

Setup Sanoid/Syncoid

Run Sanoid for automating snapshots and Syncoid for remote backups.

Install (source)

apt-get install debhelper libcapture-tiny-perl libconfig-inifiles-perl pv lzop mbuffer
sudo git clone https://github.com/jimsalterjrs/sanoid.git
cd sanoid
ln -s packages/debian .
dpkg-buildpackage -uc -us
apt install ../sanoid_*_all.deb

Configure Sanoid

# /etc/sanoid/sanoid.conf
+ [rpool]
+ 	recursive = yes
+         frequently = 0
+         hourly = 36
+         daily = 30
+         monthly = 3
+         yearly = 0
+         autosnap = yes
+         autoprune = yes
+
+ [zpool10/services]
+         recursive = yes
+         frequently = 0
+         hourly = 24
+         daily = 30
+         monthly = 1
+         yearly = 0
+         autosnap = yes
+         autoprune = yes
# /usr/lib/systemd/system/sanoid.service
  [Service]
- Environment=TZ=UTC
+ Environment=TZ=EST

Eanble Sanoid

systemctl daemon-reload
systemctl enable --now sanoid.service

Configure Syncoid

# /etc/systemd/system/rpool-backup.timer
+ [Unit]
+ Description=Backup rpool daily
+
+ [Timer]
+ OnCalendar=daily
+ Persistent=true
+
+ [Install]
+ WantedBy=timers.target
# /etc/systemd/system/rpool-backup.service
+ [Unit]
+ Description=Use syncoid to backup rpool to zpool10/backups/rpool
+ Requires=zfs.target
+ After=zfs.target
+
+ [Service]
+ Type=oneshot
+ ExecStart=/usr/sbin/syncoid --recursive rpool zpool10/backups/rpool

Enable Syncoid

systemctl daemon-reload
systemctl enable --now rpool-backup.timer