smartctlによるストレージデバイスの健全性診断とSMARTデータ解析

パッケージの導入と環境準備

ストレージデバイスの自己診断機能(SMART)を活用するには、smartmontoolsユーティリティの導入が必須となります。主要なディストリビューションにおけるインストール手順は以下の通りです。

# Debian/Ubuntu系
sudo apt update && sudo apt install smartmontools

# RHEL/CentOS/Fedora系
sudo dnf install smartmontools

# 導入後のバージョン確認
smartctl --version

デバイスの検出とRAID構成への対応

システムに接続されているすべてのブロックデバイスを列挙するには、--scan-openオプションを使用します。ハードウェアRAID構成下では、物理ディスクへ直接アクセスするためのデバイス透過設定(passthrough)が不可欠です。

$ sudo smartctl --scan-open
/dev/nvme0 -d nvme # /dev/nvme0, NVMe device
/dev/bus/0 -d megaraid,2 # /dev/bus/0 [megaraid_disk_02], SCSI device
/dev/bus/0 -d megaraid,3 # /dev/bus/0 [megaraid_disk_03], SCSI device

RAIDコントローラー経由で物理ディスクを操作する場合は、-d(または--device)フラグで適切なドライバタイプとポート番号を指定します。代表的な構文は以下の通りです。

  • MegaRAID: -d megaraid,N (Nはスロット番号)
  • 3ware: -d 3ware,N
  • HighPoint RocketRAID: -d hpt,L/M/N
  • Areca: -d areca,X/Y (X:エンクロージャー, Y:スロット)

SMART属性の詳細取得と構造化表示

単一ディスクの全ステータスを確認する場合、-a(または--all)が標準ですが、より構造化された機械可読形式や拡張情報を取得する場合は-x--jsonが推奨されます。

# NVMeデバイスの全SMART情報と拡張ログを出力
sudo smartctl -x /dev/nvme0

# 特定のRAIDスロットに配置されたSASディスクのヘルスステータスと属性をフィルタリング
sudo smartctl -H -A -d megaraid,2 /dev/bus/0

実行結果の代表的なセクション構成は以下のようになります。

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Exos 7E8
Device Model:     ST4000NM0023
Serial Number:    ZG20K8L9
LU WWN Device Id: 5 000c50 0c1234567
Firmware Version: E004
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s
Local Time is:    Fri Oct 27 14:22:01 2023 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.
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: 		(  540) 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: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 ( 345) minutes.
Conveyance self-test routine
recommended polling time: 	 (   2) minutes.
SCT capabilities: 	       (0x003d)	SCT Status supported.
    					SCT Error Recovery Control supported.
    					SCT Feature Control supported.
    					SCT Data Table supported.

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   078   065   044    Pre-fail  Always       -       58320128
  3 Spin_Up_Time            0x0003   092   092   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       12
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  9 Power_On_Hours          0x0032   088   088   000    Old_age   Always       -       10842
...

出力データにおける重要な指標は以下の通りです。

  • SMART overall-health: デバイスの健全性ステータス(PASSED/FAILED)。FAILEDが返された場合は早期交換が推奨されます。
  • Reallocated_Sector_Ct (ID#5): 不良セクタの代替処理回数。増加傾向にある場合、物理的な劣化が進んでいる可能性が高いです。
  • Power_On_Hours (ID#9): 累計稼働時間。消耗品としての寿命管理に利用されます。
  • Error_Log/Self-test_Log: 過去のエラー記録と自己診断履歴を確認することで、断続的な障害や書き込みエラーの特定が可能になります。

自己テストの実行とログ管理

ディスクの潜在的な不良領域を検出するには、バックグラウンドまたはキャプティブモードで自己テストを実行します。

# 短時間テスト(約1〜2分)
sudo smartctl -t short /dev/sda

# 完全テスト(数時間かかる場合あり)
sudo smartctl -t long /dev/nvme0

# テスト結果ログの出力
sudo smartctl -l selftest /dev/sda

テスト実行中はシステムパフォーマンスに影響を与える可能性があるため、メンテナンスウィンドウでの実施が一般的です。結果は-l selftestまたは-xオプションで確認でき、ステータスがCompleted without error以外の場合は詳細なエラーコードとLBA(論理ブロックアドレス)が記録されます。

タグ: smartmontools smartctl S.M.A.R.T storage-monitoring hardware-diagnosis

5月18日 13:11 投稿