Linux – RHEL 6 / CentOS 6 – Determining the SAN LUN ID for an EMC VNX5700-Presented LUN

When using dm-multipath (multipath, multipathd) with RedHat Enterprise Linux 6 (RHEL6) or CentOS 6 with a Fibre-Channel (FC) -connected EMC SAN (VNX-5700 or CLARiiON CX4-480), when a group of similarly-sized LUNs are all presented at the same time, it can be difficult to identify from the server-side which is which.

Here is a one-liner bash-shell script that will map the /dev/dm-? device to the LUN WWN to the SAN-LUN-ID:

for x in /dev/dm-* ; do export lunid=$( /usr/bin/sg_inq --page=0x83 ${x} | grep "^ 00" | cut -d" " -f17 | awk '{ print strtonum( "0x" $1 ) };' ) ; export wwid=$( /sbin/scsi_id --whitelisted --replace-whitespace --device=${x} ) ; echo ${x} == ${wwid} == SAN-LUN-${lunid}; done

It iterates across all devices with the path “/dev/dm-*” and produces output similar to the following:

/dev/dm-0==3600601600d902d036013e9181b48e211==SAN-LUN-15

Which is handy.

Advertisements

One thought on “Linux – RHEL 6 / CentOS 6 – Determining the SAN LUN ID for an EMC VNX5700-Presented LUN

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s