コマンドでSMARTの状態を調べる
HDD の状態を調べるには、S.M.A.R.Tを調べる必要があって、それには smarttools のコマンド一式を使う必要が有ることがわかった。
HDDが異常化か正常化知りたいだけなんだ!
そんなせっかちな人には、此のコマンド PASSED と表示されたOKですね。*1
smartctl -H /dev/sda -d sat
takuya@:~$ sudo smartctl -H /dev/sda -d sat
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
では、インストールからいろいろ試してみます。
apt でぱぱっと入るので楽ちんですね。
sudo apt install smartmontools
早速使ってみる
sudo smartctl -i /dev/sda
-i
で指定すると基本的な情報が出てくる
smarttools を見るコマンドは smartctl
で、おもに此のコマンドで状態を見る。
takuya@:~$ sudo smartctl -i /dev/sda
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Caviar Green (AF, SATA 6Gb/s)
Device Model: WDC WD20EZRX-00D8PB0
Serial Number: WD-WMC4M2XXXXXX
LU WWN Device Id: 5 0014ee XXXXX
Firmware Version: 80.00A80
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2 (minor revision not indicated)
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Fri Mar 3 17:54:18 2017 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
dm(data mapper) デバイスに対して行うと
DM について smartctl を行うとこんな感じ。ブロックデバイスでも出てくるものと出てこないものがある。かならず物理デバイスに対して行う必要がある。 lvm で dm してて、その元になった /dev/sdX が見えるわけでもない。
takuya@:~$ sudo smartctl -i /dev/mapper/data
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
/dev/mapper/data-video: Unable to detect device type
Please specify device type with the -d option.
Use smartctl -h to get a usage summary
USB で繋いだドライブも見えないことがある。
USB 経由で繋いだハードディスク・ドライブでは、情報が取れないことがある。
USB経由で繋いでいるドライブなどは TYPEを指定してみる。
USB 経由で繋いだハードディスク・ドライブに実行した失敗例
takuya@:~$ sudo smartctl -a /dev/sda
smartctl 6.4 2014-10-07 r4002 [armv6l-linux-4.4.21+] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
/dev/sda: Unknown USB bridge [0x0789:0x0175 (0x103)]
Please specify device type with the -d option.
Use smartctl -h to get a usage summary
USB 経由で繋いだハードディスク・ドライブにTYPE指定した例
TYPE を指定するには -d TYPE_NAME
を使うことで値がみられる。
takuya@:~$ sudo smartctl -i /dev/sda -d sat
TYPEに使える値は次の通り。
つかえるあたいは以下の通り。最近はSATAなので -d sat
でイケルと思う
ata, scsi, sat[,auto][,N][+TYPE],
usbcypress[,X], usbjmicron[,p][,x][,N], usbsunplus,
marvell, areca,N/E, 3ware,N, hpt,L/M/N,
megaraid,N, aacraid,H,L,ID, cciss,N, auto, test
S.M.A.R.Tのオンオフを切り替える
smartctl でSMARTのオンオフを切り替える事ができる。
sudo smartctl -d sat -s on /dev/sda
sudo smartctl -d sat -s off /dev/sda
オフラインテスティングをオン・オフする
sudo smartctl -d sat -o on /dev/sda
sudo smartctl -d sat -o off /dev/sda
Attribute で表示される値のautosaveをオン・オフする
sudo smartctl -d sat -S on /dev/sda
sudo smartctl -d sat -S off /dev/sda
参考資料によると、オフラインテスティングは、ディスクのアイドル時にディスクアクセスを全部カットしてHDDのチェックをするらしい。ただし、ディスクアクセス要求があるとチェックを一旦停止してディスクアクセスを優先し、ディスク・アクセス終了後にディスク・チェックを再開するらしい。この一連の動作はパフォーマンスに影響を与えるかもしれないとのこと。
SMART の状態を表示する
-a
で全部の状態を表示することが出来るわけです。
sudo smartctl -a /dev/sda -d sat
これをつかえば、Windowsな人達もおなじみのデータが見られる。
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 18
3 Spin_Up_Time 0x0027 171 168 021 Pre-fail Always - 4441
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 259
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 100 253 000 Old_age Always - 0
9 Power_On_Hours 0x0032 066 066 000 Old_age Always - 25262
10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 242
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 204
193 Load_Cycle_Count 0x0032 181 181 000 Old_age Always - 58619
194 Temperature_Celsius 0x0022 125 086 000 Old_age Always - 22
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 0
SMART での提供情報を見る
smart で何が出来るかや設定状況を見る。
各項目ごとに、このHDDにおける、Enabled/supported が見える
Self-test を開始して何分ぐらいたったかもコレでわかる。
また、実行中のテストに何分くらい掛かるかわかる。
takuya@:~$ sudo smartctl -d sat /dev/sda -c
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
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: (29040) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
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: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 293) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x7035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
テストする
smart のHDD状態をチェックする。short と long が選べる。他にも offline, short, long, conveyance, force, vendorなどがある。
sudo smartctl -t short /dev/sda
参考資料
https://blog.shadypixel.com/monitoring-hard-drive-health-on-linux-with-smartmontools/
https://help.ubuntu.com/community/Smartmontools
S.M.A.R.T. - ArchWiki