RAID – How to Monitor Disk Health Using smartd on High Availability RAID 1 Server

mdadmraid1smartsoftware-raid

I have a server with three identical SATA/600 3TB drives: /dev/sda, /dev/sdb, /dev/sdc. The drives are partitioned, using GPT with three partitions each:

  • 1 MB: Reserved partition for boot loader
  • 1 GB: RAID1 /dev/md0 ( ext2 ( /boot ) )
  • 3 TB: RAID1 /dev/md1 ( encrypted volume ( LVM ( volume group ( Swap, /, /etc, /home … ) ) ) )

One of the three drives is a hot spare and the other two are active in the RAID sets. It works fine and I am able to boot after disconnecting any single HDD. I want to use smartd (part of smartmontools) to monitor the health of the drives and report errors to syslog (which I monitor using logcheck). This server should have as high availability as possible, but it is acceptable that performance is lowered during tests.

Here is the output of smartctl -a /dev/sda:

smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-4-amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD30EZRX-00MMMB0
Serial Number:    WD-WMAWZ0412093
LU WWN Device Id: 5 0014ee 2b19fbdcd
Firmware Version: 80.00A80
User Capacity:    3,000,592,982,016 bytes [3.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Fri Sep 27 15:37:25 2013 CEST
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

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                    was completed without error.
                    Auto Offline Data Collection: Enabled.
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:        (50280) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    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:    ( 255) minutes.
Conveyance self-test routine
recommended polling time:    (   5) minutes.
SCT capabilities:          (0x3035) SCT Status supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   148   148   021    Pre-fail  Always       -       9575
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       95
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       820
 10 Spin_Retry_Count        0x0032   100   253   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       93
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       65
193 Load_Cycle_Count        0x0032   196   196   000    Old_age   Always       -       12824
194 Temperature_Celsius     0x0022   119   116   000    Old_age   Always       -       33
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       0

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%       787         -
# 2  Extended offline    Completed without error       00%       727         -

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
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.

It seems offline testing is supported. When I issue smartctl -o on, smartctl -c shows that Offline data collection status has been set to (0x82). If I issue smartctl -o off the same value becomes (0x02).

I have set up smartd to start up with the server by setting start_smartd=yes in /etc/default/smartmontools. How would you recommend that I configure smartd by editing /etc/smartd.conf for this server? Please describe each parameter you use and why you use it the way you do.

I will add my current set up as an answer. Feel free to use it as a base and improve it in your own answer. A better description using the same set up would be an improvement too!

Best Answer

I switched from long selftests to select,cont tests. It's like the long selftest, but only one slice of disk at a time. So while the long selftest may take well over a day (with an otherwise busy 3TB disk), the selective test can run every night when the server is the least busy and actually finish, without harming performance in the more busy hours.

So basically you would be distributing a monthly long self-test of the entire disk, to a nightly selective test that still covers the entire disk over the course of a month.

It takes some preparation though.

  • smartd must run with the --savestates option as the disks themselves usually do not keep track of the last region tested.
  • You must initiate the first selective self test manually (-t select,0-$size) so smartd will know the slice size to test each day. The size determines how long the test will take and how many days to span the entire disk.
  • Make sure the $size you pick aligns to the disk size. Otherwise you risk the last slice being very small (worst case you waste a day testing only a single sector of the disk).
  • You must verify that this information actually made it to the savestates files as sometimes it does not and then the test will not run the way you want to. (Editing the savestate file directly is also an option).
  • The syntax for the smartd.conf file is -s c/../.././01 (in this example it would run every day at 1am).

Once that is done however the process is automatic and reliable. Once it reaches the end of the disk it will automatically start at the beginning the next day. Read the smartctl manpage regarding select,cont tests.

While the long or selective tests are great, you should probably still run the short or overall assessment tests. They only take a very short time and may help detect general problems.

Related Question