New tool available: findbay

It’s still early days, but I got a wild hair today and began writing a new simple tool, findbay.

root@elden:~# zpool status | grep SHGP31
	  nvme-SHGP31-2000GM_ANA7N7[elided]

root@elden:~# findbay ANA7N7
/dev/nvme0n1

root@elden:~# pv < `findbay ANA7N7` > /dev/null
47.0GiB 0:00:08 [6.97GiB/s] [>           ]   2% ETA 0:04:59

In the above snippet, we can see me demonstrating that NVME drives have absurdly long device labels, showing you a chunk of one of mine, and then running findbay against a small chunk of that device label (usually, I’d recommend using the last four or five characters, because those are the most likely to be unique).

Run by itself, findoid [string] will either return the bare devicename (eg /dev/sda) associated with any entry in /dev/disk/by-id, or will complain and error if there’s either no result or multiple results (the latter meaning the string you chose was not even locally unique, eg using SEA when you have more than one Seagate drive).

But you can also chain it into a pv (or even cat) command, as shown directly after that, which will not only return the raw devicename but also light up the associated LED.

Future versions of the tool will support blipping the drive with reads DIRECTLY, and include an option to specify a pattern (for obnoxious bays that don’t show much difference between full saturation and light activity). But I think this is already pretty useful in the meantime.

You can find findbay in MASTER of the Sanoid project Github right now; it should make its way out to distributions with our next full release.

2 Likes

So for you, the serial number from ‘sudo nvme list’ (command from the nvme-cli program) is still too long to use?

It’s long enough to type that practically, you wind up having to highlight copy and paste. Except when you’re on a raw TTY with no copy and paste available, in which case you’re reduced to some pretty clunky use of sed and awk and xargs to accomplish the same thing–reliably specifying the entire long string of random nonsense that identifies the drive.

This way, you at least have the option of just using the last four characters of the WWN (which aren’t technically guaranteed to be locally unique, but I’ve never yet had to deal with two drives in the same system with the same last four), which is very easy indeed to remember and type.