Linux(CentOS,Ubuntu)で HDDの S.M.A.R.T.情報を表示させる方法と、HDDの自己診断の実行方法です。 HDDには S.M.A.R.T. と呼ばれる、HDDの項目値を読み出せる機能があり、これを通してHDDの各種情報を読み取ることが出来ます。 この情報には、読み込みエラーの回数・代替処置された不良セクタの数などがあり、HDDの障害を早期に発見する為に役立ちます。 取得できる情報にどのようなものがあるか、以下サイトで説明されています。 Self-Monitoring, Analysis and Reporting Technology - Wikipedia Windows では CrystalDiskInfo といったソフトで S.M.A.R.T.情報を表示できます。 CrystalDiskInfo - 窓の杜ライブラリ 以降で、Linux(CentOS,Ubuntu)で HDDの S.M.A.R.T.情報を表示させる方法と、HDDの自己診断の実行方法を説明します。 なお、文中のコマンドは root で実行して下さい。 物理HDDの確認まず、システム上のHDDを確認します。 smartctl --scan を実行します。 下記例では、/dev/sda 、/dev/sdb の2つのHDDです。 # smartctl --scan /dev/sda -d scsi # /dev/sda, SCSI device /dev/sdb -d scsi # /dev/sdb, SCSI device HDDが SMART対応か確認smartctl コマンドでHDDデバイス名を下記のように指定して実行します。 smartctl /dev/sda -i 表示結果に以下のような行が含まれていると SMARTに対応しています。 SMART support is: Available - device has SMART capability. SMART support is: Enabled ソフトウェアRAID mdadm によるデバイスの場合は、当然 SMARTに対応していません。 # smartctl /dev/md0 -i /dev/md0: Unable to detect device type Smartctl: please specify device type with the -d option. VirtualBox 等で仮想マシン上で Linuxを実行している場合も、SMARTに対応していません。 # smartctl /dev/sda -i SMART support is: Unavailable - device lacks SMART capability. USB-HDD の場合も、SMARTに対応していません。 # smartctl /dev/sdc -i /dev/sdc: Unknown USB bridge [0x0411:0x0283 (0x100)] 但し、HDD-USB変換に使っているチップにメーカー独自のコマンドでSMARTを読み出す機能を持っているものがあるそうです。 USB接続のHDDからSMART情報を読み出す(外付けHDD or SATA/IDE-HDD変換ケーブル) - (旧)今日の出来事 smartctl コマンドで -d オプションを使用すれば良いようです。 -d オプションに続けて、どのような値を指定すべきかは、機器ごとに異なりますので、下記を参照して下さい。 Supported_USB-Devices – smartmontools 例えば、以下のように実行します。上記サイトに記載が無い機器でも、まずは下記のように -d sat で実行してみて下さい。 smartctl /dev/sdc -i -d sat SMART情報表示HDDが SMART対応か確認できたら、smartctl コマンドでHDDデバイス名と -A オプションを付けて実行します。 下記のようにSMART情報が表示されます。 # smartctl /dev/sda -A === 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 117 094 006 Pre-fail Always - 132080352 3 Spin_Up_Time 0x0003 095 094 070 Pre-fail Always - 0 4 Start_Stop_Count 0x0032 099 099 020 Old_age Always - 1270 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0 7 Seek_Error_Rate 0x000f 084 060 030 Pre-fail Always - 310932712 9 Power_On_Hours 0x0032 088 088 000 Old_age Always - 10973 10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0 : : 各項目の意味については、以下を参照して下さい。 Self-Monitoring, Analysis and Reporting Technology - Wikipedia HDDの自己診断smartctl では、HDDの自己診断も行えます。 自己診断には Short , Extended , Conveyance の3種類ありますが、HDDによっては行えない自己診断もあります。 Shortでは、大抵10分以下で完了するような短時間の自己診断を実行します。 Extended では、より時間のかかる自己診断を実行します。 Conveyance では、デバイスの輸送中に受ける可能性があるダメージの有無を確認します。 HDDがどの自己診断を行えるかは、smartctl コマンドで -c オプションを付けて実行すると表示されます。 また自己診断を実行した際にかかる時間も表示されます。 以下例では、 Short , Extended , Conveyance の3種類とも対応しています。 # smartctl -c /dev/sdb : : Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 62) minutes. Conveyance self-test routine recommended polling time: ( 5) minutes. 下記は、Conveyance の表示が無いので、Conveyance には対応していない場合です。 # smartctl -c /dev/sda : : Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 107) minutes. まず、自己診断前に smartctl -l コマンドで HDDの自己診断の履歴を表示させます。 過去自己診断を実行した場合は、結果が記録されており、#1,#2,... の箇所に表示されます。 # smartctl -l selftest /dev/sda smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-39-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === 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 Conveyance offline Completed without error 00% 10941 - # 2 Short offline Completed without error 00% 0 - 自己診断の実行は、smartctl コマンドで -t オプションを付けて実行します。 -t に続けて short , long , conveyance を指定します。 自己診断 Extended の場合は、long を指定することに注意して下さい。 下記のように実行します。 # smartctl -t short /dev/sda smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-39-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === 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 2 minutes for test to complete. Test will complete after Wed Nov 26 16:33:49 2014 Use smartctl -X to abort test. 実行すると、すぐにプロンプトに戻りますが、バックグラウンドで自己診断は行われています。 Test will complete after の行に、終了予定時刻が表示されています。 自己診断の結果を見る場合は、下記のように -lオプションを使用します。 自己診断前は #1,#2 の2件だったのが、#1,#2,#3 の3件になっています。 #1 が最新の結果です。 この例では「Completed without error」となっており、エラーはありませんでした。 # smartctl -l selftest /dev/sda smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-39-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === 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% 10974 - # 2 Conveyance offline Completed without error 00% 10941 - # 3 Short offline Completed without error 00% 0 - もし、自己診断の実行前と同様、#1,#2 の2件だった場合は、自己診断はまだ実行中です。 HDDによっては、時間がかかる自己診断では途中経過が表示されるものがあります。 下記例では #3 の箇所に進捗が表示されています。LifeTime 列が 10974 であることを覚えておきます。 # smartctl -l selftest /dev/sda smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-39-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === 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 Conveyance offline Completed without error 00% 10941 - # 2 Short offline Completed without error 00% 0 - # 3 Short offline Self-test routine in progress 20% 10974 - 数分後に確認すると、LifeTime 列が 10974 のものは #1 に移っています。 最新の結果は #1 に表示されています。 この例では「Completed without error」となっており、エラーはありませんでした。 # smartctl -l selftest /dev/sda smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-39-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === 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% 10974 - # 2 Conveyance offline Completed without error 00% 10941 - # 3 Short offline Completed without error 00% 0 - 実行中の自己診断をキャンセルするには、smartctl で -X オプションを付けて実行します。 smartctl /dev/sdb -X キャンセルすると、smartctl -l コマンドで結果を表示した際に履歴に「Aborted by host」が残ります。 # smartctl -l selftest /dev/sda : # 4 Conveyance offline Aborted by host 90% 5361 - 以上、Linuxで HDDの S.M.A.R.T.情報を表示させる方法と、HDDの自己診断の実行方法でした。 参考S.M.A.R.T. (日本語) - ArchWiki ハードディスク障害か - torutkの日記 Manpage of SMARTCTL USB接続のHDDからSMART情報を読み出す(外付けHDD or SATA/IDE-HDD変換ケーブル) - (旧)今日の出来事 Supported_USB-Devices – smartmontools Umbrella Linux HDDの温度を調べるコマンド smartctl @IT:ハードディスクのS.M.A.R.T.情報を表示するには Self-Monitoring, Analysis and Reporting Technology - Wikipedia |
<< 前記事(2014/12/07) | ブログのトップへ | 後記事(2014/12/16) >> |
タイトル (本文) | ブログ名/日時 |
---|---|
HDDに異常があればメール通知する smartdの利用方法
Linuxで ハードディスクの状態を監視し、異常を検出するとメールで通知する smartdデーモンの利用方法です。 以下の記事で紹介した HDDの SMART情報を監視します。 ...続きを見る |
パソコン鳥のブログ 2015/09/04 21:45 |
内 容 | ニックネーム/日時 |
---|
<< 前記事(2014/12/07) | ブログのトップへ | 後記事(2014/12/16) >> |