Introduction

Since my home server uses a BTRFS raid 1 array for data storage, it is able to handle a single disk failure without any data loss. But to make sure it survives without data loss, immediate action needs to be taken, should a disk decide to stop working. To get such an information as quickly as possible, This guide sets up regular hard-disk checks with SMARTd and instant notifications via Pushover, if something goes wrong. As always, there is an excellent guide over in the Arch Wiki, where most of this is taken from.

Prerequisites

Install smartd and smartctl with the smartmontools package:

$ sudo pacman -S smartmontools

For the notifications, we will use ntfy. This awesome tool makes sending push messages via cli super comfortable. It requires Python and pip.will

$ sudo pacman -S python-pip
$ sudo pip install ntfy

Add notification script

We add a small script to /usr/share/smartmontools/smartd_warning.d/. This will be executed on any alert which arises from smartd.

Add a script called “smartdnotify” with following content:

#!/usr/bin/env bash
SMARTD_MESSAGE=${SMARTD_MESSAGE:-"SMARTd Error"}
ntfy -t SMARTd -b pushover -o user_key YOUR_USER_KEY send "$SMARTD_MESSAGE"

and make it executable

$ sudo chmod +x /usr/share/smartmontools/smartd_warning.d/smartdnotify

You need to replace YOUR_USER_KEY with your user key (obviously …) from the Pushover website.

SMARTd configuration

Finally, we just need to configure SMARTd which consists of a single line in /etc/smartd.conf:

DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././05|L/../../6/06) -W 4,35,42 -m @smartdnotify

This will enable automatic offline data collection (-o), enable automatic attribute autosave (-S) and schedule short self-tests every day at 5am and a long self-test every Saturday at 6am. It will omit tests, if disks are in standy (-n). Last but not least, it will log temperature rises of four or more degrees as well as temperatures above 35 degrees and will notify if the temperature rises above 42 degrees. On all occasions, where smartd wants to tell us something, it executes our smartdnotify script (-m).