Tuesday, 2 April 2013

WWN IDs and HBA Port Mappings from SCSI Disks under Linux

Extracting WWN IDs and HBA Port Mappings from SCSI Disks under Linux:


This note presents a technique to extract the unique Scsi id for each disk attached to a Linux-based server. The accessible disks may be installed directly on the server or connected via a host bus adapter card (HBA) to a storage area network (SAN) or switch. If the disks are attached via SAN, the path and port information is also extracted.

SCSI ID Extraction

The small computer storage interface (Scsi) commonly connects hard disks, tape devices, DVD-players, floppy drives, etc. through a common interface to Linux-based servers. Disk arrays that are grouped together as logical unit number (LUN) storage in SANs can also present themselves as Scsi devices on Linux servers. The command fdisk -l lists attached Scsi disk devices, including those from a SAN. 

When multiple LUNs from a SAN are attached to a server the mapping to the device list generated by the fdisk command is not readily apparent. It is often necessary for system administrative purposes to generate this mapping. For example, one or more of the disks composing a LUN may be failing and user files need to be migrated off it. A LUN may have special characteristics such as a wide RAID-stripe or cache setting that a file system like General Parallel File System (GPFS) relies on to optimize performance. For such reasons, identifying the mapping of the LUNs to the fdisk list is of importance.

Our sample system consists of a x86_64 server running Red Hat Enterprise Linux 5.5 with two local disks and six remote disks that reside on a SAN connected to the server through a fibre channel HBA. The SAN connection on the server is handled by the Redundant Disk Array Controller (RDAC) muti-path proxy driver (mpp). Typing fdisk -l yields (output edited for clarity):

Disk /dev/sda: 250.0 GB
Disk /dev/sdb: 750.1 GB
Disk /dev/sdc: 8818.3 GB
Disk /dev/sdd: 9663.6 GB
Disk /dev/sde: 7516.1 GB
Disk /dev/sdf: 8818.3 GB
Disk /dev/sdg: 8589.9 GB
Disk /dev/sdh: 8589.9 GB

Using the command scsi_id for each /block/a-h (for example, for /dev/sda we type scsi_id -g -s /block/sda) generates the output:

SATA WD2502ABYS-23B7 WD-WCAT1H504691 
SATA HUA721075KLA330 GTA260P8H8893E


The two initial Scsi ids represent the local disks (/dev/sda and /dev/sdb). The remaining six represent the Scsi ids of the fibre channel attached LUNs. A subset of the output string scsi_id generates for the fibre LUNs matches the World Wide Name (WWN). On an IBM DS based storage, the WWN for a LUN information is accessible using the SMclient software in section on Arrays/LUNs. 

Path Extraction

With the Scsi id mapped to the WWN LUN, we turn our attention to the task of identifying through which HBA port a LUN is being presented to the server. The command lspci | grep -i fibre generates a list of fibre channel

HBA cards installed on our sample storage server running RDAC:

12:00.0 Fibre Channel: Qlogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA
12:00.1 Fibre Channel: Qlogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA

This shows a single 2-port 8Gb fibre channel host bus adapter card (HCA or HBA) with ports 0.0 and 0.1. Next we examine the SAN disks sdc-sdh in /sys/block. For the disks, the command ls -l /sys/block/sd[c-h]/device displays (edited for relevance):

../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:0 (disk sdc)
../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:1 (disk sdd)
../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:2 (disk sde)
../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:3 (disk sdf)
../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:4 (disk sdg)
../../devices/mppvirtual/mppadapter0/host6/target6:0.0/6:0:0:5 (disk sdh)

The sub-string “6:0.0” refers to the file /proc/scsi/mpp/6 in the RDAC mpp driver directory with port 0.0 being used. The last digit of each output line above refers to the LUN number. Searching for the Lun numbers directly within the file /proc/scsi/mpp/6 reveals the WWN name for each disk that matches the result scsi_id extracted. 


Using the two techniques above, a Scsi disk on a Linux server can be mapped to the LUN on a SAN and the I/O path (HBA and port number) it uses is also extracted. This method has been successfully used on RHEL, CentOS and SLES connected to IBM DS, DDN, EMC and HP storage SANs.

0 blogger-disqus:

Post a Comment