Tips en Trucs 2016

De gezondheid van de harde schijf nagaan met smartmontools

Het smartmontools pakket bevat twee programma's (smartctl en smartd) om opslagmedia te controleren en op te volgen. De programma's maken gebruik van het in moderne ATA en SCSI ingebouwde Self-Monitoring, Analysis and Reporting Technology System (SMART) systeem. De smartmontools waarschuwen u op voorhand voor een op hand zijnde hard schijf catastrofe (verminderde betrouwbaarheid of volledige uitval).

De gezondheid van uw schijf nagaan

Moderne Linux systemen zijn standaard uitgerust met geactiveerde smartmontools. Om te controleren of uw harde schijf SMART ondersteunt, start je de opdracht:

dany@laptop:~> sudo smartctl -i /dev/sda
root's password:
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     SAMSUNG MZ7TD256HAFV-000L9
Serial Number:    S17LNSAF241936
LU WWN Device Id: 5 002538 500000000
Firmware Version: DXT02L5Q
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
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 15 13:01:28 2016 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

De uitvoer toont allerlei informatie over de harde schijf. De voorlaatste regel geeft aan dat de harde schijf SMART ondersteunt. De laatste regel geeft aan dat SMART in ingeschakeld. Mocht SMART niet ingeschakeld zijn, schakel deze dan in met:

dany@laptop:~> sudo smartctl -s on /dev/sda
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

Om de volledige SMART informatie van een SATA schijf weer te geven, start je de opdracht:

dany@laptop:~> sudo smartctl -a -d ata /dev/sda
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     SAMSUNG MZ7TD256HAFV-000L9
Serial Number:    S17LNSAF241936
LU WWN Device Id: 5 002538 500000000
Firmware Version: DXT02L5Q
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
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 15 13:52:07 2016 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:  (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:                (53956) seconds.
Offline data collection
capabilities:                    (0x5b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        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:        (  40) minutes.
SCT capabilities:              (0x003d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

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
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1993
 12 Power_Cycle_Count       0x0032   098   098   000    Old_age   Always       -       1617
175 Program_Fail_Count_Chip 0x0032   100   100   010    Old_age   Always       -       0
176 Erase_Fail_Count_Chip   0x0032   100   100   010    Old_age   Always       -       0
177 Wear_Leveling_Count     0x0013   095   095   005    Pre-fail  Always       -       53
178 Used_Rsvd_Blk_Cnt_Chip  0x0013   100   100   010    Pre-fail  Always       -       0
179 Used_Rsvd_Blk_Cnt_Tot   0x0013   100   100   010    Pre-fail  Always       -       0
180 Unused_Rsvd_Blk_Cnt_Tot 0x0013   100   100   010    Pre-fail  Always       -       6240
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   100   010    Pre-fail  Always       -       0
184 End-to-End_Error        0x0033   100   100   097    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0032   070   056   000    Old_age   Always       -       30
195 Hardware_ECC_Recovered  0x001a   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   253   253   000    Old_age   Always       -       0
233 Media_Wearout_Indicator 0x003a   199   199   000    Old_age   Always       -       460801
234 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
235 Unknown_Attribute       0x0012   099   099   000    Old_age   Always       -       78
236 Unknown_Attribute       0x0012   099   099   000    Old_age   Always       -       29
237 Unknown_Attribute       0x0012   099   099   000    Old_age   Always       -       53
238 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       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%       592         -
# 2  Short offline       Completed without error       00%       575         -

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.

Voor IDE schijven gebruik je de opdracht sudo smartctl -a /dev/sda. De toestand van een harde schijf geef je weer met:

dany@laptop:~> sudo smartctl -H /dev/sda
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

Als je in de uitvoer een fout (error) ziet opduiken, maak je best snel een back-up!!! En niet ter vervanging van de vorige back-up, maar een complete extra back-up. In panieksituaties (paniek is altijd een slechte raadgever) worden soms overhaaste en desastreuze beslissingen genomen.

Nu SMART actief is, kan je een aantal testen op uw harde schijf loslaten. Een overzicht van de testen, krijg je met:

dany@laptop:~> sudo smartctl -c /dev/sda
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
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:                (53956) seconds.
Offline data collection
capabilities:                    (0x5b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        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:        (  40) minutes.
SCT capabilities:              (0x003d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

Elke schijf kan een korte (short) en uitgebreide (long) test uitvoeren. Telkens staat vermeld hoelang de test in minuten zal duren. Bij ATA schijven bestaat er een transport (conveyance) test om te controleren of de schijf transportschade heeft opgelopen. Bijvoorbeeld van de fabrikant naar de verdeler of klant. Een korte test start je met:

dany@laptop:~> sudo smartctl --test short /dev/sda
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 2 minutes for test to complete.
Test will complete after Fri Jul 15 14:20:59 2016

Use smartctl -X to abort test.

Daarbij kan je het type test (short) vervangen door long of conveyance. De testen worden steeds op de achtergrond uitgevoerd, waardoor je de voortgang niet op het scherm kunt volgen. Vraag het resultaat van een test op met:

dany@laptop:~> sudo smartctl -l selftest /dev/sda
root's password:
smartctl 6.2 2013-11-07 r3856 [x86_64-linux-4.1.26-21-default] (SUSE RPM)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
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%      1993         -
# 2  Short offline       Completed without error       00%       592         -
# 3  Short offline       Completed without error       00%       575         -

Hoewel de uitvoer meestal heel duidelijk is, kan je bij twijfel steeds de handleiding raadplegen:

dany@laptop:~> man 8 smartctl
SMARTCTL(8)                       2013-11-07                       SMARTCTL(8)



NAME
       smartctl - Control and Monitor Utility for SMART Disks


SYNOPSIS
       smartctl [options] device


FULL PATH
       /usr/sbin/smartctl


PACKAGE VERSION
       smartmontools-6.2 2013-11-07 r3856


DESCRIPTION
       [This man page is generated for the Linux version of smartmontools.  It
       does not contain info specific to other platforms.]
 Manual page smartctl(8) line 1 (press h for help or q to quit)

De gezondheid van uw schijven automatisch opvolgen

Moderne distributies gebruiken de dienst (daemon) smartd om de gezondheid van uw harde schijven in het oog te houden. De status van deze dienst kan je opvragen met:

dany@laptop:~> systemctl status smartd.service -l
smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled)
   Active: active (running) since vr 2016-07-15 11:24:17 CEST; 3h 17min ago
 Main PID: 805 (smartd)
   CGroup: /system.slice/smartd.service
           └─805 /usr/sbin/smartd -n

Meer informatie over de smartd dienst kan je opvragen met:

dany@laptop:~> man 8 smartd

En zijn configuratie met:

dany@laptop:~> man 5 smartd.conf

De meeste distributies leveren hier uitstekend werk.