I enabled SMART notifications on my laptop running Debian. Basically I just want to get a notification pop up when something goes wrong on a disk. I don't want to get an email, I think a notification is better indicated on the workstation where I spend my days (while emails are off course better for servers).
It works, I even tested it (but what exactly did I test ?), but I still have doubts if I did it the right way, and if what I did is really useful.
Basically, what I did :
- I installed
smartmontools
andsmart-notifier
# apt-get install smartmontools smart-notifier
- I then configured the
smartd
daemon to monitor/dev/sda
and send its messages to the notifier. This is done in/etc/smartd.conf
, in which I have only 1 line :
/dev/sda -a -m myUsername -M exec /usr/share/smartmontools/smartd-runner -M test
- The
-M test
option in the previous command displays a test notification popup as soon as I restart thesmartd
daemon (you have to log out and log back in in order for it to work). And it works, restarting thesmartd
daemon displays the test notification popup. - And finally I removed the
-M test
option and restartedsmartd
again.
So, can I be at ease now ? Will this setup send me a popup as soon as something goes wrong with /dev/sda
? I have a lot of unanswered questions :
- With the
-M test
option, the test notification popup is only displayed when I restartsmartd
. Nothing is displayed when I restart my laptop and log in (probably becausesmartd
is already running at that point). Can I be confident that a notification will pop up ifsmartd
detects something wrong on my disks ? - What event exactly will trigger that pop up ? In other words, what is "something wrong" ?
$ man smartd
states that :
smartd will attempt to enable SMART monitoring on ATA devices (equivalent to smartctl -s on) and polls these and SCSI devices every 30 minutes (configurable), logging SMART errors and changes of SMART Attributes via the SYSLOG interface.
And indeed, checking /var/log/syslog
I can see a log entry after 30 minutes (last line) :
Jul 30 13:17:06 precision7520 smartd[20258]: smartd 6.6 2016-05-31 r4324 [x86_64-linux-4.19.0-0.bpo.5-amd64] (local build)
Jul 30 13:17:06 precision7520 smartd[20258]: Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Jul 30 13:17:06 precision7520 smartd[20258]: Opened configuration file /etc/smartd.conf
Jul 30 13:17:06 precision7520 smartd[20258]: Configuration file /etc/smartd.conf parsed.
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda, type changed from 'scsi' to 'sat'
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], opened
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], Samsung SSD 850 EVO 2TB, S/N:S2RMNB0J801642K, WWN:5-002538-c407b1fd2, FW:EMT02B6Q, 2.00 TB
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], not found in smartd database.
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], can't monitor Current_Pending_Sector count - no Attribute 197
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], can't monitor Offline_Uncorrectable count - no Attribute 198
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], is SMART capable. Adding to "monitor" list.
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], state read from /var/lib/smartmontools/smartd.Samsung_SSD_850_EVO_2TB-S2RMNB0J801642K.ata.state
Jul 30 13:17:06 precision7520 smartd[20258]: Monitoring 1 ATA/SATA, 0 SCSI/SAS and 0 NVMe devices
Jul 30 13:17:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], state written to /var/lib/smartmontools/smartd.Samsung_SSD_850_EVO_2TB-S2RMNB0J801642K.ata.state
Jul 30 13:47:06 precision7520 smartd[20258]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 67 to 68
But no pop up. Maybe because the log entry was just a minor information (a 1 degree temperature increase) ? But then, what kind of event exactly is supposed to trigger the notification ?
- Finally, there are a lot of examples in
/etc/smartd.conf
, with even more in$ man smartd.conf
, some performing (-s
) short (-s S
) or extended (-s L
) self tests at given intervals. Are those self tests necessary ? Isn't SMART supposed to integrate its own self test procedures (the SM of SMART stands for Self-Monitoring) ? How useful are results without performing self tests ?
For information, my # smartctl /dev/sda
results :
$ sudo smartctl -a /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.19.0-0.bpo.5-amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Samsung SSD 850 EVO 2TB
Serial Number: S2RMNB0J801642K
LU WWN Device Id: 5 002538 c407b1fd2
Firmware Version: EMT02B6Q
User Capacity: 2 000 398 934 016 bytes [2,00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4c
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Fri Jul 30 14:15:22 2021 WAT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
(...)
No self test seems to be ever performed :
(...)
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x53) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
No Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 265) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
(...)
Are these data of any use, even without self-tests ?
(...)
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
9 Power_On_Hours 0x0032 094 094 000 Old_age Always - 27805
12 Power_Cycle_Count 0x0032 098 098 000 Old_age Always - 1055
177 Wear_Leveling_Count 0x0013 099 099 000 Pre-fail Always - 21
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 010 Pre-fail Always - 0
181 Program_Fail_Cnt_Total 0x0032 100 100 010 Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 010 Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 099 010 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 067 043 000 Old_age Always - 33
195 Hardware_ECC_Recovered 0x001a 200 200 000 Old_age Always - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 0
235 Unknown_Attribute 0x0012 099 099 000 Old_age Always - 71
241 Total_LBAs_Written 0x0032 099 099 000 Old_age Always - 26330052507
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 14903 -
# 2 Short offline Completed without error 00% 14709 -
# 3 Short offline Aborted by host 70% 2733 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
255 0 65535 Read_scanning was never started
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
A lot of question, but basically they all boil down to one : what are the best practices to enable SMART disk notifications on a Linux workstation ? I was kind of surprised that googling this question didn't provide any useful informations