S.M.A.R.T. – Monitorování disků
Monitorování disků je možné pomocí sady nástrojů smartmontools, která obsahuje smartctl a smartd. Smartctl je nástroj, který zkontroluje data zapsaná ve vlastní paměti disku. Každý disk má totiž čip a firmware od výrobce pro ovládání, který uchovává data ohledně zápisu a čtení, životnosti, provozu a ještě více. Firmware disku lze v některých případech aktualizovat.
Tato data odpovídají standardu S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) a na základě získaných dat se vyhodnotí stav pevného disku. Dnes již všechny disky tento standard podporují, v Linuxu a FreeBSD je možné použít balíček smartmontools, který obsahuje smartctl a smartd.
Při reklamaci disku může být uznán i výpis S.M.A.R.T. dat z disku, ale nemusí být uznána, pokud obsahuje také záznam o přehřátí disku.

Obsah:
Monitorování disku smartd
Démon pro SMART monitorování disku se jmenuje smartd a jestliže běží, zaznamenává data do systémového logu buď do umístění /var/log/syslog anebo /var/log/messages.
smartd
Instalace na CentOS
Pro instalaci slouží balíček smartmontools a pro démona smartd je potřeba spustit a zaktivnit službu.
Instalace balíčku smartmontools:
yum install smartmontools
Spuštění služby smartd:
chkconfig smartd on
service smartd start
Zjištění stavu služby pomocí příkazu:
service smartd status
Instalace na FreeBSD
Pro instalaci slouží balíček smartmontools. Instalace balíčku pomocí pkg:
pkg install smartmontools
Pro monitorování musíme spouštět démona smartd po startu, to docílíme zapsáním povelu pro start programu do /etc/rc.conf:
smartd_enable="YES"
Po instalaci se vytvoří vzorové nastavení, které se nachází v umístění /usr/local/etc/smartd.conf.sample.
Test disku
Kromě stálého monitorování disků je možné také zkontrolovat stav vybraného disku. Pro nahlédnutí přikládám výpis smartctl.
Smartctl kontrola S.M.A.R.T údajů:
smartctl -a /dev/sdb
Selftest disku:
smartctl -l selftest /dev/sdb
Pokud dojde při kontrole k nalezení chyby, bude zapsán záznam o začátku LBA sektoru s chybou, následně již neprobíhá další testování, jestliže byla nalezena chyba.
Atributy a hodnoty
Selftest
Níže je význam položek testů a jejich hodnot pro různé testy a situace. Selftest provedeme například příkazem smartctl -l selftest /dev/sda. Pro nahlédnutí výpisu selftestu se podívejte do příkladu – selftest.
- Num znamená číslo testu
- Test_Description je popis testu
- Status stav a hodnocení testu
- Remaining zbývající část k dokončení
- LifeTime (hours) je záznam o době chodu disku a udává se v hodinách
- LBA_of_first_error značí případné chyby na LBA sektoru, zobrazí pouze první číslo chyby sektoru, zbytek už netestuje
Příklady výpisů
smartctl -a /dev/sdb smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.12.14-lp151.28.48-default] (SUSE RPM) Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Seagate Barracuda 7200.14 (AF) Device Model: ST500DM002-1BD142 Serial Number: W3TKL9W1 LU WWN Device Id: 5 000c50 08ab488ae Firmware Version: KC48 User Capacity: 500,107,862,016 bytes [500 GB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 7200 rpm Device is: In smartctl database [for details use: -P show] ATA Version is: ATA8-ACS T13/1699-D revision 4 SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Wed Jul 8 09:34:23 2020 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: ( 600) 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: ( 1) minutes. Extended self-test routine recommended polling time: ( 85) minutes. Conveyance self-test routine recommended polling time: ( 2) minutes. SCT capabilities: (0x303f) SCT Status supported. SCT Error Recovery Control supported. SCT Feature Control supported. SCT Data Table supported. SMART Attributes Data Structure revision number: 10 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x000f 102 099 006 Pre-fail Always - 4125544 3 Spin_Up_Time 0x0003 100 100 000 Pre-fail Always - 0 4 Start_Stop_Count 0x0032 096 096 020 Old_age Always - 4128 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0 7 Seek_Error_Rate 0x000f 082 060 030 Pre-fail Always - 170446633 9 Power_On_Hours 0x0032 055 055 000 Old_age Always - 40265 10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 123 183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0 184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0 187 Reported_Uncorrect 0x0032 090 090 000 Old_age Always - 10 188 Command_Timeout 0x0032 100 100 000 Old_age Always - 0 0 0 189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0 190 Airflow_Temperature_Cel 0x0022 063 052 045 Old_age Always - 37 (Min/Max 35/41) 194 Temperature_Celsius 0x0022 037 048 000 Old_age Always - 37 (0 19 0 0 0) 195 Hardware_ECC_Recovered 0x001a 042 034 000 Old_age Always - 4125544 197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0 240 Head_Flying_Hours 0x0000 100 253 000 Old_age Offline - 40258h+38m+34.233s 241 Total_LBAs_Written 0x0000 100 253 000 Old_age Offline - 2876196260 242 Total_LBAs_Read 0x0000 100 253 000 Old_age Offline - 2489507036 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% 40259 - 2 Short offline Completed without error 00% 40235 - 3 Short offline Completed without error 00% 40211 - 4 Short offline Completed without error 00% 40187 - 5 Extended offline Interrupted (host reset) 90% 40185 - 6 Short offline Completed without error 00% 40163 - 7 Short offline Completed without error 00% 40139 - 8 Short offline Completed without error 00% 40115 - 9 Short offline Completed without error 00% 40091 - 10 Short offline Completed without error 00% 40067 - 11 Short offline Completed without error 00% 40043 - 12 Short offline Completed without error 00% 40019 - 13 Short offline Completed without error 00% 39995 - 14 Short offline Completed without error 00% 39971 - 15 Short offline Completed without error 00% 39947 - 16 Extended offline Interrupted (host reset) 70% 39936 - 17 Short offline Completed without error 00% 39933 - 18 Short offline Completed without error 00% 39929 - 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.
Smartctl získání dat S.M.A.R.T.
smartctl -a /dev/sda smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.12.14-lp151.28.52-default] (SUSE R PM) Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Device Model: TOSHIBA MQ01ACF050 Serial Number: 16IOCZFLT LU WWN Device Id: 5 000039 6c3e857bf Firmware Version: AV001D User Capacity: 500,107,862,016 bytes [500 GB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 7200 rpm Form Factor: 2.5 inches Device is: Not in smartctl database [for details use: -P showall] ATA Version is: ATA8-ACS (minor revision not indicated) SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Wed Jul 8 09:37:48 2020 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: ( 120) seconds. Offline data collection capabilities: (0x5b) SMART execute Offline immediate. Auto Offline data collection on/off supp ort. 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: ( 95) 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: 128 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_ FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x000b 100 100 050 Pre-fail Always - 0 3 Spin_Up_Time 0x0027 100 100 001 Pre-fail Always - 1543 5 Reallocated_Sector_Ct 0x0033 100 100 050 Pre-fail Always - 0 9 Power_On_Hours 0x0032 029 029 000 Old_age Always - 28571 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 174 191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 41 192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 67 193 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 6296 194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 43 (Min/Max 15/61) 199 UDMA_CRC_Error_Count 0x0032 100 100 000 Old_age Always - 555408672 200 Multi_Zone_Error_Rate 0x0032 100 100 000 Old_age Always - 1203704578 240 Head_Flying_Hours 0x0032 029 029 000 Old_age Always - 28515 241 Total_LBAs_Written 0x0032 100 100 000 Old_age Always - 28638771284 242 Total_LBAs_Read 0x0032 100 100 000 Old_age Always - 36255135226 254 Free_Fall_Sensor 0x0032 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% 28565 - 2 Short offline Completed without error 00% 28541 - 3 Short offline Completed without error 00% 28517 - 4 Short offline Completed without error 00% 28493 - 5 Extended offline Completed without error 00% 28493 - 6 Short offline Completed without error 00% 28469 - 7 Short offline Completed without error 00% 28450 - 8 Short offline Completed without error 00% 28428 - 9 Short offline Completed without error 00% 28404 - 10 Short offline Completed without error 00% 28385 - 11 Extended offline Aborted by host 90% 28284 - 12 Short offline Completed without error 00% 28284 - 13 Short offline Completed without error 00% 0 - 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.
Selftest
smartctl -l selftest /dev/sda smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.12.14-lp151.28.52-default] (SUSE RPM) Copyright (C) 2002-17, 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% 28565 - 2 Short offline Completed without error 00% 28541 - 3 Short offline Completed without error 00% 28517 - 4 Short offline Completed without error 00% 28493 - 5 Extended offline Completed without error 00% 28493 - 6 Short offline Completed without error 00% 28469 - 7 Short offline Completed without error 00% 28450 - 8 Short offline Completed without error 00% 28428 - 9 Short offline Completed without error 00% 28404 - 10 Short offline Completed without error 00% 28385 - 11 Extended offline Aborted by host 90% 28284 - 12 Short offline Completed without error 00% 28284 - 13 Short offline Completed without error 00% 0 -
Poznámky k chybám a upozorněním
Někdy můžeme v logu narazit na následující chyby:
- SMART Prefailure Attribute: 1 Raw_Read_Error_Rate changed from 103 to 104 je často vyskytující se chyba/upozornění vyskytující se v záznamu událostí, dané hodnoty jsou variabilní, můžeme jej ignorovat
- SMART Usage Attribute: 195 Hardware_ECC_Recovered changed from 37 to 38 jestliže tyto údaje kolísají ve velkých skocích na menší hodnoty, znamená to, že je pro disk problém dostat se k některým datům (vyšší hodnoty jsou dobré, nízké hodnoty a výkyvy jsou špatné)
- SMART Usage Attribute: 194 Temperature_Celsius changed from 38 to 39 záznam o změně teploty, nemusí nás zajímat
Pro detailnější popis chyb a vysvětlivky můžeme kouknout na odkaz wiki.unraid.net/Understanding_SMART_Reports.