How to Find WWN, WWNN and WWPN Number of HBA Card in Linux

There are several ways/commands to determine the WWN of a Fibre Channel (FC) HBA and their details in Linux/Unix operating systems.

What is SAN?

Most IT industries use SAN (Storage Area Network) and fas I/O for greater performance.

SAN is a high-speed network that creates connections between storage devices and servers, providing better performance. It is connected to the Fiber Channel (FC) with HBA.

SCSI (Small System System Interface) is a protocol used to communicate between servers and storage devices.

Why Do You Need a wwn Number?

If any Linux server or system is connected to one or more SAN switches through Fibre Channel (FC) HBA cards then storage team have to create a zoning on fiber channel switch to assign and unassign storage to a specific Linux host.

The following hardware related Linux commands help identify other hardware information on the Linux system.

If you need additional storage for the Linux host, you must provide the storage team with a WWN number, and they assign a new LUN based on the WWN number.

You must scan the SCSI host to find new LUNs assigned by the storage team.

The famous FC Host Bus Adapters are QLogic, Emulex, Brocade, Cisco, etc.

Some of the important key notes about this.

  • WWN – World Wide Name
  • WWNN – World Wide Node Name
  • WWPN – World Wide Port Name
  • WWID – World Wide Identifier
  • OUI – Organizationally Unique Identifier

How to Find a List of HBA Cards Installed on a Linux System

You can easily identify how many HBA cards are installed on your Linux system by running the lspci command.

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

If you want to find information about other bus devices in Linux see the following article.

HBA card information can be identified in two ways in Linux and the details are described below.

Method-1: How to Identify an HBA Card Information in Linux Manually

You can find HBA card information by listing from sysfs as follows.

The sysfs filesystem is a pseudo-filesystem which provides an interface to kernel data structures.

The files under sysfs provide information about devices, kernel modules, filesystems, and other kernel components.

The sysfs filesystem is commonly mounted at /sys. Typically, it is mounted automatically by the system.

Go to the below path to check for available HBA ports.

# ls -l /sys/class/fc_host
total 0
lrwxrwxrwx 1 root root 0 Oct 26 17:10 host1 -> ../../devices/pci0000:00/0000:00:02.0/0000:03:00.0/host1/fc_host/host1
lrwxrwxrwx 1 root root 0 Oct 26 17:10 host2 -> ../../devices/pci0000:00/0000:00:02.2/0000:04:00.0/host2/fc_host/host2
lrwxrwxrwx 1 root root 0 Oct 26 17:10 host3 -> ../../devices/pci0000:00/0000:00:02.2/0000:04:00.0/host2/fc_host/host3
lrwxrwxrwx 1 root root 0 Oct 26 17:10 host4 -> ../../devices/pci0000:00/0000:00:02.2/0000:04:00.0/host2/fc_host/host4

Go to the below path to view the HBA ports used on the Linux system.

# ls -lrt /sys/class/fc_transport/

drwxr-xr-x  2 root root 0 May 27 09:40 target7:0:2
drwxr-xr-x  2 root root 0 May 27 09:40 target7:0:1
drwxr-xr-x  2 root root 0 May 27 09:40 target7:0:0
drwxr-xr-x  2 root root 0 May 27 09:40 target5:0:2
drwxr-xr-x  2 root root 0 May 27 09:40 target5:0:1
drwxr-xr-x  2 root root 0 May 27 09:40 target5:0:0

Go to the below path to find the fc host (HBA card) wwn number on the Linux system.

# cat /sys/class/fc_host/host?/port_name

0x500143802426baf2
0x500143802426baf3
0x500143802426baf4
0x500143802426baf5

If you want to check a specific fc host wwn number, use the following format.

# cat /sys/class/fc_host/host1/node_name

0x500143802426baf2

Go to the below path to check the state of HBA ports.

# more /sys/class/fc_host/host?/port_state

::::::::::::::
/sys/class/fc_host/host1/port_state
::::::::::::::
Online
::::::::::::::
/sys/class/fc_host/host2/port_state
::::::::::::::
Online
::::::::::::::
/sys/class/fc_host/host3/port_state
::::::::::::::
Online
::::::::::::::
/sys/class/fc_host/host4/port_state
::::::::::::::
Online

Method-2: How to Identify an HBA Card Information in Linux Using systool Command

The systool is a tool that uses APIs provided by libsysfs to gather information. It allows you to view system device information by bus, class, and topology.

When you run systool without parameters will present all available bus types, device classes, and root devices.

How to Install systool on Linux

systool can be easily installed from the distribution official repository.

For RHEL/CentOS 6/7 systems, use the yum command to install systool.

$ sudo yum install -y sysfsutils

For RHEL/CentOS 8 and Fedora systems, use the dnf command to install systool.

$ sudo dnf install -y sysfsutils

Once the sysfsutils package is installed on the Linux system, run the following command to find the WWN number of fc host.

# systool -c fc_host -v | grep port_name

    port_name           = "0x500143802426baf2"
    port_name           = "0x500143802426baf3"
    port_name           = "0x500143802426baf4"
    port_name           = "0x500143802426baf5"

Run the following command to check the state of HBA ports.

# systool -c fc_host -v | grep port_state

    port_state          = "Online"
    port_state          = "Online"
    port_state          = "Online"
    port_state          = "Online"

If you want to check a specific fc host wwn number, run the following command.

# systool -c fc_host -v -d host2 | grep port_name

Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

You may also like...