Check hard drive health using S.M.A.R.T.

This commit is contained in:
Jan Schulz-Hofen
2020-02-20 23:28:41 +01:00
parent 30c2c60f59
commit 97abacccc3
2 changed files with 39 additions and 0 deletions
+17
View File
@@ -357,3 +357,20 @@ cp -f conf/fail2ban/filter.d/* /etc/fail2ban/filter.d/
# scripts will ensure the files exist and then fail2ban is given another
# restart at the very end of setup.
restart_service fail2ban
# ### S.M.A.R.T. Monitoring Tools
# Install and configure smartmontools so we can check for failing hard drives.
# We'll perform a first single smartd startup to check if any devices are found
# which can be monitored. If none are found (virtual machines!), we will configure
# smartd to not start automatically. Otherwise, smartd will run.
apt_install smartmontools
smartd --quit=onecheck > /dev/null 2>&1 || { smart=$? ; }
if [ "${smart:-0}" -ne 17 ]; then # smartd manpage: 17 means smartd didn't find any devices to monitor.
echo "S.M.A.R.T. capable hard drives found, setting up smartd..."
tools/editconf.py /etc/default/smartmontools start_smartd=yes
restart_service smartmontools
else
echo "No S.M.A.R.T. capable hard drives found, disabling smartd..."
tools/editconf.py /etc/default/smartmontools start_smartd=no
fi