Rocky 9:SMART 检测与 smartd 告警落地
在 Rocky 9.8 环境(特权容器,宿主内核 5.14.0-687.54.1.el9_8)与同一宿主上实测:lsblk -d、smartctl --scan、smartctl -i /dev/vda、-d sat、-d nvme、systemctl is-active smartd、smartd.conf 默认内容。日志:plans/content-expansion/evidence/logs/rocky-disk-health.log。
本环境的虚拟盘不提供 SMART,所以「能读到时怎么配」部分按官方默认配置说明,未在真实 SATA/NVMe 盘上产出输出示例。
lsblk -d -o NAME,TYPE看盘的类型;smartctl --scan看能否枚举;smartctl -i /dev/<盘>看是否返回型号与 SMART support;- 读不到就换监控位置(云平台 / 阵列卡 / 宿主机)。
这台机器的实际结果
Section titled “这台机器的实际结果”sudo smartctl --scansudo smartctl -i /dev/vda(无输出)
/dev/vda: Unable to detect device typePlease specify device type with the -d option.再指定类型也失败:
Read Device Identity failed: Inappropriate ioctl for deviceRead NVMe Identify Controller failed: NVME_IOCTL_ADMIN_CMD: Inappropriate ioctl for device说明 virtio 盘没有透传 SMART 通道,客户机侧无论怎么配都读不到。
smartd 的默认配置长什么样
Section titled “smartd 的默认配置长什么样”grep -vE "^#|^$" /etc/smartmontools/smartd.conf | head -2systemctl is-active smartdDEVICESCAN -H -m root -M exec /usr/libexec/smartmontools/smartdnotify -n standby,10,qinactive默认 DEVICESCAN 会扫描所有支持的盘,健康检查失败时通过 -m root 发邮件。没有可扫描的设备时,它不会产生任何告警——这正是虚拟盘环境要避免的「以为有监控」。
读不到 SMART 时看什么
Section titled “读不到 SMART 时看什么”dmesg -T | grep -iE "i/o error|medium error|link reset" | tail -5sudo mdadm --detail /dev/md0 2>/dev/null | grep -E "State|Faulty"- 内核日志:I/O error / medium error 是硬件层最直接的症状;
- 软 RAID:
State变成 degraded、Faulty Devices出现具体盘; - 硬件 RAID:厂商 CLI(storcli/perccli/ssacli);
- 云盘:控制台的磁盘健康与事件。
- 把
-d sat当万能参数:类型不对只会得到 ioctl 错误; - smartd 没设备也照配:看起来有监控,实际什么都不报;
- 只看 SMART 不看 RAID 状态:RAID 卡后的盘,SMART 往往被控制器吞掉。
练习:给一台机器定「监控方案」
Section titled “练习:给一台机器定「监控方案」”sudo dnf install -y smartmontools mdadmsudo smartctl --scansudo smartctl -i /dev/<盘> || echo "SMART 不可用"dmesg -T | grep -icE "i/o error|medium error"sudo mdadm --detail /dev/md0 2>/dev/null | grep State检查:
- 能判断「本机能不能读 SMART」
- 读不到时,能说出替代监控位置
- 能列出至少两个替代信号
常见问题
virtio 盘为什么读不到 SMART?
SMART 命令走 ATA/NVMe 专有通道,虚拟盘通常不把这层透传给客户机;只有云平台或宿主机能看到物理盘状态。
smartd 默认配置够用吗?
物理机上 DEVICESCAN + -m root 是合理起点,但要把邮件通路和告警接收人配好;虚拟盘环境不要指望它。
RAID 卡后面的盘怎么监控?
用厂商 CLI 看阵列与物理盘状态,并开启控制器的事件告警;SMART 往往被控制器拦截,smartctl 拿不到。
- XFS 修复:XFS 损坏的判断与修复顺序
- LVM 扩容:LVM 扩容与 XFS 增长
- 网络排查:按症状分诊网络问题