smartctl

smartctl


==============================
Install/Update the tool
==============================

apt install smartmontools


==============================
To ensure the hard disk supports SMART and is enabled, use the following command (in this example for the hard disk /dev/sdc):
==============================

smartctl -i /dev/sdc

smartctl --info /dev/sda | grep 'SMART support is:'

==============================
If SMART is available but not enabled, you can enable it:
==============================

smartctl --smart=on /dev/<device>

==============================
Before performing a test, an approximate indication of the time duration of the various tests are displayed using the following command:
==============================

smartctl -c /dev/sdc

==============================
The following command starts the desired test (in Background Mode):
==============================

smartctl -t <short|long|conveyance|select> /dev/sdc

==============================
In general, the test results are included in the output of the following commands:
==============================

smartctl -a /dev/sdc

==============================
The following command can also be used, if only the test results should are displayed:
==============================

sudo smartctl -l selftest /dev/sdc

==============================
Quick overall health
==============================
smartctl -H /dev/sda

==============================
Show even more info than -a
==============================

smartctl -x /dev/sdc

==============================
Automated checking create or edit /etc/smartd.conf with the below
==============================

DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -W 4,35,40 -m <username or email> -M exec /usr/local/bin/smartdnotify

==============================
To send an email and a system notification, put something like this into /usr/local/bin/smartdnotify:
==============================

#!/bin/sh
# Send email
echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"
# Notify user
wall "$SMARTD_MESSAGE"
# Uncomment if using a compatible GUI with libnotify
#sudo -u X_user DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/X_userid/bus notify-send "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning