Merevlemez állapotának ellenőrzése Smartmontools-al

Útmutató a smartmontools csomag telepítéséhez és használatához Debian és Ubuntu rendszereken.
A smartmontools csomag egy alkalmazás amely segítségével információkat nyerhetünk ki a számítógépünk merevlemezeinek állapotáról, erodálásáról, esetleges hibáiról.

A smartmontools telepítése:

sudo apt-get install smartmontools

A smartmontools csomagban két alkalmazás található:

  • smartctl – segítségével parancssorból részletes információt kaphatunk a merevlemez állapotáról
  • smartd – démon, amely bizonyos időközönként ellenőrzi a merevlemez állapotát és az esetleges figyelmeztetéseket, hibákat naplózza a /var/syslog napló fileba. Továbbá beállíthatjuk, hogy az esetleges hibákról értesítőt küldjön egy tetszőleges email címre.

A smartctl használata:

Mielőtt rátérnénk a parancs paraméterezésére, győződjünk meg a tesztelendő merevlemez elnevezéséről.

fdisk -l
 

server1:~# fdisk -l
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 19269 154778211 83 Linux
/dev/hda2 19270 19457 1510110 5 Extended
/dev/hda5 19270 19457 1510078+ 82 Linux swap / Solaris
server1:~#

Ahogy latszik a példában szereplő szerver eseteben a merevlemez elnevezése: /dev/sda

smartctl -a /dev/sda

Ha elsőnek futtatjuk a parancsot valószínűleg a következő kimenetet látjuk:

server1:~# smartctl -a /dev/sda
smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: ST3160022ACE
Serial Number: 5JS3XTZX
Firmware Version: 9.01
User Capacity: 160,041,885,696 bytes
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 T13 1410D revision 2
Local Time is: Tue Apr 8 18:58:44 2008 CEST
SMART support is: Available – device has SMART capability.
SMART support is: Disabled
SMART Disabled. Use option -s with argument ‘on’ to enable it.

Tehát a SMART nincs engedélyezve. A következő paranccsal engedélyezhetjük:

smartctl -s on -a /dev/sda

Így most lényegesen több információt kapunk, amely tartalmazza az összes hibát ami fellelhető a SMART naplóban.

server1:~# smartctl -s on -a /dev/hda
smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model:     ST3160022ACE
Serial Number:    5JS3XTZX
Firmware Version: 9.01
User Capacity:    160,041,885,696 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   6
ATA Standard is:  ATA/ATAPI-6 T13 1410D revision 2
Local Time is:    Tue Apr  8 18:59:14 2008 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART 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:                 (15556) 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:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 111) minutes.
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   059   056   006    Pre-fail  Always       -       163692057
  3 Spin_Up_Time            0x0003   096   096   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       0
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   100   253   030    Pre-fail  Always       -       722959
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       55
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       37
194 Temperature_Celsius     0x0022   039   046   000    Old_age   Always       -       39
195 Hardware_ECC_Recovered  0x001a   059   056   000    Old_age   Always       -       163692057
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   199   000    Old_age   Always       -       1
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 Error Log Version: 1
ATA Error Count: 1
        CR = Command Register [HEX]
        FR = Features Register [HEX]
        SC = Sector Count Register [HEX]
        SN = Sector Number Register [HEX]
        CL = Cylinder Low Register [HEX]
        CH = Cylinder High Register [HEX]
        DH = Device/Head Register [HEX]
        DC = Device Command Register [HEX]
        ER = Error register [HEX]
        ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.
Error 1 occurred at disk power-on lifetime: 28 hours (1 days + 4 hours)
  When the command that caused the error occurred, the device was active or idle.
  After command completion occurred, registers were:
  ER ST SC SN CL CH DH
  -- -- -- -- -- -- --
  84 51 00 5d 4c 85 e0  Error: ICRC, ABRT at LBA = 0x00854c5d = 8735837
  Commands leading to the command that caused the error were:
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name
  -- -- -- -- -- -- -- --  ----------------  --------------------
  25 00 00 5d 4c 85 e0 00      05:05:31.855  READ DMA EXT
  25 00 00 5d 4b 85 e0 00      05:05:31.810  READ DMA EXT
  25 00 00 5d 4a 85 e0 00      05:05:31.773  READ DMA EXT
  25 00 00 5d 49 85 e0 00      05:05:31.737  READ DMA EXT
  25 00 00 5d 48 85 e0 00      05:05:31.651  READ DMA EXT
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%        54         -
# 2  Short offline       Aborted by host               80%        54         -
# 3  Short offline       Completed without error       00%        54         -
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.
server1:~#

