Today the disks for my new ZFS NAS arrived, rejoice! 😍

Now I ask myself: If some day one of the drives fails, how am I supposed know which of the physical ones it is? My preliminary plan is to plug them into to disk container one by one, writing down the newly appearing blkids and labeling the corresponding drive. This is somewhat time consuming, so you folks have a better idea?


  • @nlfx
    2 years ago

    I thought of something similar, but that again doesn’t save me from having to plug in the disks one by one.

    I just plug all disks in my server, then run the following script to get the mapping GPTID -> partition -> disk serial:

    glabel status | awk '/^gptid/ { print $1, $3 }' | while read -r gptid part; do
            serial="$(smartctl -i "$disk" | awk '/^Serial Number:/ { print $3 }')"
            printf '%s\t%s\t%s\n' "$gptid" "$part" "$serial"

    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/.

    Don’t know what I expected though, because you can’t make a hard drive suddenly beep or turn a light on. ^^

    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.