smartmontools

    硬盘设备:指定要查看的硬盘(可以使用 fdisk -l 获取有哪些硬盘设备)

    1. ~ sudo fdisk -l
    2. 设备 起点 末尾 扇区 大小 类型
    3. /dev/sda1 2048 1050623 1048576 512M EFI 系统

    查看 /dev/sda1 硬盘特定的属性和值 (Power_On_Hours: 表示通电时长 18195 小时)

    1. ~ sudo smartctl -A /dev/sda1
    2. === START OF READ SMART DATA SECTION ===
    3. Vendor Specific SMART Attributes with Thresholds:
    4. ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
    5. 3 Spin_Up_Time 0x0023 100 100 002 Pre-fail Always - 1326
    6. 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 3752
    7. 9 Power_On_Hours 0x0032 055 055 000 Old_age Always - 18195
    8. 10 Spin_Retry_Count 0x0033 174 100 030 Pre-fail Always - 0
    9. 184 End-to-End_Error 0x0033 100 100 097 Pre-fail Always - 0
    10. 185 Unknown_Attribute 0x0032 100 100 001 Old_age Always - 65535
    11. 187 Reported_Uncorrect 0x0032 001 001 000 Old_age Always - 134
    12. 188 Command_Timeout 0x0032 100 098 000 Old_age Always - 48
    13. 191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 2850
    14. 192 Power-Off_Retract_Count 0x0022 100 100 000 Old_age Always - 32047593
    15. 193 Load_Cycle_Count 0x0032 095 095 000 Old_age Always - 51738

    下一步,编辑smartd的配置文件(/etc/smartd.conf),添加以下行内容。

    1. /dev/sda -m myemail@mydomain.com -M test

    保存改动并重启smartd。