Where is my disk?

Jeroen de Meijer

In Solaris it used to be easy to know which disk resided where. Every bay had it’s own (scsi-)target so you knew that c0t0d0 was bay zero, and c0t4d0 was bay 4.

In the SPARC T3, T4 and T5 systems however, these simple target numbers are replaced by the World Wide Number (WWN of the disk).

So your disks are now named things like:

root@d1prod11:~# zpool status
  pool: zones
 state: ONLINE
 scan: scrub repaired 0 in 0h13m with 0 errors on Mon Nov 17 04:48:13 2014

        NAME                       STATE     READ WRITE CKSUM
        zones                      ONLINE       0     0     0
          mirror-0                 ONLINE       0     0     0
            c0t5000C5004754F48Fd0  ONLINE       0     0     0
            c0t5000CCA01676F3C8d0  ONLINE       0     0     0

errors: No known data errors

If a disk fails you will have a hard time finding out which one it is. There is a procedure for finding this out, which includes sifting through the prtconf output and using reference tables in the Oracle documentation. This a pain.

But after some searching I found a faster way, which most importantly, I could script. It uses the Fault Management framework (SUNWfmd package in Solaris 10). It has a topology tool which shows all devices in the system and their location.

The script takes the cXtXdX notation for disks as input, and then spits out the bay number.

I believe the script can be improved, but for now it does the job. You won’t need the script in Solaris 11, as it has a tool that determines this for you quickly: disktool. However, in Solaris 10 this tool is buggy (it only sees disks on the first controller).

Here is the script.


if [ ! $USER = "root" ]
        echo "ERROR: Root privileges are needed."
        exit 1

SYSTEM=`prtconf -b | grep banner-name`
if [[ ! ${SYSTEM#*  } = *@([SPARC T3-|SPARC T4-|SPARC T5-][0-9]) ]];
        echo "ERROR: System type ${SYSTEM#*  } not supported. Only T3, T4 and T5 systems are supported."
        exit 1

# Promt for disk name
read -r DISK?"Please enter disk name [cXtXdX]: "

# The disk name should not have a slice (sX) part, so if it's there we remove it.

# Get the device path of the disk from the format command.
DEVFSPATH=`echo current |format ${DISK} 2> /dev/null | grep ^/`

if [ -n "${DEVFSPATH}" ]
        # Use the fault management topology tool to look for the device path.
        # Two lines before that is the string containing the bay the disk is in.
        # So we use nawk to gives us the line with the device path and the two lines before that.
        # Then we cut the output to be left with the bay number.
        DISKBAY=`/usr/lib/fm/fmd/fmtopo -P io.devfs-path 2> /dev/null | nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=0 s="${DEVFSPATH}" - | cut -d/ -f 7 | cut -d= -f2`

        # Report back the bay number.
        echo "Your disk is in bay: ${DISKBAY}."
        echo "ERROR: Device path for ${DISK} cannot be found."
        exit 1


you might also like