How To Find Fiber Host Bus Adapter (Fiber HBA) WWN On Linux

Here are some useful commands for the most popular Linux/Unix operating systems to find your HBA WWN. For brevity sake I am dividing this into a number of posts. For this one, it’s Linux, verified on CentOS/Redhat and Suse Linux Enterprise Server.

Useful stuff I hope, at least to me, because while we all love fiber storage, before it can even get presented to your server your Storage Admin needs to know your server’s HBA’s WWN (whether you are using a fiber switch or plugging directly). So here we go!

p.s. (pre-script) WE LOVE FIBER

I LOVE FIBER!


Oh, and because of strange google search results, you might have come here looking to find info on getting HBA WWN info on a different OS than what is featured here. So a quick run down of what I have available:

Okay onward!!

By the way those Fiber One bars TOTALLY kick my butt. I like them, they’re delish, but I can’t eat more than half at one time because otherwise I get the stomach rumblies all day and can’t function.

My friend says it’s the chickory root.

Anyway…

If you have QLogic

Before I start, if you have QLOGIC, you might want to skip down to the bottom where I mention “QLOGIC ROCKS” because QLOGIC has a nice set of management tools you can use …

Otherwise if you are not using QLOGIC, then onward sysadmin traveler!


Sponsored Links

LINUX: Finding Fiber HBA WWN

Linux Clipart
Verified on Suse Linux Enterprise Server and CentOS/Redhat

The info is in

/sys/class/scsi_host/hostN/device/fc_host/hostN/port_name

Where “N” is the number of device for your fiber HBAs.

Unfortunately, you may have a large number of listings depending on the different cards (besides fiber HBA) that you have on your system. In my example, I have six listings:


host0
host1
host2
host3
host4
host5

but only two represent a fiber HBA.

So you may have to do some digging. In my case they are


host4
host5

(I have two HBAs installed)

So …

[root@centos63node01 ~]# cat /sys/class/scsi_host/host4/device/fc_host/host4/port_name
0x5001438003af1ffc
[root@centos63node01 ~]# cat /sys/class/scsi_host/host5/device/fc_host/host5/port_name
0x5001438003af1b9e
[root@centos63node01 ~]#

Here is a one liner command to find it. This is added 2/28/2014 per a comment on my blog made by reader Liivo L (THANKS Liivo L!!)

[root@testlinux ~]# cat /sys/class/scsi_host/host*/device/fc_host/host*/node_name
0x20000024ff5763d2
0x20000024ff5763d3

[root@testlniux ~]#

This is the way I did have it written down prior to Liivo L’s comment. Here’s my shortcut bash command if you don’t want to look around. This command is executed in the /sys/class/scsi_host directory. While the one liner command is easier, this is a nice example of using a “for do done” loop on your command line (very handy for many other things)

[root@centos63node01 scsi_host]# for i in 0 1 2 3 4 5; do cat host$i/device/fc_host/host$i/port_name; done
cat: host0/device/fc_host/host0/port_name: No such file or directory
cat: host1/device/fc_host/host1/port_name: No such file or directory
cat: host2/device/fc_host/host2/port_name: No such file or directory
cat: host3/device/fc_host/host3/port_name: No such file or directory
0x5001438003af1ffc
0x5001438003af1b9e
[root@centos63node01 scsi_host]#


Sponsored Links

And by the by..QLOGIC ROCKS!

I strongly recommend QLOGIC HBA’s or any rebranded QLOGIC HBA.

Consider me old school, but when I first started in SAN and fiber it was pretty much QLOGIC vs Emulex. And we were having bad luck with Emulex. First, it wasn’t even supported on some of the unix platforms I was working on, and second we were having strange blips with Emulex in our production database (on Solaris with Sun Storage) and when I called Sun, they recommended I move to QLOGIC. Which I did. Problems gone.

(No wonder that QLOGIC for the longest time cost maybe twice as much as Emulex?)

Sure that was maybe 7 years ago, and things have probably improved since then, but sysadmins are a superstitious lot that when we find something that works, it’s hard to teach us new tricks sometimes.

Then again, have you seen how much time and resources are devoted to QLOGIC drivers and management?

As an example, I don’t go through any of the above shenangigans if I have QLOGIC. I just download QLOGIC’s command line tool (scli) which installs like a dream and you can use it to find anything and everything about your HBAs.

QLOGIC sansurfer scli screenshot
Okay..soapbox off now :)

THAT’S ALL FOLKS!!!

That's All Folks!
Hope this has been helpful! It is very helpful information to me at least knowing how to find the WWN of my fiber so don’t poopoo it please!!

(Did you see what I did there?)

, , , , Linux

17 thoughts on “How To Find Fiber Host Bus Adapter (Fiber HBA) WWN On Linux

  1. can we get all the info which we get from scli, without that ?

    if we don’t have scli installed on ? how to get all the information about HBA’s ?

    ofcourse we will get the WWPN nos. from “cat /sys/class/fc_host/hostX/port_name”

  2. From what I know, you can only get basic info about the HBA itself using the existing OS files (in /sys and /proc). As opposed to SCLI is a tool put out by qlogic meant to work with the qlogic hardware to give you a lot more info about the HBA and what it is connected to including target luns, etc.

    So my answer is that no, you wouldn’t get all the info without scli.

    The next question is, what info do you need? If it’s just basic HBA info (model, wwpn, etc) then you should be able to get it. Advanced stats and info about the storage, likely not. Unfortunately I don’t have a qlogic HBA on a server hooked up to a fiber storage handy so I can’t verify, but from what I recall this is how it is.

  3. Thanks for your efforts and the oneliner, theres always something to learn! :)

    You can very easy find the emulex HBAs on the CLI – Just use …

    hbacmd ListHBAs

    Ciao,
    Hans

  4. Hi,

    I would lik eto know script in Linux server that how many hba wwpns are connected to Fabric .

    I have sample script for AIX as given below , based on that can youplease help me to generate script for Linux server to find out connected WWPNs pl

    Script for AIX connected WWPN numbers as given below

    for i in $(lsdev -C|awk ‘/^fcs/ {print $1}’);do echo “$i\t$(lscfg -vl $i|awk -F. ‘/Network Address/ {print $NF}’)”

    This will generate output only for connected WWPNs to fabric , similarly can you please help me to get same for Linux hosts

    Thanks in advance

    Nag

  5. here is another single line command that will give you the hostX information also.

    # grep 0x /sys/class/scsi_host/host*/device/fc_host/host*/port_name
    /sys/class/scsi_host/host2/device/fc_host/host2/port_name:0x1000c4346b20d5ee
    /sys/class/scsi_host/host3/device/fc_host/host3/port_name:0x1000c4346b20d5ef
    /sys/class/scsi_host/host4/device/fc_host/host4/port_name:0x1000c4346b20d5c2
    /sys/class/scsi_host/host5/device/fc_host/host5/port_name:0x1000c4346b20d5c3

Leave a Comment

Your email address will not be published. Required fields are marked *

Spam protection by WP Captcha-Free