smartmontools によるハードディスクの自己診断機能
はじめに
smartmontools は HDD の S.M.A.R.T 情報を簡単に取得できサーバ等のHDD状態を診断してエラーなどがあるとメールでお知らせしてくれる機能を持っています。HDDが完全に故障する前に検知することが可能となりデータの保全をすることが出来ます。 Install
portsのsysutils/smartmontoolsからインストール。
# portinstall sysutils/smartmontools
/etc/rc.confに以下の行を追加
smartd_enable="YES"
設定ファイル
/usr/local/etc/smartd.conf の書き方は、man smartd.confやサンプルファイル(/usr/local/etc/smartd.conf.sample)を参照。 通常は、DEVICESCAN行をコメントアウトした上で、
#DEVICESCAN # First (primary) ATA/IDE hard disk. Monitor all attributes, enable # automatic online data collection, automatic Attribute autosave, and # start a short self-test every day between 2-3am, and a long self test # Saturdays between 3-4am. /dev/ad4 -a -o on -S on -s (S/../.././02|L/../../6/03) -H -m alert@example.com
上記のような書き方をしてればOKです。最後の通知先メールアドレスは適宜変更すること、エラーが検知されるとアラートメールが飛んできます。
テストの内容
- 毎日2-3時の間にshortテスト
- 毎週日曜日3-4時にlongテスト
起動
# /usr/local/etc/rc.d/smartd start
コマンド
セルフテスト
shot test
# smartctl -t shot /dev/ada0
long test
# smartctl -t long /dev/ada0
セルフテストの結果表示は smartctl -a /dev/ada0 コマンドの一番最後に出てきます。shortテストで約1分、longテストで約60分時間がかかる
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% 20292 - # 2 Extended offline Completed without error 00% 20283 -
ステータス確認
# smartctl -a /dev/hda
エラーログを確認
# smartctl -l error /dev/hda smartctl 6.0 2012-10-10 r3643 [FreeBSD 9.1-PRERELEASE amd64] (local build) Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART Error Log Version: 1 No Errors Logged
ドライブの診断実行例
# smartctl -a /dev/ada0 [9/1844]
smartctl 6.0 2012-10-10 r3643 [FreeBSD 9.1-PRERELEASE amd64] (local build)
Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Hitachi Deskstar 7K250
Device Model: HDS722516VLSA80
Serial Number: VN6DTECDERW5RA
Firmware Version: V34OA6MA
User Capacity: 164,696,555,520 bytes [164 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA/ATAPI-6 T13/1410D revision 3a
Local Time is: Sun Nov 25 23:00:18 2012 JST
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: (0x80) Offline data collection activity
was never started.
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: ( 3585) seconds.
Offline data collection
capabilities: (0x1b) 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.
No 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: ( 60) minutes.
SMART Attributes Data Structure revision number: 16
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 060 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 050 Pre-fail Offline - 0
3 Spin_Up_Time 0x0007 181 181 024 Pre-fail Always - 85 (Average 246)
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 467
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 2
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 020 Pre-fail Offline - 0
9 Power_On_Hours 0x0012 098 098 000 Old_age Always - 20292
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 435
192 Power-Off_Retract_Count 0x0032 099 099 050 Old_age Always - 1254
193 Load_Cycle_Count 0x0012 099 099 050 Old_age Always - 1254
194 Temperature_Celsius 0x0002 253 253 000 Old_age Always - 21 (Min/Max 3/50)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 2
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
SMART Error Log Version: 1
No Errors Logged
created: