[smartmontools-support] using smartd to monitor a rotating group of USB drives?
Christian Franke
Christian.Franke at t-online.de
Sun Nov 4 19:51:32 CET 2018
Nathan Stratton Treadway wrote:
> ...
> (We've been trying this out using smartmontools 6.5+svn4324-1 as found
> in the Bionic release of Ubuntu.)
>
> Of course we looked at the the "-d removable" option lines in
> smartd.conf... but that doesn't seem to apply DEVICESCAN-detected
> devices.
>
> In any case, we're running into the following issues in our scenario:
>
> A) we get "SMART error (FailedOpenDevice) detected" warning messages
> each time a drive is unplugged, repeated daily until some new drive
> is plugged in and takes over the old /dev/sdX device name.
This should be fixed since r4399. This fix is included in smartmontools
6.6 (released ~1 year ago).
> B) when a new drive is plugged in, it appears that smartd doesn't check
> to see if the drive now found as /dev/sdX is actually the same drive
> as the one found at start-up time -- and thus over time multiple
> different drives are all treated as the same drive, with data saved
> the same /var/lib/smartmontools/*<DEVICE_MODEL>_<SERIAL_NUMBER>*
> files (named after whatever happened to be plugged in at startup
> time) -- and, I believe, any warning emails sent include the original
> drive's info in the body of the message, rather than the info for the
> drive that's actually attached at that time.
A platform independent solution is possibly difficult. It may work to
add another option (e.g. "-d replaceable") to enable a re-check of
device identity before each check cycle.
For Linux only, the following less complex enhancement for DEVICESCAN
may also work:
Add all /dev/disk/by-id/* entries which are symlinks to some /dev/sdX to
the scan result. Then add the remaining /dev/sdX to the result.
This small script demonstrates the idea:
--------------------
#!/bin/sh
{
ls -dl /dev/disk/by-id/* 2>/dev/null | \
sed -n 's,^.* \(/d[^ ]*\) -> \.\./\.\./\(sd[a-z][a-z]*\)$,\1
/dev/\2,p' \
&& ls -d /dev/sd[a-z] /dev/sd[a-z][a-z] 2>/dev/null
} | awk '
NF == 2 {print $1; used[$2] = 1; next}
!used[$1] {print $1}
'
--------------------
If possible, please test whether the group of USB drives appear as
unique symlinks in /dev/disk/by-id.
> C) smartd only checks for devices mapped to the /dev/sd* files that were
> found at startup time; if more drives are plugged in simultaneously
> after startup, the "extras" won't be detected.
This is an open issue which needs to be addressed for each platform
separately. Could possibly be solved by an external tool which catches
hotplug events and then sends SIGHUP to smartd.
> ...
> Will it cause any problems/conflicts to run "smartd -q onecheck" at the
> same time as the standard long-term smartd process is running (assuming
> that I make sure the internal drives are excluded from monitoring by the
> smartd_for_usb_drives.conf file)?
This should be safe.
Thanks,
Christian
More information about the Smartmontools-support
mailing list