Jelenleg a SMART engedélyezve van, így legközelebb már nem szükséges a -s on kapcsoló használata!

A smartd használata:

A smartd megadott időközönként ellenőrzi a merevlemezt es figyelmeztet az esetleges meghibásodásokról, így időben (akar automatikusan, script segítségével) másolatot készíthetünk a merevlemez adatairól, megelőzve az teljes adatvesztést.
A smartd használatához szerkesztenünk kell a /etc/default/smartmontools file. Konkrétan uncomment-elnünk kell a következő sorokat:

start_smartd=yes
smartd_opts="--interval=1800"

A smartdemont a következő paranccsal indítjuk:

sudo /etc/init.d/smartmontools start

Ha most belenézünk a syslog fileba látni fogjuk, hogy a smartdemon sikeresen indult e el, ugyanakkor minden ellenőrzés után az esetleges változásokat naplózza.

tail -n50 /var/log/syslog
[...]
Apr  8 19:12:17 server1 smartd[3731]: smartd version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Apr  8 19:12:17 server1 smartd[3731]: Home page is http://smartmontools.sourceforge.net/
Apr  8 19:12:17 server1 smartd[3731]: Opened configuration file /etc/smartd.conf
Apr  8 19:12:17 server1 smartd[3731]: Drive: DEVICESCAN, implied '-a' Directive on line 22 of file /etc/smartd.conf
Apr  8 19:12:17 server1 smartd[3731]: Configuration file /etc/smartd.conf was parsed, found DEVICESCAN, scanning devices
Apr  8 19:12:17 server1 smartd[3731]: Problem creating device name scan list
Apr  8 19:12:17 server1 smartd[3731]: Device: /dev/hda, opened
Apr  8 19:12:17 server1 smartd[3731]: Device: /dev/hda, not found in smartd database.
Apr  8 19:12:17 server1 smartd[3731]: Device: /dev/hda, is SMART capable. Adding to "monitor" list.
Apr  8 19:12:17 server1 smartd[3731]: Device: /dev/hdc, opened
Apr  8 19:12:17 server1 smartd[3731]: Device: /dev/hdc, packet devices [this device CD/DVD] not SMART capable
Apr  8 19:12:17 server1 smartd[3731]: Monitoring 1 ATA and 0 SCSI devices
Apr  8 19:12:17 server1 smartd[3733]: smartd has fork()ed into background mode. New PID=3733.
Apr  8 19:12:17 server1 smartd[3733]: file /var/run/smartd.pid written containing PID 3733
[...]
Apr  8 19:36:01 server2 smartd[13160]: Device: /dev/hda, SMART Usage Attribute: 194 Temperature_Celsius changed from 36 to 37

A további beállításokról részletesebb információk a man smartd manuálban találhatóak.
Forrás: howtoforge.com (angol nyelvű)

2 thoughts on “Merevlemez állapotának ellenőrzése Smartmontools-al

  1. Én így használom, hogy rendszeresen indítson self és long tesztet is:
    /dev/sda -d ata -a -o on -S on -s (S/../.././02|L/../../6/03) -m root
    A root-nak be van állítva mailcím a /etc/aliases-ben.
    Idozito beallitasa: T/MM/DD/d/HH
    T Test tipusa, L = Logn Self-Test, S = Sort Self-Test, C = Conveyance Self-Test (ATA only), O = Offline Immediate Test (ATA only)
    MM Az ev honapjai 01-12-ig
    DD A hónap apjai 01-31-ig
    d A hét napjai 1(hétfő)-től 7(vasárnap)-ig
    HH A nap órái 00-23 óráig

  2. Visszajelzés: Recent Links Tagged With "howtoforge" - JabberTags

Vélemény, hozzászólás?

Az e-mail címet nem tesszük közzé. A kötelező mezőket * karakterrel jelöltük

Ez az oldal az Akismet szolgáltatást használja a spam csökkentésére. Ismerje meg a hozzászólás adatainak feldolgozását .