How to check Fibre Channel HBAs in Linux

Last updated on 06th February 2014

Fibre Channel (FC) Host Bus Adapters(HBA) are interface cards that connects the host system to a fibre channel network or devices. The two major manufacturers of FC HBAs are QLogic and Emulex and the drivers for many HBAs are distributed in-box with the Operating Systems. If the drivers are not available on your Linux version, you need to install them manually and load the modules in kernel

Here is a step by step guide to verify that your FC HBAs installed and configured correctly.

Step-1: Determine the Manufacturer and Model of the HBAs.

Run the lspci command to list all PCI cards detected on the system.

# lspci | grep "Fibre Channel"
07:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
0a:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)

The above output shows the system bus has detected two QLogic HBAs.

Step-2: Get the Vendor and Device IDs for the HBAs installed.

These can be obtained from the file /usr/share/hwdata/pci.ids

# vi /usr/share/hwdata/pci.ids
.....
1077  QLogic Corp.
	2532  ISP2532-based 8Gb Fibre Channel to PCI Express HBA
.....

The vendor id for QLogic is 1077 and the device id is 2532. You could confirm this using the lspci -nn command as shown below

# lspci -nn | grep "Fibre Channel"
07:00.0 Fibre Channel [0c04]: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA [1077:2532] (rev 02)
0a:00.0 Fibre Channel [0c04]: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA [1077:2532] (rev 02)

Step-3: Check if the driver modules are installed.

This can be done by searching the list of available modules. (Replace 2.6.18-308.el5PAE with your kernel version in the command below)

# grep 1077 /lib/modules/2.6.18-308.el5PAE/modules.* | grep 2532
/lib/modules/2.6.18-308.el5PAE/modules.alias:alias pci:v00001077d00002532sv*sd*bc*sc*i* qla2xxx
/lib/modules/2.6.18-308.el5PAE/modules.pcimap:qla2xxx              0x00001077 0x00002532 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

The above output shows that this HBA is supported by the module qla2xxx

Step-4: Check if the drivers for these HBAs are loaded in the kernel.

The lsmod command will list the currently loaded kernel modules

# lsmod | grep qla2xxx
qla2xxx              1205905  0
scsi_transport_fc      44745  1 qla2xxx
scsi_mod              144277  16 be2iscsi, ib_iser, iscsi_tcp, bnx2i, libcxgbi, libiscsi2, scsi_transport_iscsi2, scsi_dh, sr_mod, sg, usb_storage, qla2xxx, scsi_transport_fc, libata,cciss, sd_mod

The output shows the module qla2xxx is loaded by the kernel. If you don't see any output for lsmod command then you can load the module using modprobe command

# modprobe -v qla2xxx

Step-5: Getting detailed information

You can find detailed information about the fibre channel adapters in the location /sys/class/fc_host/

# ll /sys/class/fc_host/
drwxr-xr-x 3 root root 0 Feb  5 11:28 host3
drwxr-xr-x 3 root root 0 Feb  5 11:28 host4

The directories host3 and host4 in the example above contains information specific to each adapter like node name (WWN), port name (WWN), type, speed,state etc.,

An easier way to get this information is to use the systool command.

# systool -c fc_host
Class = "fc_host"
  Class Device = "host3"
    Device = "host3"
  Class Device = "host4"
    Device = "host4"

The -v option gives you detailed output

# systool -c fc_host -v host3
Class = "fc_host"

 Class Device = "host3"
 Class Device path = "/sys/class/fc_host/host3"
   fabric_name         = "0x50014380272531e9"
   issue_lip           = <store method only>
   node_name           = "0x50014380281412e9"
   port_id             = "0x0000e8"
   port_name           = "0x50014380281412e8"
   port_state          = "Online"
   port_type           = "LPort (private loop)"
   speed               = "8 Gbit"
   supported_classes   = "Class 3"
   supported_speeds    = "1 Gbit, 2 Gbit, 4 Gbit, 8 Gbit"
   symbolic_name       = "HPAK344A FW:v5.06.03 DVR:v8.03.07.09.05.08-k"
   system_hostname     = ""
   tgtid_bind_type     = "wwpn (World Wide Port Name)"
   uevent              = <store method only>

   Device = "host3"
   Device path = "/sys/devices/pci0000:00/0000:00:01.0/0000:07:00.0/host3"
     edc               = <store method only>
     fw_dump           =
     nvram             = "ISP "
     optrom_ctl        = <store method only>
     optrom            =
     reset             = <store method only>
     sfp               = ""
     uevent            = <store method only>
     vpd               = "&"

Post a comment

Comments

vizzy | February 20, 2018 5:19 PM |

unfortunately systools is no more available in most distros

ItReallyIs | July 22, 2020 1:10 PM |

You're using the wrong distro then, it's in rhel/centos 7.

gregvu | November 8, 2017 6:52 AM |

Hello, How we can tell, that we have 2 x 2-port hba and not 4 x 1 hba port hba? Thanks10:00.0 Fibre Channel: Emulex Corporation Lancer-X: LightPulse Fibre Channel Host Adapter (rev 30) 10:00.1 Fibre Channel: Emulex Corporation Lancer-X: LightPulse Fibre Channel Host Adapter (rev 30) 15:00.0 Fibre Channel: Emulex Corporation Lancer-X: LightPulse Fibre Channel Host Adapter (rev 30) 15:00.1 Fibre Ch

BalaPobi | July 14, 2017 10:06 AM |

Nice information and very simple to understand.

Ed | February 10, 2017 6:40 AM |

Only seems to miss checking you have the card(s) in the correct width slot: lspci |grep Fibre |awk '{print $1}' |xargs -I {} lspci -s {} -vv |egrep "LnkCap|LnkSta" check that Link Capability and Link State are equal. (Not 100%, some older chips in 4Gb and 8Gb can be x8 capable and the cards are x4.) eg: broken card: LnkCap: Port #0, Speed 5GT/s, Width x8 LnkSta: Speed 5GT/s, Width x4,

Ed | February 10, 2017 6:40 AM |

Only seems to miss checking you have the card(s) in the correct width slot: lspci |grep Fibre |awk '{print $1}' |xargs -I {} lspci -s {} -vv |egrep "LnkCap|LnkSta" check that Link Capability and Link State are equal. (Not 100%, some older chips in 4Gb and 8Gb can be x8 capable and the cards are x4.) eg: broken card: LnkCap: Port #0, Speed 5GT/s, Width x8 LnkSta: Speed 5GT/s, Width x4,

Janardhan AK | May 11, 2016 7:28 AM |

Good link, Had my hba configured, But have an other problem where hba is showing down.

Vivek | March 16, 2016 11:05 AM |

Nice and precise.

Kiran | December 18, 2015 9:53 AM |

Simple and clear.

Naga | December 5, 2015 11:41 AM |

to find the kernel modules for the devices, we can use #lspci -k instead. 05:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02) Subsystem: Hewlett-Packard Company Device 338e Kernel driver in use: qla2xxx Kernel modules: qla2xxx 05:00.1 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)

Olivier | November 27, 2015 12:29 PM |

Very useful, thanks!

Daniel | October 30, 2015 3:21 PM |

Great info! Thanks!

Priya | October 27, 2015 11:20 AM |

Very well explained. Thank you

anmol | August 4, 2015 5:18 AM |

neatly explained and accurate.