Smartmontools

0% Status
Z Wikibooks, biblioteki wolnych podręczników.

smartmontools - zestaw programów do obsługi systemu S.M.A.R.T.

Na pakiet smartmontools składają się dwa programy smartctl i smartd. Pierwszy z nich to uniwersalne narzędzie od konfiguracji, uruchamiania testów i odczytywania z dysku informacji o jego stanie. Smartd odpowiada natomiast za monitorowanie dysku. Programy te działają w środowisku systemów operacyjnych Linux, FreeBSD, NetBSD, Solaris oraz Microsoft Windows.


Instalacja[edytuj]

Ubuntu/Linux Mint:

sudo apt-get install smartmontools

Debian (z konta roota):

apt-get install smartmontools

Archlinux (z konta roota):

pacman -S smartmontools

Lista zamontowanych dysków[edytuj]

W Ubuntu możemy to sprawdzić za pomocą komendy :

sudo fdisk -l


Odczytywanie informacji o dysku[edytuj]

Podstawowe informacje o dysku twardym możemy wyświetlić uruchamiając smartctl z opcją -i. Dla przykładowego dysku Seagate Barracuda program wyświetlił następujące informacje:

kb@techie:~$ sudo /usr/sbin/smartctl -i /dev/hda
smartctl version 5.32 Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model:     ST3160023A
Serial Number:    3JS2DNYN
Firmware Version: 3.06
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 2
Local Time is:    Sat Aug  7 15:25:15 2004 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Dwie ostatnie linijki informują o dostępności i aktywności S.M.A.R.T.

Włączanie S.M.A.R.T.[edytuj]

Aby włączyć S.M.A.R.T. dla dysku /dev/hda użyjemy następujących opcji: --smart=on - włącza S.M.A.R.T., --offlineauto=on - włącza test offline co cztery godziny oraz --saveauto=on - włącza zapisywanie atrybutów, aby nie były tracone po zaniku zasilania.
Przykładowe wywołanie:

kb@techie:~$ sudo /usr/sbin/smartctl --smart=on --offlineauto=on --saveauto=on /dev/hda
smartctl version 5.32 Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
SMART Attribute Autosave Enabled.
SMART Automatic Offline Testing Enabled every four hours.

Odczytywanie logu[edytuj]

Odczytanie dokładnych informacji o dysku umożliwia opcja --attributes w połączeniu z --log=selftest. Oto przykładowe informacje:

kb@techie:~$ sudo /usr/sbin/smartctl --attributes --log=selftest /dev/hda
smartctl version 5.32 Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
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   063   058   006    Pre-fail  Always       -       121669089
  3 Spin_Up_Time            0x0003   096   096   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       16
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   075   060   030    Pre-fail  Always       -       31597920
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1059
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       299
194 Temperature_Celsius     0x0022   039   046   000    Old_age   Always       -       39
195 Hardware_ECC_Recovered  0x001a   063   058   000    Old_age   Always       -       121669089
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
200 Multi_Zone_Error_Rate   0x0000   100   253   000    Old_age   Offline      -       0
202 TA_Increase_Count       0x0032   100   253   000    Old_age   Always       -       0

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%       799         -
# 2  Short offline       Completed without error       00%       797         -
# 3  Short offline       Completed without error       00%       504         -
# 4  Extended offline    Completed without error       00%       504         -
# 5  Extended offline    Completed without error       00%       471         -
# 6  Short offline       Completed without error       00%       469         -
# 7  Extended offline    Completed without error       00%       170         -
# 8  Short offline       Completed without error       00%       169         -
# 9  Short offline       Completed without error       00%       159         -
#10  Extended offline    Completed without error       00%        81         -
#11  Short offline       Completed without error       00%        79         -
#12  Short offline       Completed without error       00%        31         -
#13  Extended offline    Completed without error       00%        28         -
#14  Short offline       Completed without error       00%        27         -
#15  Short offline       Completed without error       00%        23         -
#16  Short offline       Completed without error       00%        16         -
#17  Short offline       Completed without error       00%         4         -
#18  Conveyance captive  Fatal or unknown error        00%         4         -
#19  Conveyance offline  Fatal or unknown error        00%         4         -
#20  Extended offline    Completed without error       00%         1         -
#21  Short offline       Completed without error       00%         0         -

Dla przykładu zinterpretujmy linię:

194 Temperature_Celsius     0x0022   039   046   000    Old_age   Always       -       39

Wartość w kolumnie VALUE to aktualna temperatura dysku - wynosi ona 39*C, natomiast najgorsza temperatura w jakiej dysk pracował to 46*C (kolumna WORST).

Wiersz:

#19  Conveyance offline  Fatal or unknown error        00%         4         -

zawiera informację o wystąpieniu krytycznego lub nieznanego błędu podczas próby wykonania testu typu conveyance - jest to spowodowane brakiem obsługi tego typu testu przez ten model dysku twardego. Test został wykonany w 4 godzinie "życia dysku" (ang. life time).

Uruchamianie testu[edytuj]

Test uruchamiamy poleceniem smartctl -t argument parametru -t wybiera rodzaj testu. Dla przykładu przeprowadzę na moim dysku test offline. Oto komunikaty programu:

kb@techie:~$ sudo /usr/sbin/smartctl -t offline /dev/hda
smartctl version 5.32 Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART off-line routine immediately in off-line mode".
Drive command "Execute SMART off-line routine immediately in off-line mode" successful.
Testing has begun.
Please wait 430 seconds for test to complete.
Test will complete after Sat Aug  7 15:28:48 2004

Use smartctl -X to abort test.

smartd[edytuj]

Ręczne sprawdzanie informacji o dysku jest skrajnie niewygodne - smartd automatyzuje ten proces. Co 30 minut (czas ten można skonfigurować) sprawdza stan dysku i porównuje z ostatnio zapisanym. Wszelkie różnice wysyła do programu syslog, który zapisuje je w dzienniku systemowym. Przykładowa informacja o wzroście temperatury może wyglądać tak:

Aug  7 12:26:23 localhost smartd[2513]:
Device: /dev/hda, SMART Usage Attribute: 194 Temperature_Celsius changed from 34 to 37