Linux get the list of FC HBA’s and WWPN

This simple script gives you the list of FC HBA detected in system. It query the sysfs filesystem to get the available fibre channel HBA. Script works for most of the Linux flavors, as specially any of Redhat, SUSE, Fedora and Centos distributions.

This script will not alter any of system configuration rather it just query the sysfs filesystem. Copy the script to server and execute it. Output collected under file “/tmp/hba_list.txt”.


This script will not list the HBA if there is any hardware or driver issue. In such case refer “dmesg“ to troubleshoot further.


# Display available FC Ports and their WWPN
echo "--------------------------------------------------"
echo -e "\tCollecting the available HBA details. \n\tOutput stored as /tmp/hba_list.txt"
echo "--------------------------------------------------"

for hba in `ls -d /sys/class/fc_host/host*`;do
FC_HOST=`basename $hba`
PortID=`cat $hba/port_id`
wwpn=`cat $hba/port_name`
state=`cat $hba/port_state`
speed=`cat $hba/speed`
hba=`cat $hba/symbolic_name`
cat << EOB >> /tmp/hba_list.txt

HBA WWPN : $wwpn PortId: $PortID
HBA State: $state Speed : $speed

Here is the sample of HBA details which has been collected by above script.

#cat /tmp/hba_list.txt

FC-Host: host1
HBA WWPN : 0x5001439994c99988 PortId: 0x100300
HBA State: Online Speed : 4 Gbit

FC-Host: host2
HBA WWPN : 0x5001439994c9998a PortId: 0x0f0300
HBA State: Online Speed : 4 Gbit
There are no attachments for this article.
Related Articles RSS Feed
Linux – Securing your important files with XFS extendend attributes
Viewed 6404 times since Wed, Jul 25, 2018
RHEL: Scan and configure new SAN (fibre channel) LUNs
Viewed 5577 times since Sun, May 27, 2018
RHEL: Manually encrypting a filesystem with LUKS
Viewed 2007 times since Sun, May 27, 2018
linux aix Killing a process and all of its descendants
Viewed 1420 times since Tue, May 5, 2020
python learning
Viewed 808 times since Wed, Dec 18, 2019
How to create a Systemd service in Linux
Viewed 902 times since Mon, Dec 7, 2020
3 Ways to Check Linux Kernel Version in Command Line
Viewed 9488 times since Fri, Apr 19, 2019
Turbocharge PuTTY with 12 Powerful Add-Ons – Software for Geeks #3
Viewed 10977 times since Sun, Sep 30, 2018
List usernames instead of uids with the ps command for long usernames
Viewed 985 times since Wed, Jul 25, 2018
OpenSSL – sprawdzanie czy klucz pasuje do certyfikatu
Viewed 1521 times since Thu, May 24, 2018