SMART (Acronym for Self-Monitoring, Analysis and Reporting Technology) can be found on all modern hard drives, allowing for the detection of conditions and the reporting of the times a unit can “fall” permanently.
Smartmontools is a free multiplatform tool that uses the S.M.A.R.T. of hard drives to get informed about their status. With Smartmontools, a user or system administrator can be constantly informed about the imminent hard disk failure.
On Ubuntu or Debian systems, Smartmontools is available in official repositories:
sudo apt-get install smartmontools
It is possible that other important Linux distributions – Arch, Fedora, Suse/openSuse, CentOS/Red Hat, Slackware – to be in the official warehouses (for Fedora it surely is).
Installing Smartmontools provides 2 programs: smartctl, which can be used in an interactively mode and smartd, which, as the name suggests, is a daemon meant to run in the background.
Smartctl requires root permissions to run. Smartctl monitors an entire hard disk (not a particular partition). To get information about a hard drive, we will use the -i option:
sudo smartctl -i /dev/sda
where sdx is the drive you are interested in.
You will receive some drive info and you can also see if SMART support is available and enabled for your unit. If the SMART attribute is available but not enabled, you have the following command available:
sudo smartctl -s on /dev/sda To check the health of your hard drive, we will use the -H option:
sudo smartctl -H /dev/sda
If we do not have PASSED at the exit, it means the hard drive has cracked or this will happen in a very short time. To see the SMART hard drive yield, use the -c option:
sudo smartctl -c / dev / sda
Smartctl is a fantastic tool that needs to be run periodically. Smartd is a daemon designed to periodically run the SMART diagnostics of selected drives. So if the hard drive did not pass the tests or an error occurred, the owner will be notified immediately.
The configuration file can normally be found at /etc/smartd.conf. We open this file and look for the lines that begin with DEVICESCAN and comment on it by adding # to its beginning. Then we show the system the list of drives to be scanned:
/dev/sda -a -o on -S on -s (S/../.././07 | L/../../6/03) -m firstname.lastname@example.org -M exec /usr/share/smartmontools/smartd-runner
The options listed above show the following:
• /dev/sda: The hard disk indicated for scanning
• -a: Activates some recommended options
• -d sat: on most systems (and mine), smartctl correctly recognizes that I have an ATA serial hard drive. smartd does not. If the smartd fails or does not start running, it is advisable to add the -d TYPE option
• -o on: enables SMART Automatic offline tests
• -S on: Enables SMART auto save
• -s (S/../.././07 | L/../../6/03): Run short tests (S/../.././02) and long (L/. ./../6/03) at the preset time. This example shows that a short test will start at 7:00 a day, and a long test at 3 o’clock.
• -m root: will send an email to the specified address; multiple addresses can be separated by commas. Keep in mind that this fat requires an active e-mail service (for example, on servers).
• -M exec /usr/share/smartmontools/smartd-runner: modifies the behavior of the -m option On Debian and Ubuntu systems, smartd-runner performs other actions in addition to the email option (-m).
For more information, see the smartd.conf man page:
After the smartd setup, we need to make sure that the scan will start in the same time with the system. To do this, open the /etc/default/smartmontools configuration file and uncomment line #start_smartd=yes (delete the # character). We save and start startd by commands:
sudo /etc/init.d/smartmontools restart
We should receive a message at the indicated address.