おはようございます、こんにちは、こんばんは。
自宅サーバとしてLinuxMint18を運用しています。サーバとして機能しているのは、DHCPサーバ、内向きDNSサーバ、ファイル共有サーバ、sshサーバとして、自宅内LANのサーバとして元気に動作しています。
今は元気に動作していますが、いつかは壊れてしまう可能性があります。壊れてしまった場合、特に被害が大きいのは、ファイル共有しているデータです。データを保持し続けようと考えると、重要なことは、HDDが壊れる前にデータを確実にバックアップすることです。ということで、今回は「smartctl」コマンドでストレージの健康状態を確認する方法をメモします。
Contents
やったこと
smartctlのインストール
いつも通りに、apt-getコマンドでインストールします。
sudo apt-get install smartmontools
認識されているディスクの情報を表示する
sudo smartctl --scan /dev/sda -d scsi # /dev/sda, SCSI device /dev/sdb -d scsi # /dev/sdb, SCSI device /dev/sdc -d sat # /dev/sdc [SAT], ATA device /dev/sdd -d sat # /dev/sdd [SAT], ATA device
S.M.A.R.T.対応を確認する
それぞれのHDDがS.M.A.R.T.に対応しているか確認する
下記の例は、/dev/sda。上記の4つを確認したところ、すべてS.M.A.R.T.に対応しているのでストレージの健康状態を取得可能だった。
sudo smartctl -i /dev/sda smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build) Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Hitachi Deskstar 7K1000.B Device Model: Hitachi HDT721010SLA360 (略) SMART support is: Available - device has SMART capability. SMART support is: Enabled <- ここが、EnableならOK
S.M.A.R.T.情報を表示する
とりあえず、5番の「Reallocated_Sector_Ct」が不良セクターを表すらしいので注意する。その他、細かいことは、こちらを確認する
sudo smartctl -A /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
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 132 132 054 Pre-fail Offline - 114
3 Spin_Up_Time 0x0007 121 121 024 Pre-fail Always - 474 (Average 475)
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 1939
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 123 123 020 Pre-fail Offline - 34
9 Power_On_Hours 0x0012 095 095 000 Old_age Always - 35708
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 913
192 Power-Off_Retract_Count 0x0032 098 098 000 Old_age Always - 3029
193 Load_Cycle_Count 0x0012 098 098 000 Old_age Always - 3029
194 Temperature_Celsius 0x0002 200 200 000 Old_age Always - 30 (Min/Max 14/56)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
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 - 346
smartmontoolsの自己診断を開始する
簡単なテスト(short)を実施するコマンドを実行した。他のテストは、「short」を「long」や「 conveyance」に指定する。「short」は1分程度で終わるテストらしい。
sudo smartctl -t short /dev/sda
自己診断結果を表示する
sudo smartctl -l selftest /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, 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% 35711 -
まとめ
とりあえず、手動でS.M.A.R.T.情報を取得して、ストレージの健康状態をチェックしたところ、異常はなかった。これを定期的に実行するのは面倒だし、忘れそう・・。cronで定期的に実行して、結果をメールで通知する方法とか調べてみようかな。