[smartmontools-support] using smartd to monitor a rotating group of USB drives?

Nathan Stratton Treadway nathanst at ontko.com
Sun Nov 4 21:34:12 CET 2018


On Sun, Nov 04, 2018 at 19:51:32 +0100, Christian Franke wrote:
> 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.

Yes, in this case they do... though these particular drives the
../by-id/ name is based on the USB bridge and not the drive identifiers.
(This is under Linux 4.15.0-36-generic x86_64 as found in Ubuntu Bionic.)

I saved the your script to "device_symlink_lists.sh", then ran the
following command to show both the output of the script and also the
/dev/ name the links point to:

====
root at tumhalad:~/external_usb_drives# for DEV in $(./device_symlink_lists.sh ) ; do echo -n "$DEV -> ";  readlink -f $DEV; done
/dev/disk/by-id/ata-MB0500GCEHE_WMAYP0H8TMAM -> /dev/sda
/dev/disk/by-id/ata-MB0500GCEHE_WMAYP0K0W6SM -> /dev/sdc
/dev/disk/by-id/ata-MB4000GCWLV_P4HLMDTC -> /dev/sdb
/dev/disk/by-id/ata-MB4000GCWLV_P4HMV9GB -> /dev/sdd
/dev/disk/by-id/ata-TOSHIBA_MK5059GSX_Z95LF13BS -> /dev/sde
/dev/disk/by-id/usb-WD_My_Passport_0740_5758423145413146454A4C38-0:0 -> /dev/sdf
/dev/disk/by-id/usb-WD_My_Passport_0740_575844314539314C464E5737-0:0 -> /dev/sdi
/dev/disk/by-id/wwn-0x50000392371814b8 -> /dev/sde
/dev/disk/by-id/wwn-0x5000cca249d68f0e -> /dev/sdb
/dev/disk/by-id/wwn-0x5000cca249d71d4d -> /dev/sdd
/dev/disk/by-id/wwn-0x50014ee0041783d7 -> /dev/sda
/dev/disk/by-id/wwn-0x50014ee05981908d -> /dev/sdc
====

So in this case the MB* links, sda through sdd, reference the internal
SATA-controler-attached drives, sde/TOSHIBA is a random USB drive
currently plugged in, and the two usb-WD drives are part of the rotating
group.  (As long as the Toshiba drive is plugged in, the rotating
up-to-four drives on that 4-port USB hub end up using sdf-sdi.) 

There aren't any /dev/sd* devices that are missing symlinks in the
/dev/disk/by-id/ directory.

I'm not sure off hand why the Toshiba drive maps based on the disk
itself while the WD drives map based on the USB bridge... but obviously
the drives that map based on the disk get both a Model/SSN link and a
WWN link, while USB mapped-drives have only one link.


In contrast, the files under /var/lib/smartmontools look like:
/var/lib/smartmontools/smartd.MB0500GCEHE-WMAYP0H8TMAM.ata.state
/var/lib/smartmontools/smartd.MB0500GCEHE-WMAYP0K0W6SM.ata.state
/var/lib/smartmontools/smartd.MB4000GCWLV-P4HLMDTC.ata.state
/var/lib/smartmontools/smartd.MB4000GCWLV-P4HMV9GB.ata.state
/var/lib/smartmontools/smartd.TOSHIBA_MK5059GSX-Z95LF13BS.ata.state
/var/lib/smartmontools/smartd.WDC_WD5000BMVW_11AMCS2-WD_WX41A9109594.ata.state
/var/lib/smartmontools/smartd.WDC_WD5000BMVW_11AMCS2-WD_WX41A91A2669.ata.state
[etc.]


Let me know if I can provide any other information.

						Nathan

----------------------------------------------------------------------------
Nathan Stratton Treadway  -  nathanst at ontko.com  -  Mid-Atlantic region
Ray Ontko & Co.  -  Software consulting services  -   http://www.ontko.com/
 GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt   ID: 1023D/ECFB6239
 Key fingerprint = 6AD8 485E 20B9 5C71 231C  0C32 15F3 ADCD ECFB 6239



More information about the Smartmontools-support mailing list