CentOS5にUSB接続したハードディスクの調子が悪そうでsmartctlコマンドを使ってハードディスクを調査、診断してみました。
以下に備忘録としてsmartctlコマンドについて記述します。
Logwatcherから以下のようなメールが届いていました。
SmartdからWarningsを知らせるメッセージです。
--------------------- Smartd Begin ------------------------ Warnings: Warning via mail to root: successful - 1 Time(s) Sending warning via mail to root ... - 1 Time(s) ---------------------- Smartd End -------------------------
S.M.A.R.Tに対応しているハードディスクは温度・不良セクタ数等などを検査することができます。
これにより、故障の早期発見などに役立ちます。
Windows向けの資料ですが、S.M.A.R.Tについて記述した資料です。
いくつかのオプションを使用してsmartctlコマンドを使ってみました。
以下にsmartctlコマンドの使用例を記します。
尚、以下の操作はrootユーザにて作業しました。
デバイス(ハードディスク)の情報を取得します。
smartctl -a デバイス名
smartctl -hオプションを使用し-aオプションの動作を確認してみます。
[root@centos5 ~]# smartctl -h <省略> -a, --all Show all SMART information for device <省略>
実際にデバイス名/dev/sdaを指定して実行した時の出力です。
[root@centos5 ~]# smartctl -a /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Model Family: Hitachi Deskstar 7K2000 Device Model: Hitachi HDS722020ALA330 Serial Number: 12345678901234 LU WWN Device Id: 5 000000 222222222 Firmware Version: 11111111 User Capacity: 2,000,398,934,016 bytes [2.00 TB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: 8 ATA Standard is: ATA-8-ACS revision 4 Local Time is: Mon Apr 15 12:12:12 2013 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: (0x82) Offline data collection activity was completed without error. Auto Offline Data Collection: Enabled. <省略> 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 016 Pre-fail Always - 0 2 Throughput_Performance 0x0005 133 133 054 Pre-fail Offline - 100 3 Spin_Up_Time 0x0007 113 113 024 Pre-fail Always - 636 (Average 639) 4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 91 5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0 7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0 8 Seek_Time_Performance 0x0005 121 121 020 Pre-fail Offline - 35 9 Power_On_Hours 0x0012 097 097 000 Old_age Always - 22171 10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 19 <省略>
オプション-tを使用することによりセルフテストを実行することができます。
smartctl -t テストタイプ デバイス名
オプション-hを使用して-tオプションについて確認しました。
[root@centos5 ~]# smartctl -h <省略> -t TEST, --test=TEST Run test. TEST: offline, short, long, conveyance, vendor,N, select,M-N, pending,N, afterselect,[on|off] <省略>
上記のshortとlongを実際につかってセルフテストを行ってみます。
[root@centos5 ~]# smartctl -t short /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 1 minutes for test to complete. Test will complete after Mon Apr 15 18:36:23 2013 Use smartctl -X to abort test.
[root@centos5 ~]# smartctl -h <省略> -H, --health Show device SMART health status <省略>
[root@centos ~]# smartctl -H /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED
[root@centos5 ~]# smartctl -h <省略> -l TYPE, --log=TYPE Show device log. TYPE: error, selftest, selective, directory[,g|s], xerror[,N][,error], xselftest[,N][,selftest], background, sasphy[,reset], sataphy[,reset], scttemp[sts,hist], scttempint,N[,p], scterc[,N,M], devstat[,N], ssd, gplog,N[,RANGE], smartlog,N[,RANGE] <省略>
[root@centos ~]# smartctl -l selftest /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === 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% 22171 - # 2 Extended offline Aborted by host 90% 22171 - # 3 Extended offline Aborted by host 90% 22171 - # 4 Short offline Completed without error 00% 22171 -
上記と同様にshortをlongに変更してsmartctlコマンドを実行します。
結構時間がかかります。dfコマンドで確認したところ450Gのディスクで131分と出力されました。)
[root@centos5 ~]# smartctl -t long /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Extended self-test routine immediately in off-line mode". Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 131 minutes for test to complete. Test will complete after Mon Apr 15 21:24:39 2013 Use smartctl -X to abort test. [root@centos5 ~]#
smartctl -l selftest /dev/hda
[root@centos5 ~]# smartctl -l selftest /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === 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 Extended offline Completed without error 00% 18006 - # 2 Short offline Completed without error 00% 18004 - # 3 Short offline Completed without error 00% 18004 - # 4 Short offline Aborted by host 70% 18004 - # 5 Short offline Completed without error 00% 18003 -
上記で-tオプションを使用してセルフテストを行いました。
その時、中止の方法も出力されています。
Use smartctl -X to abort test.
実際に使用するには、以下のようになります。
smartctl -X デバイス名
実際にセルフテストを実行して中止したときの出力です。
[root@centos5 ~]# smartctl -t short /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 1 minutes for test to complete. Test will complete after Mon Apr 15 22:04:02 2013 Use smartctl -X to abort test.
[root@centos ~]# smartctl -X /dev/sda smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.3.1.el5] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Abort SMART off-line mode self-test routine". Self-testing aborted!
以上、smartctlコマンドの使用方法をいくつか紹介しました。