概念
smartd由kernel-utils包預設安裝。用命令 rpm -ql kernel-utils 可以列出kernel-utils包中的檔案。
smartd守護進程通常在系統啟動的時候被開啟,它的配置檔案是/etc/smartd.conf。
比如,假設有兩個硬碟被安裝,/dev/hda和/dev/hdb。一個是CD_ROM設備,另一個是硬碟。為了檢測它們是否支持SMART,使用命令 smartctl -i /dev/hda 和 smartctl -i /dev/hdb:
# /usr/sbin/smartctl -i /dev/hdasmartctl version 5.1-11 Copyright (C) 2002-3 Bruce AllenHome page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION ===Device Model: ST380011ASerial Number: 3JVB672NFirmware Version: 8.01Device is: Not in smartctl database [for details use: -P showall]ATA Version is: 6ATA Standard is: ATA/ATAPI-6 T13 1410D revision 2Local Time is: Fri Aug 20 14:09:16 2004 ESTSMART support is: Available - device has SMART capability.SMART support is: Enabled”SMART support is: Available - device has SMART capability.“這行說明支持SMART。"SMART support is: Enabled”這行說明SMART已經被打開。
CD-ROM設備和舊式的硬碟不支持SMART,這可以從smartctl -i /dev/hdb的輸出看出:
# /usr/sbin/smartctl -i /dev/hdbsmartctl version 5.1-11 Copyright (C) 2002-3 Bruce AllenHome page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION ===Device Model: LTN526DSerial Number: [No Information Found]Firmware Version: 9S03Device is: Not in smartctl database [for details use: -P showall]ATA Version is: 1ATA Standard is: Exact ATA specification draft version not indicatedLocal Time is: Fri Aug 20 14:24:43 2004 ESTSMART is only available in ATA Version 3 Revision 3 or greater.We will try to proceed in spite of this.SMART support is: unavailable - device lacks SMART capability.A mandatory SMART command has failed: exiting. To continue, use the -T option to set the tolerance level to 'permissive' 注意有些硬碟控制器不支持SMART。比如有些硬體RAID控制器不支持,或者不會傳遞SMART信息,即使加入的硬碟支持SMART。
可以修改/etc/smartctl.conf檔案,使得smartd只監視你想監視的設備。假設只有/dev/hda需要被監視,在該設備上如果有警告信息發生,需要把它發給根用戶,那么/etc/smartd.conf需要這樣修改:
# /etc/smartd.conf# Sample configuration file for smartd. See man 5 smartd.conf.# Home page is: http://smartmontools.sourceforge.net...# A very silent check. Only report SMART health status if it fails# But send an email in this case/dev/hda -a -m [email protected] ... 編輯完/etc/smartd.conf,重啟該守護進程:
# /sbin/service smartd restartShutting down smartd: [FAILED]Starting smartd: [ OK ]
要設定smartd在系統啟動時候被激活,在根用戶下用 chkconfig smartd on 命令。
#chkconfig smartd off
這是關閉smartd服務自動啟動,機器重新啟動時smartd不再運行!
smartd使用
smartd是一個守護進程(一個幫助程式),它能監視擁有自我監視,分析和匯報技術(Self-Monitoring, Analysis, and Reporting Technology - SMART)的硬碟。
SMART系統使得硬碟能監視並匯報自己的運行狀況。它的一個重要特性是能夠預測失敗,使得系統管理員能避免數據丟失。
smartd由kernel-utils包預設安裝。用命令 rpm -ql kernel-utils 可以列出kernel-utils包中的檔案。
smartd守護進程通常在系統啟動的時候被開啟,它的配置檔案是/etc/smartd.conf。
比如,假設有兩個硬碟被安裝,/dev/hda和/dev/hdb。一個是CD_ROM設備,另一個是硬碟。為了檢測它們是否支持SMART,使用命令 smartctl -i /dev/hda 和 smartctl -i /dev/hdb:
# /usr/sbin/smartctl -i /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: ST380011A
Serial Number: 3JVB672N
Firmware Version: 8.01
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: Fri Aug 20 14:09:16 2004 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
”SMART support is: Available - device has SMART capability.“這行說明支持SMART。"SMART support is: Enabled”這行說明SMART已經被打開。
CD-ROM設備和舊式的硬碟不支持SMART,這可以從smartctl -i /dev/hdb的輸出看出:
# /usr/sbin/smartctl -i /dev/hdb
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: LTN526D
Serial Number: [No Information Found]
Firmware Version: 9S03
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 1
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Fri Aug 20 14:24:43 2004 EST
SMART is only available in ATA Version 3 Revision 3 or greater.
We will try to proceed in spite of this.
SMART support is: Unavailable - device lacks SMART capability.
A mandatory SMART command has failed: exiting. To continue, use the -T
option to set the tolerance level to 'permissive'
注意有些硬碟控制器不支持SMART。比如有些硬體RAID控制器不支持,或者不會傳遞SMART信息,即使加入的硬碟支持SMART。
可以修改/etc/smartctl.conf(註:應是 /etc/smart.conf ?)檔案,使得smartd只監視你想監視的設備。假設只有/dev/hda需要被監視,在該設備上如果有警告信息發生,需要把它發給根用戶,那么/etc/smartd.conf需要這樣修改:
# /etc/smartd.conf
# Sample configuration file for smartd. See man 5 smartd.conf.
# Home page is: http://smartmontools.sourceforge.net
...
# A very silent check. Only report SMART health status if it fails
# But send an email in this case
/dev/hda -a -m [email protected] ...
編輯完/etc/smartd.conf,重啟該守護進程:
# /sbin/service smartd restart
Shutting down smartd: [FAILED]
Starting smartd: [ OK ]
要設定smartd在系統啟動時候被激活,在根用戶下用 chkconfig smartd on 命令。
/etc/smartd.conf檔案寫的很好,有很多例子可以參考。
關於Linux smartmon工具的更多信息,可以在
http://smartmontools.sourceforge.net
找到。關於SMART的常用信息,可以在
http://smartmontools.sourceforge.net/#references
找到。
[root@anima lwg]# /usr/sbin/smartctl -i /dev/hda
smartctl version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: maxtor 6Y080L0
Serial Number: Y2NCM7GE
Firmware Version: YAR41BW0
User Capacity: 81,964,302,336 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 0
Local Time is: Tue Sep 19 15:06:58 2006 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
[root@anima lwg]# /usr/sbin/smartctl -i /dev/hdc
smartctl version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: ATAPI-CD ROM-DRIVE-52MAX
Serial Number: [No Information Found]
Firmware Version: Ver 52E4
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 1
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Tue Sep 19 15:07:04 2006 CST
SMART is only available in ATA Version 3 Revision 3 or greater.
We will try to proceed in spite of this.
SMART support is: Unavailable - Packet Interface Devices [this device: CD/DVD] don't support ATA SMART
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.
[root@anima lwg]# /usr/sbin/smartctl -i /dev/hdd
smartctl version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model: Maxtor 6Y060L0
Serial Number: Y2N48WXE
Firmware Version: YAR41BW0
User Capacity: 61,492,838,400 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 0
Local Time is: Tue Sep 19 15:07:07 2006 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
[root@anima lwg]# /etc/init.d/smartd restart
Shutting down smartd: [FAILED]
Starting smartd: [FAILED]
[root@anima lwg]# cat /etc/smartd.conf
/dev/hda -H -m [email protected]
/dev/hdb -H -m [email protected]
[root@anima lwg]# cp /etc/smartd.conf /etc/smartd.conf.bak
[root@anima lwg]# vim /etc/smartd.conf
#修改了監視設備,並設定在相應設備上如果有警告信息發生,需要把它發給根用戶。
#下列兩行注釋是原文內容:
#/dev/hda -H -m [email protected]
#/dev/hdb -H -m [email protected]
/dev/hda -a -m [email protected]
/dev/hdd -a -m [email protected]
[root@anima lwg]#
[root@anima lwg]# /etc/init.d/smartd restart
Shutting down smartd: [FAILED]
Starting smartd: [ OK ]
[root@anima lwg]#
[root@anima lwg]# /usr/sbin/smartd --help
smartd version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
Usage: smartd [options]
-c NAME|-, --configfile=NAME|-
Read configuration file NAME or stdin [default is /etc/smartd.conf]
-d, --debug
Start smartd in debug mode
-D, --showdirectives
Print the configuration file Directives and exit
-h, --help, --usage
Display this help and exit
-i N, --interval=N
Set interval between disk checks to N seconds, where N >= 10
-l local[0-7], --logfacility=local[0-7]
Use syslog facility local0 - local7 or daemon [default]
-p NAME, --pidfile=NAME
Write PID file NAME
-q WHEN, --quit=WHEN
Quit on one of: nodev, errors, nodevstartup, never, onecheck
-r, --report=TYPE
Report transactions for one of: ioctl[,N], ataioctl[,N], scsiioctl[,N]
-V, --version, --license, --copyright
Print License, Copyright, and version information
[root@anima lwg]# /usr/sbin/smartctl --help
smartctl version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
Usage: smartctl [options] device
============================================ SHOW INFORMATION OPTIONS =====
-h, --help, --usage
Display this help and exit
-V, --version, --copyright, --license
Print license, copyright, and version information and exit
-i, --info
Show identity information for device
-a, --all
Show all SMART information for device
================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====
-q TYPE, --quietmode=TYPE (ATA)
Set smartctl quiet mode to one of: errorsonly, silent
-d TYPE, --device=TYPE
Specify device type to one of: ata, scsi, marvell, 3ware,N
-T TYPE, --tolerance=TYPE (ATA)
Tolerance: normal, conservative, permissive, verypermissive
-b TYPE, --badsum=TYPE (ATA)
Set action on bad checksum to one of: warn, exit, ignore
-r TYPE, --report=TYPE
Report transactions (see man page)
============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====
-s VALUE, --smart=VALUE
Enable/disable SMART on device (on/off)
-o VALUE, --offlineauto=VALUE (ATA)
Enable/disable automatic offline testing on device (on/off)
-S VALUE, --saveauto=VALUE (ATA)
Enable/disable Attribute autosave on device (on/off)
======================================= READ AND DISPLAY DATA OPTIONS =====
-H, --health
Show device SMART health status
-c, --capabilities (ATA)
Show device SMART capabilities
-A, --attributes
Show device SMART vendor-specific Attributes and values
-l TYPE, --log=TYPE
Show device log. TYPE: error, selftest, selective, directory
-v N,OPTION , --vendorattribute=N,OPTION (ATA)
Set display OPTION for vendor Attribute N (see man page)
-F TYPE, --firmwarebug=TYPE (ATA)
Use firmware bug workaround: none, samsung, samsung2
-P TYPE, --presets=TYPE (ATA)
Drive-specific presets: use, ignore, show, showall
============================================ DEVICE SELF-TEST OPTIONS =====
-t TEST, --test=TEST
Run test. TEST is: offline short long conveyance select,M-N pending,N afterselect,on afterselect,off
-C, --captive
Do test in captive mode (along with -t)
-X, --abort
Abort any non-captive test on device
=================================================== SMARTCTL EXAMPLES =====
smartctl -a /dev/hda (Prints all SMART information)
smartctl --smart=on --offlineauto=on --saveauto=on /dev/hda
(Enables SMART on first disk)
smartctl -t long /dev/hda (Executes extended disk self-test)
smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hda
(Prints Self-Test & Attribute errors)
smartctl -a --device=3ware,2 /dev/sda
(Prints all SMART info for 3rd ATA disk on 3ware RAID controller)
[root@anima lwg]#