System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to view SAN switch and SAN box details using the hardware path of the LUN in Linux

 
senthil_kumar_1
Super Advisor

How to view SAN switch and SAN box details using the hardware path of the LUN in Linux

There is one LUN assigned to one of the linux box...It is shown as "sda" with in linux...

I found some hardware path for this LUN "sda" using below steps...


lgora61:/ # cd /sys/block/sda

lgora61:/sys/block/sda # ll

lrwxrwxrwx 1 root root 0 Sep 18 2010 device -> ../../devices/pci0000:04/0000:04:0a.0/0000:06:01.0/host0/0:0:0:0



So I am thinking that "/devices/pci0000:04/0000:04:0a.0/0000:06:01.0/host0/0:0:0:0" is the path to the LUN "sda"...


Now I am having some questions:


1)Is "/devices/pci0000:04/0000:04:0a.0/0000:06:01.0/host0/0:0:0:0" hardware path?..If not, how to find the hardware path?

2)How to find the SAN switch and SAN box details from with in linux using above details?...If it is not using above details, how to find?
2 REPLIES
Simon Hargrave
Honored Contributor

Re: How to view SAN switch and SAN box details using the hardware path of the LUN in Linux

# scsi_id -g -u -s /block/sda

This will give you the WWID of the LUN, which you can map back to a vdisk depending on your array

# multipath -v3 | grep tgt

This will show you target WWN's of your array

As for switches, you'll need to refer to your SAN documentation for that :D
Alzhy
Honored Contributor

Re: How to view SAN switch and SAN box details using the hardware path of the LUN in Linux

The info for your SAN / HBA can be found in contents of files under:

/sys/class/fc_host/host*

For switch port ID:

cat /sys/class/fc_host/host*/port_id

Port Id identifies the switch port on the SAN switch your HBA is physically connected to. It varies from switch manu to switch manu and there is a table for that.


Take the following, save in a script say show_hbas.ksh, make executable and run as your regular tool:


#!/bin/ksh
#
# Display available FC Ports and their WWIDS
echo "show_hbas.ksh"
echo "v.0.1 Alzhy (crude. 02/2010)"
echo " "
for hba in `ls -d /sys/class/fc_host/host*`;do
FC_HOST=`basename $hba`
PortID=`cat $hba/port_id`
wwid=`cat $hba/port_name`
state=`cat $hba/port_state`
speed=`cat $hba/speed`
hba=`cat $hba/symbolic_name`
cat <FC-Host: $FC_HOST ($hba)
---------------------------------------------------------------------------
HBA WWID : $wwid PortId: $PortID
HBA State: $state Speed : $speed

EOB
done


Cheers!
Hakuna Matata.