S.M.A.R.T.(Self-Monitoring, Analysis and Reporting Technology)是硬碟內建的自我監測機制,記錄溫度、重新配置扇區、尋找錯誤、通電時數等關鍵屬性。當屬性超過閾值即預警硬碟可能故障。
# Debian/Ubuntu
sudo apt install smartmontools
# CentOS/RHEL/Fedora
sudo dnf install smartmontools
# Arch
sudo pacman -S smartmontools
sudo smartctl -i /dev/sda
關鍵輸出:
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
若顯示 Disabled,需啟用:
sudo smartctl --smart=on --offlineauto=on --saveauto=on /dev/sda
sudo smartctl -H /dev/sda
輸出:
SMART overall-health self-assessment test result: PASSED
PASSED:健康FAILED:立即備份資料並更換硬碟sudo smartctl -A /dev/sda
| ID | 屬性名稱 | 關鍵意義 | 警戒值 |
|---|---|---|---|
| 5 | Reallocated_Sector_Ct | 重新導向的壞軌扇區數 | > 0 即需關注,持續增長必換 |
| 197 | Current_Pending_Sector | 待測試的不穩定扇區 | > 0 可能即將壞軌 |
| 198 | Offline_Uncorrectable | 離線無法修正的扇區 | > 0 嚴重 |
| 194 | Temperature_Celsius | 溫度 | > 50°C 需改善散熱 |
| 9 | Power_On_Hours | 通電總時數 | 參考壽命(企業級 5 年 ≈ 43,800h) |
| 190 | Airflow_Temperature_Cel | 氣流溫度 | 參考值 |
| 12 | Power_Cycle_Count | 開關機次數 | 參考值 |
VALUE:正規化數值(越大越好),THRESH:閾值,RAW_VALUE:原始計數。
# 短時間測試(約 2 分鐘)
sudo smartctl -t short /dev/sda
# 長時間測試(數小時,掃描全盤)
sudo smartctl -t long /dev/sda
# 查看測試結果
sudo smartctl -l selftest /dev/sda
sudo smartctl -a /dev/sda
包含身分資訊、健康狀態、所有屬性、錯誤日誌、自我測試記錄。
sudo systemctl enable --now smartd
設定檔 /etc/smartd.conf 可自訂通知郵件、檢查間隔、忽略裝置等。
sudo smartctl -a /dev/nvme0
# 或使用 nvme-cli
sudo nvme smart-log /dev/nvme0
NVMe 使用不同指令集,屬性定義參考 nvme-cli 文件。