Linux: ID world wide ID from a lun

Title:Linux: ID world wide ID from a lun
Author:Douglas O’Leary <dkoleary@olearycomputers.com>
Description:How to ID the WWID from a given LUN
Date created:05/2013
Date updated:06/21/2013
Disclaimer:Standard: Use the information that follows at your own risk. If you screw up a system, don’t blame it on me...

This little bit of ugliness came from trying to identify which disks are actually the same device in a multipath environment. This isn’t the whole solution, but it’s a step in the right direction.

First method should be pretty reliable regardless of the environment. Basically, you identify the lun for which you want the WWID then use it as as argument to the scsi_id command. /sbin/scsi_id comes with the udev package so should be reliably avialable on any redhat related distro.

In my client’s environment, we’re using 3-par so I was able to use an inline script to identify WWIDs as follows:

lsscsi | grep -i '3pardata vv' | awk '{print $NF}' | while read dev
do
w=$(scsi_id -g -s /block/${dev##*/})
printf "%-10s %s\n" ${dev} ${w}
done
/dev/sdxd  350002ac0967f087a
/dev/sdxe  350002ac09680087a
/dev/sdxf  350002ac09681087a
/dev/sdxg  350002ac09682087a
/dev/sdxh  350002ac09683087a
/dev/sdxi  350002ac09684087a
/dev/sdxj  350002ac09685087a
/dev/sdxk  350002ac09686087a

06/21/13: There seems to be a fairly wide variation in the scsi_id command arguments between the various versions. For instance:

  • rhel6.4: scsi_id –page=0x83 –whitelisted –device=/dev/${d}
  • rhel5.9: scsi_id -p 0x83 -g -s /block/${d}
  • rhel???: scsi_id -g -s /block/${d}
  • rhel4: scsi_id -g -s /block/${d} -d /dev/${d}

Nice to keep things consistent and easily scriptable...

Another option which shows some promise is to use the multipath -ll command. For instance, the display that follows shows that devs sdik and sdmd are pointing to the same gpfs volume with a WWID of 350002ac000200d1e.

# multipath -ll | head
gpfs167 (350002ac000200d1e) dm-212 3PARdata,VV
[size=2.0T][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=2][active]
\_ 5:0:1:68  sdik 135:64  [active][ready]
\_ 6:0:0:68  sdmd 69:336  [active][ready]
gpfs152 (350002ac000110d1e) dm-194 3PARdata,VV
[size=2.0T][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=2][active]
\_ 5:0:1:51  sdhp 133:240 [active][ready]
\_ 6:0:0:51  sdld 67:432  [active][ready]

Both options should be scriptable; but, that’s as far as I got before getting pulled off to different projects.