I'm running TrueNAS-SCALE-23.10.0.1 on an old Supermicro motherboard in a Genesys S208B-TWIN-ITX-12G chassis. This chassis has hot swappable 3.5" SAS drive bays oriented in two rows of four drives. My storage drives are connected through an LSI Broadcom SAS 9300-8i HBA. My HBA does not support the LOCATE feature, so I cannot blink LEDs to locate hard drives to replace.
In order to quickly associate which hard drive in TrueNAS corresponds to what physical slot it is stored in I wrote a script. This script uses the description column of TrueNAS's Storage Disks table to label what slot a particular drive is installed in. One caveat with this script is I must run it after every reboot or after I install/remove a hard drive, so running sudo slots
is now at the beginning of my disk repalcement workflows.
Copy slots.sh (attached below) to /usr/local/sbin/slots
and then run sudo chmod +x /usr/local/sbin/slots
. Afterward you will be able to use the tool anywhere by running sudo slots
.
Here is an example output:
$ sudo slots
Updating...
cli -c 'storage disk update "{serial_lunid}A8U9V69MF02U_50002c69cf006e22" description="Slot 0"'
cli -c 'storage disk update "{serial_lunid}ERKE3ODC_500072751ec5ac8f" description="Slot 1"'
cli -c 'storage disk update "{serial_lunid}G38Y5GR9_50005f7976c6b9d2" description="Slot 2"'
cli -c 'storage disk update "{serial_lunid}J93BE0VO_5000abcd935fa962" description="Slot 4"'
cli -c 'storage disk update "{serial_lunid}RHBDQCAW_500029dc633bc768" description="Slot 5"'
cli -c 'storage disk update "{serial_lunid}E8OGD9VZ_500064a75b8d3b55" description="Slot 6"'
Printing table...
+-------------------------+-------------------------+-------------------------+-------------------------+
| 0/sdc/18TB/A8U9V69MF02U | 1/sdd/18TB/ERKE3ODC | 2/sdb/20TB/G38Y5GR9 | |
+-------------------------+-------------------------+-------------------------+-------------------------+
| 4/sdf/18TB/J93BE0VO | 5/sdg/16TB/RHBDQCAW | 6/sde/16TB/E8OGD9VZ | |
+-------------------------+-------------------------+-------------------------+-------------------------+
When you upgrade TrueNAS everything in /usr/local/sbin
will be lost. To keep the script on your machine permanently it must be stored as an init script in your TrueNAS configuration. This can be done with the following commands:
PAYLOAD="$(cat /usr/local/sbin/slots |gzip -9 - |base64 -w0)"
COMMAND="echo $PAYLOAD|base64 -d|gzip -d|install -m0755 /dev/stdin /usr/local/sbin/slots"
cli -c "system init_shutdown_script create comment=\"slots.sh\" type=COMMAND when=POSTINIT command=\"$COMMAND\""