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
Yum Update: DB_RUNRECOVERY Fatal error, run database recovery
Viewed 274 times since Fri, Jan 17, 2020
Viewed 562 times since Fri, Jul 27, 2018
Viewed 574 times since Fri, Nov 30, 2018
Linux - How to unlock and reset user’s account
Viewed 500 times since Fri, Jun 8, 2018
logrotate How log rotation works with logrotate
Viewed 751 times since Sun, Jan 12, 2020
Install Security Patches or Updates Automatically on CentOS and RHEL
Viewed 395 times since Fri, Oct 26, 2018
How log rotation works with logrotate
Viewed 1108 times since Fri, Nov 30, 2018
Szybkie sprawdzenie zewnętrznego adresu IP i hosta
Viewed 808 times since Thu, May 24, 2018
Install OpenVPN On CentOS / RHEL 7
Viewed 107 times since Fri, May 15, 2020
How to Migrate from RHEL 8 to CentOS 8
Viewed 93 times since Fri, May 15, 2020