You can get the disk serial with smartctl -i /dev/...
. Serial should be written on disk. Keep a mapping of disk ID -> serial.
If serial is not visible without taking all disks apart, it’s a good idea to put a sticker with a copy of it on the side of the disk or disk tray depending on your NAS form factor.
I just plug all disks in my server, then run the following script to get the mapping GPTID -> partition -> disk serial:
#!/bin/sh glabel status | awk '/^gptid/ { print $1, $3 }' | while read -r gptid part; do disk="/dev/${part%p*}" serial="$(smartctl -i "$disk" | awk '/^Serial Number:/ { print $3 }')" printf '%s\t%s\t%s\n' "$gptid" "$part" "$serial" done
Then, when a disk fails, I just check with
zpool status
which one is unavailable or completely missing, and see to which serial it corresponds in the previously stored output of the above script.This script is for FreeBSD and assumes you add disks using their GPTID in your ZFS pool (default on TrueNAS), but it can easily be adapted to Linux with a mix of
lsblk --nodeps -o +WWN,SERIAL
and the symlinks in/dev/disk/by-id/
.You can create random read to try to identify a disk (using
badblocks
for instance). If the bad disk is not completely dead, create random read on it and try to “feel” which disk is constantly spinning and creating vibration. If disk is completely dead, do the same on all other disks and feel which one is inactive.But writing down the disk ID -> serial mapping, if the serial is written on the hard drives is a lot easier and more reliable.