Identify Disks on SuperMicro server running FreeBSD

The poor man's means to identify disks would be to issue a dd if=/dev/daX of=/dev/null and see which disk's activity LED is blinking most rapidly. This of course needs a period of low activity for the other disks in the system, but is very generic.

If you have a (LSI) SAS controller that would work with sas2ircu then you might use it to issue the "display" command to list available drives and their serials and subsequently run the "LOCATE" command to blink the light on the enclosure.


I know this is an old question, but it gave me a few of the pieces I put together, and i thought i'd shoot back the script i came up with, since this is an almost exact match to my situation: it requires sas2ircu: http://www.avagotech.com/docs-and-downloads/host-bus-adapters/host-bus-adapters-common-files/sas_sata_6g_p20/SAS2IRCU_P20.zip and from the ports, bash and sg3_utils

It does make a few assumptions, i think the main one is that it is attached to controller 0. you can use sas2ircu list to identify your controller number.

It will check the selected pool (via zpool status). If there are no errors it will:

  • save a file (at /root/.sas2ircu/drives) with a mapping of device names to enclosure slots
  • turn off any leds previously activated by this script (this is stored in /root/.sas2ircu/locs)

If there are errors it will:

  • send an email with the full output of zpool status
  • activate the leds of any failed drives (and store the locations activates in /root/.sas2ircu locs so they can later be deactivated)

anyway here is the script. I run it as an hourly cron job.

#! /usr/local/bin/bash
if [ ! "$1" ]; then
  echo "Usage: zpscan.sh pool [email]"
  echo "Scan a pool, send email notification and activate leds of failed drives"
  exit
fi
if [ ! -d /root/.sas2ircu ]; then
  mkdir /root/.sas2ircu
  touch /root/.sas2ircu/drives
  touch /root/.sas2ircu/locs
fi
if [ "$2" ]; then
  email="$2"
else
  email="root"
fi
condition=$(/sbin/zpool status $1 | egrep -i '(DEGRADED|FAULTED|OFFLINE|UNAVAIL|REMOVED|FAIL|DESTROYED|corrupt|cannot|unrecover)')
if [ "${condition}" ]; then
  emailSubject="`hostname` - ZFS pool - HEALTH fault"
  mailbody=$(zpool status $1)
  echo "Sending email notification of degraded zpool $1"
  echo "$mailbody" | mail -s "Degraded Zpool $1 on hostname" $email
  drivelist=$(zpool status $1 | grep -E "(DEGRADED|FAULTED|OFFLINE|UNAVAIL|REMOVED|FAIL|DESTROYED)" | grep -vE "^\W+($1|NAME|mirror|logs|spares)" | sed -E $'s/.*was \/dev\/([0-9a-z]+)/\\1/;s/^[\t  ]+([0-9a-z]+)[\t ]+.*$/\\1/')
  echo "Locating failed drives."
  for drive in $drivelist;
  do
  record=$(grep -E "^$drive" /root/.sas2ircu/drives)
  location=$(echo $record | cut -f 3 -d " ")
  echo Locating: $record
  sas2ircu 0 locate $location ON
  if [ ! "$(egrep $location /root/.sas2ircu/locs)" ]; then
  echo $location >> /root/.sas2ircu/locs
  fi
  done
else
  echo "Saving drive list."
  drivelist=$(zpool status $1 | grep -E $'^\t  ' | grep -vE "^\W+($1|NAME|mirror|logs|spares)" | sed -E $'s/^[\t ]+//;s/([a-z0-9]+).*/\\1/')
  saslist=$(sas2ircu 0 display)
  printf "" > /root/.sas2ircu/drives
  for drive in $drivelist;
  do
  sasaddr=$(sg_vpd -i -q $drive 2>/dev/null | sed -E '2!d;s/,.*//;s/  0x//;s/([0-9a-f]{7})([0-9a-f])([0-9a-f]{4})([0-9a-f]{4})/\1-\2-\3-\4/')
  encaddr=$(echo "$saslist" | grep $sasaddr -B 2 | sed -E 'N;s/^.*: ([0-9]+)\n.*: ([0-9]+)/\1:\2/')
  echo $drive $sasaddr $encaddr >> /root/.sas2ircu/drives
  done

  for loc in $(cat /root/.sas2ircu/locs);
  do
  sas2ircu 0 locate $loc OFF
  done
  printf "" > /root/.sas2ircu/locs
fi

  for loc in $(cat /root/.sas2ircu/locs);
  do
  sas2ircu 0 locate $loc OFF
  done
  printf "" > /root/.sas2ircu/locs
fi

For most of my ZFS solutions, you better bet that I have a table and a set of labels identifying drives by their partial SAS WWN. This is a function of the LSI controllers I use, which read like:

    NAME                        STATE     READ WRITE CKSUM
    vol1                        ONLINE       0     0     0
      mirror-0                  ONLINE       0     0     0
        c10t50000393482B340Cd0  ONLINE       0     0     0
        c10t50000393482B4CF0d0  ONLINE       0     0     0
      mirror-1                  ONLINE       0     0     0
        c10t50000393482B4DB4d0  ONLINE       0     0     0
        c10t50000393482BAB48d0  ONLINE       0     0     0
      mirror-2                  ONLINE       0     0     0
        c10t50000393482BDA68d0  ONLINE       0     0     0
        c10t500003935803910Cd0  ONLINE       0     0     0

enter image description here

There are a couple of options to getting this to work. One is the commercial SanTools SMARTmon utility that's available to OEMs and integrators. It leverages the SCSI Enclosure Services (SES) features in external JBOD units, but has some magic for internal disks, too.

You may also have an option depending on the controller you're using. Are you just using a motherboard controller or a purpose-built non-RAID SAS HBA?