How to check the number of HBA cards or ports are available in my Linux setup ?

In my earlier article I had given a bunch of commands which can help a newbie understand dm multipath

Tutorial/Cheatsheet: Begineer's Guide to Understanding Device Mapper Multipath for Linux

Method 1

On a Linux box with Emulex NIC card you can view the available HBA cards using below command

# lspci  | grep -i fibre
04:00.2 Fibre Channel: Emulex Corporation OneConnect 10Gb FCoE Initiator (be3) (rev 01)
04:00.3 Fibre Channel: Emulex Corporation OneConnect 10Gb FCoE Initiator (be3) (rev 01)

Here as you see my node has an Emulex 554FLB NIC card with be2net driver

# ethtool -i eth0 | grep driver
driver: be2net

On a Linux machine with Qlogic card you can use below command to check the available HBA cards

# lspci  | grep -i hba
03:00.0 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)
03:00.1 Fibre Channel: QLogic Corp. ISP2432-based 4Gb Fibre Channel to PCI Express HBA (rev 03)

Here as you see my node has an Qlogic 530FLB NIC card with bnx2x driver

# ethtool -i eth0 | grep driver
driver: bnx2x

Method 2

Or you can install sysfsutils rpm to get systool which can also show you similar information

# systool -D -c fc_host
Class = "fc_host"

  Class Device = "host0"

  Class Device = "host1"

Method 3

If you do not have this tool available then you can get the list of HBA at below location

# ls -ld /sys/class/fc_host/*
lrwxrwxrwx 1 root root 0 May 22 18:29 /sys/class/fc_host/host0 -> ../../devices/pci0000:00/0000:00:02.0/0000:04:00.2/host0/fc_host/host0
lrwxrwxrwx 1 root root 0 May 22 18:29 /sys/class/fc_host/host1 -> ../../devices/pci0000:00/0000:00:02.0/0000:04:00.3/host1/fc_host/host1

Here as you see I have two HBA with the name host0 and host1

I hope the article was useful.