CentOS / RHEL : How to identify/match LUN presented from SAN with underlying OS disk

The post mentions few ways to exactly identify/match the LUN presented from SAN with underlying OS disk.
Method 1
Execute command below command to obtain Vendor, Model and Port, Channel, SCSI-ID, LUN

# cat /proc/scsi/scsi
Host: scsi2 Channel: 00 Id: 00 Lun: 29
  Vendor: EMC      Model: SYMMETRIX        Rev: 5874
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 29
  Vendor: EMC      Model: SYMMETRIX        Rev: 5874
  Type:   Direct-Access                    ANSI SCSI revision: 05

Then execute below command:

# ls -ld /sys/block/sd*/device
lrwxrwxrwx 1 root root 0 Oct  4 12:12 /sys/block/sdaz/device -> ../../devices/pci0000:20/0000:20:02.0/0000:27:00.0/host2/rport-2:0-0/target2:0:0/2:0:0:29
lrwxrwxrwx 1 root root 0 Oct  4 12:12 /sys/block/sdbi/device -> ../../devices/pci0000:20/0000:20:02.2/0000:24:00.0/host3/rport-3:0-0/target3:0:0/3:0:0:29

Now compare hostX info with target with previous command( /proc/scsi/scsi ) to obtain details which disk is mapped to which LUN ID. The numbers marked at the end represent host, channel, target and LUN respectively. so the first device in command “ls -ld /sys/block/sd*/device” corresponds to the first device scene in the command “cat /proc/scsi/scsi” command above. i.e. Host: scsi2 Channel: 00 Id: 00 Lun: 29 corresponds to 2:0:0:29. Check the highlighted portion in both commands to correlate.

To get WWID of LUN you can use the /dev/disk/by-id/ file:

# ls -la /dev/disk/by-id/
scsi-3600508b400105e210000900000490000 -> ../../dm-1
Now its easier to understand that dm-1 has WWID 3600508b400105e210000900000490000

Method 2
Another way is to use sg_map command. Make sure you have sg3-utils installed before running this command.

# yum install sg3-utils
# sg_scan -i

/dev/sg2: scsi1 channel=0 id=0 lun=1 [em] type=0

SanDisk ImageMate CF-SM 0100 [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]

Above command will give mapping for devices. after this execute:

# sg_map -x

/dev/sg2 0 0 2 0 0 /dev/sdc

From the outputs of 2 commands above we can determine that sg2 ( SAN DISK ) is actually /dev/sdc device

Method 3
If multipath is being used ( device-mapper ) below command can be used:

# multipath -v4 -ll

mpathc (360000970000195900437533030382310) dm-1 EMC,SYMMETRIX
size=253G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 3:0:0:1 sde 8:64 active ready running
  `- 5:0:0:1 sdc 8:32 active ready running

How to understand the output

mpathc - user defined name
360000970000195900437533030382310 - WWID
dm-1 - sys-fs name
EMC - Vendor
2:0:0:29 - host,channel,scsi-id,lun

This output can be compared with the one we get with “cat /proc/scsi/scsi” command.

# cat /proc/scsi/scsi
Host: scsi2 Channel: 00 Id: 00 Lun: 29
  Vendor: EMC      Model: SYMMETRIX        Rev: 5874
  Type:   Direct-Access                    ANSI SCSI revision: 05
Related Post