如何防止 smartd 报告它找不到磁盘?

Spa*_*awk 9 monitoring hard-disk smartctl

我已经智能监控我的硬盘驱动器。它通常工作正常,但以下错误窗口一直每 24 小时弹出一次。

This email was generated by the smartd daemon running on:
  host name: sparhawk-XPS-17
  DNS domain: [Unknown]
  NIS domain: (none)
The following warning/error was logged by the smartd daemon:
Device: /dev/sdc [SAT], unable to open device
For details see host's SYSLOG.
You can also use the smartctl utility for further investigation.
Another email message will be sent in 24 hours if the problem persists.
Run Code Online (Sandbox Code Playgroud)

没有连接sdc,但我还是尝试了sudo smartctl -a /dev/sdc。结果是

smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.5.0-26-generic] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net
Smartctl open device: /dev/sdc failed: No such device
Run Code Online (Sandbox Code Playgroud)

唯一未注释掉的行/etc/smartd.conf

DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner
Run Code Online (Sandbox Code Playgroud)

有没有办法让smartd正确识别这个磁盘的删除,而不是抱怨它?如果这是不可能的,那么有没有办法让 smartd 只监控 sda 和 sdb?

Ace*_*Ace 6

我遇到了同样的问题,所以我做了一些研究。我找到了这个:

/etc/smartd.conf

# smartd will re-read the configuration file if it receives a HUP
# signal

# The file gives a list of devices to monitor using smartd, with one
# device per line. Text after a hash (#) is ignored, and you may use
# spaces and tabs for white space. You may use '\' to continue lines.

# You can usually identify which hard disks are on your system by
# looking in /proc/ide and in /proc/scsi.

# The word DEVICESCAN will cause any remaining lines in this
# configuration file to be ignored: it tells smartd to scan for all
# ATA and SCSI devices.  DEVICESCAN may be followed by any of the
# Directives listed below, which will be applied to all devices that
# are found.  Most users should comment out DEVICESCAN and explicitly
# list the devices that they wish to monitor.
Run Code Online (Sandbox Code Playgroud)

我假设通过从内核注销驱动器

root@localhost# echo 1 > /sys/block/sdX/device/delete
Run Code Online (Sandbox Code Playgroud)

然后从 /etc/smartd.conf 中删除设备条目,

然后执行“sudo service smartmontools restart”将解决您的问题,smartd 将停止报告丢失的驱动器。


use*_*ser 5

您可以通过在 /etc/smartd.conf 中明确列出这些设备而不是使用DEVICESCAN关键字来使 smartd仅监视一组特定的设备

因此,为了仅监控 /dev/sda 和 /dev/sdb,您需要从 smartd.conf 中删除:

DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner
Run Code Online (Sandbox Code Playgroud)

而不是它,添加:

/dev/sda -m root -M exec /usr/share/smartmontools/smartd-runner
/dev/sdb -m root -M exec /usr/share/smartmontools/smartd-runner
Run Code Online (Sandbox Code Playgroud)

然后重新启动 smartd 守护进程。

这种方法的主要缺点是您需要在配置中单独列出每个磁盘。至少只有两个磁盘,这并不太麻烦。

  • 这可以很好地防止对`/dev/sdc` 的扫描。但是,您知道smartd是否会正常扫描新连接的USB驱动器吗?理想情况下,它仍会扫描`/dev/sdc`,但在断开连接时不会报告。 (2认同)
  • 手动操作并删除发现并不完全理想。HUPing 守护进程或重新启动它更符合 OP 想要做的事情。 (2认同)