Scrubbing with systemd
It's important to regularly scrub ZFS volumes to verify they're not suffering from bit rot. We can automate this process with systemd timers.
System configuration
First, create /etc/systemd/system/zfs-zpool-scrub@.service
:
[Unit]
Description=Scrub ZFS zpool
Requires=zfs.target
After=zfs.target
[Service]
Type=oneshot
ExecStartPre=-/usr/sbin/zpool scrub -s %i
ExecStart=/usr/sbin/zpool scrub %i
Now create a corresponding timer:
[Unit]
Description=Scrub ZFS zpool every two weeks
Requires=zfs-zpool-scrub@%i.service
[Timer]
OnCalendar=*-*-1,15 20:00:00
Persistent=true
[Install]
WantedBy=timers.target
For each zpool
Simply enable a timer for each zpool:
sudo systemctl enable --now zfs-zpool-scrub@$pool.timer
Backlinks