In Linux Server Calculate The Wwn Numbers of Hba Cards
World Wide Names (WWN) are unique identifiers assigned to Host Bus Adapters (HBAs) in storage area networks (SANs). These identifiers help in uniquely identifying HBAs and their associated storage devices. In a Linux server environment, calculating or verifying the WWN numbers of HBA cards is essential for proper SAN configuration and troubleshooting.
What is WWN in HBA Cards?
A World Wide Name (WWN) is a unique 64-bit identifier assigned to a device in a Fibre Channel (FC) or iSCSI storage network. For HBA cards, the WWN serves as a persistent identifier that remains consistent even if the physical HBA is replaced.
WWNs are typically represented in one of two formats:
- 8-byte format: Displayed as 16 hexadecimal digits (e.g., 20:00:00:25:35:01:01:00)
- 16-byte format: Displayed as 32 hexadecimal digits (e.g., 50:05:07:68:01:02:03:04:05:06:07:08:09:0a:0b:0c)
The WWN is stored in the HBA's non-volatile memory and is used by the SAN to uniquely identify the HBA and its associated storage devices.
How to Find WWN Numbers in Linux
In a Linux environment, you can find the WWN numbers of HBA cards using several methods:
Method 1: Using lspci Command
The lspci command can display the WWN of an HBA card if it is a Fibre Channel HBA. Run the following command:
lspci -nn | grep -i fibre
This will list Fibre Channel HBAs along with their PCI device IDs. The WWN is typically displayed in the output.
Method 2: Using cat Command
For Fibre Channel HBAs, you can directly read the WWN from the HBA's sysfs entry:
cat /sys/class/fc_host/host*/port_name
This command will display the WWN of the Fibre Channel HBA in the standard 16-byte format.
Method 3: Using sanlun Command
If you have the NetApp Host Utilities installed, you can use the sanlun command to display HBA information, including the WWN:
sanlun fcp show adapter
This command provides detailed information about the Fibre Channel adapters, including their WWNs.
Method 4: Using ip Command
For iSCSI HBAs, you can use the ip command to find the iSCSI Qualified Name (IQN), which is similar to a WWN:
ip link show | grep -i iscsi
This command lists iSCSI interfaces, and you can find the IQN associated with the HBA.
Formula Used
The WWN of an HBA card is typically a 64-bit identifier that is either:
- Read directly from the HBA's non-volatile memory
- Derived from the HBA's manufacturer-assigned identifier
In Linux, the WWN is usually represented in hexadecimal format. The formula for calculating or verifying the WWN is:
WWN = Manufacturer's Unique Identifier + Device-Specific Identifier
The exact calculation depends on the HBA manufacturer and the type of storage protocol (Fibre Channel, iSCSI, etc.).
Worked Example
Suppose you have a Fibre Channel HBA card in your Linux server. You can find its WWN using the following steps:
- Open a terminal window.
- Run the command:
cat /sys/class/fc_host/host*/port_name - The output will display the WWN in the format:
20:00:00:25:35:01:01:00
This WWN uniquely identifies your HBA card in the SAN environment.
FAQ
What is the difference between WWN and WWPN?
WWN (World Wide Name) is a generic term for unique identifiers in storage networks. WWPN (World Wide Port Name) specifically refers to the unique identifier for a Fibre Channel port. In most cases, the terms are used interchangeably.
Can I change the WWN of an HBA card?
No, the WWN is a hardware-assigned identifier and cannot be changed. It is burned into the HBA's non-volatile memory during manufacturing.
How do I verify the WWN of an HBA card?
You can verify the WWN using the methods described in the "How to Find WWN Numbers in Linux" section. The WWN should match the one provided by the HBA manufacturer.