15 Practical Linux Multipath Examples for Storage Management

Linux Multipath command is used to manage storage SAN (storage area network) disks on OS side.

Linux multipath provides a way of organizing the I/O paths logically, by creating a single multipath device on top of the underlying devices.

  • How to get the HBA port name on Linux
  • Show the existing multipath configuration in brief
  • How to Get the HBA WWPN on Linux?
  • How to Get the HBA WWNN on Linux?
  • How to rescan scsi bus to get the new LUNs on Linux?
  • How to Blacklist a device in multipath on Linux?
  • How to add path_selector in multipath?

How to get the HBA port name on Linux

# systool -c fc_host -A port_name

Class = "fc_host"
Class Device = "host0"
port_name = "0x50060b0000c2a67c"
Device = "host0"
Class Device = "host1"
port_name = "0x50060b0000c2a67e"
Device = "host1"

The command systool -c fc_host -A port_name is used in Linux to retrieve specific information about Fibre Channel Host Bus Adapters (HBAs), particularly their port_name. Let’s break down what each part of the command means:

systool

systool is a command-line utility that allows you to view information about devices connected to your Linux system.

It queries the sysfs filesystem, which is a virtual filesystem provided by the kernel to export information about devices, drivers, and kernel objects. systool presents this information in a more human-readable format than directly navigating sysfs directories.

It’s particularly useful for:

  • Inspecting hardware properties.
  • Debugging driver issues.
  • Gathering specific device identifiers.

-c fc_host

See also: Mastering the Linux Command Line — Your Complete Free Training Guide

The -c option stands for “class.” This specifies that we want to query a particular class of devices. fc_host refers to the Fibre Channel Host class. Fibre Channel is a high-speed network technology primarily used to connect servers to shared storage devices (like SANs – Storage Area Networks). A Fibre Channel HBA (Host Bus Adapter) is the physical card in your server that facilitates this connection.

So, -c fc_host tells systool to focus on all detected Fibre Channel HBA devices on the system.

-A port_name

The -A option stands for “attribute.” This specifies that we want to display the value of a particular attribute for the devices in the selected class. port_name is an attribute specific to Fibre Channel HBAs. It refers to the World Wide Port Name (WWPN).

What is a WWPN? The WWPN is a globally unique identifier assigned to a Fibre Channel port. It’s a 64-bit address, typically represented as a 16-character hexadecimal string (e.g., 5001438012345678).

  • It’s similar in concept to a MAC address for Ethernet, but for Fibre Channel.
  • WWPNs are crucial for Fibre Channel zoning and LUN masking in a SAN environment, as they uniquely identify each initiator port on the host.

What the command does together:

When you run systool -c fc_host -A port_name, the command will:

  1. Scan through all the devices registered under the fc_host class in the sysfs filesystem.
  2. For each fc_host device found (i.e., each Fibre Channel HBA or port), it will attempt to read the value of its port_name attribute.
  3. It will then print the port_name (WWPN) for each detected Fibre Channel port.

Example Output:

A typical output might look like this:

Class = "fc_host"

  Class Device = "host0"
    port_name           = "0x5001438012345678"

  Class Device = "host1"
    port_name           = "0x500143809abcdef0"

In this example:

  • host0 and host1 are the device names assigned by the kernel to your Fibre Channel HBA ports.
  • 0x5001438012345678 and 0x500143809abcdef0 are the respective WWPNs for those ports.

To get the port id

# systool -c fc_host -A port_id
Class = "fc_host"
Class Device = "host0"
port_id = "0x310305"
Device = "host0"
Class Device = "host1"
port_id = "0x25030f"
Device = "host1"

Show the existing multipath configuration in brief

The mpathconf command itself is a utility used on Red Hat Enterprise Linux (RHEL) and CentOS systems (and derivatives) to configure the device-mapper-multipath service.

It simplifies the process of enabling, disabling, and setting various options for multipathing.

# mpathconf
multipath is enabled
find_multipaths is disabled
user_friendly_names is enabled
dm_multipath module is loaded
multipathd is running

mpathconf is a helper tool on Linux for configuring Device Mapper Multipath (DM-Multipath).

Multipath allows a server to access the same storage device through multiple physical paths (e.g., dual HBAs to SAN). This provides:

  • High availability (failover if one path goes down)
  • Load balancing across paths

Instead of manually editing /etc/multipath.conf and managing the multipathd service, mpathconf does the setup for you.

Using user-friendly names for multipath

Each multipath device has a World Wide Identifier (WWID), which is guaranteed to be globally unique and unchanging. By default, the name of a multipath device is set to its WWID.

Alternately, you can set the user_friendly_names option in the multipath configuration file, which sets the alias to a node unique name of the form mpathn.

With user_friendly name disabled we will only see the WWID of the multipath connected.

# multipath -l
3624a937079ebbf3c903141360001149c dm-2 PURE ,FlashArray
size=1.0T features='0' hwhandler='0' wp=rw
`-+- policy='queue-length 0' prio=1 status=active
|- 13:0:0:249 sdo 8:224 active ready running
|- 11:0:0:249 sdr 65:16 active ready running
|- 11:0:1:249 sdas 66:192 active ready running
`- 13:0:1:249 sdan 66:112 active ready running

Next, enable user_friendly name

# /sbin/mpathconf --user_friendly_names y

Check the multipath

# multipath -l
mpathb (3600c0ff000144876065be35a01000000) dm-6 HP ,P2000 G3 FC
size=359G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=0 status=active
| `- 2:0:0:1 sdb 8:16 active undef unknown
`-+- policy='service-time 0' prio=0 status=enabled
`- 2:0:1:1 sdd 8:48 active undef unknown

The mapping is done using /etc/multipath/bindings.

how to Check the HBA port name on your Linux box

  • /sys/class/fc_host/ shows Fibre Channel HBA ports.
  • Each hostX = one FC port.
  • Inside you can check WWPN, WWNN, speed, and link state.

# ls -l /sys/class/fc_host/
total 0
lrwxrwxrwx 1 root root 0 May 22 18:29 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 host1 -> ../../devices/pci0000:00/0000:00:02.0/0000:04:00.3/host1/fc_host/host1

# lspci -nn |grep -i "Fibre"
04:00.2 Fibre Channel [0c04]: Emulex Corporation OneConnect 10Gb FCoE Initiator (be3) [19a2:0714] (rev 01)
04:00.3 Fibre Channel [0c04]: Emulex Corporation OneConnect 10Gb FCoE Initiator (be3) [19a2:0714] (rev 01)
# lspci -nn |grep -i "HBA"

How to Get the HBA WWPN on Linux?

A worldwide port number (WWPN) is unique identifier for each FC port of any Fibre Channel device.

For server, we have a WWPN for each port of the HBA.

For a SAN switch, the WWPN is available for each port in the chassis.

For Storage, each host port has an individual WWPN.

Here we have two HBA so each HBA will have unique World Wide Port Name (WWPN) which will be connected to the SAN switch then to the Storage Box.

From my Linux Box

# cat /sys/class/fc_host/host0/port_name
0x50060b0000c2a67c
# cat /sys/class/fc_host/host1/port_name
0x50060b0000c2a67e

These are the WWPN number.

How to Get the HBA WWNN on Linux?

A worldwide node name (WWNN) is a globally unique 64-bit identifier that is assigned to each Fibre Channel node or device.

For servers and hosts, WWNN is unique for each HBA (host bus adapter), and in a case of a server with two HBAs, they have two WWNNs.

For a SAN switch, the WWNN is a common for the chassis.

For storage, the WWNN is common for each controller unit of midrage storage

Since here I have two HBA hence there are two WWNN for each HBA

From my Linux Box

# cat /sys/class/fc_host/host1/node_name
0x50060b0000c2a67f
# cat /sys/class/fc_host/host0/node_name
0x50060b0000c2a67d

How to rescan scsi bus to get the new LUNs on Linux?

If you have new LUNs connected to your Linux box then you will need to rescan the HBA

Assuming you know the WWPN for which the new LUN was added

# echo 1 > /sys/class/fc_host/host2/issue_lip
# systemctl reload multipathd
# multipath -v2

Next validate if the new LUN is visible using
# multipath -ll

How to Blacklist a device in multipath on Linux?

Create a function like below in /etc/multipath.conf where you can give the list of devices which you wish to blacklist.

Here I am blacklisting multiple devices which I do not wish to be created as multipath.

blacklist {
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z][[0-9]*]"
devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]"
}

Add blacklist exception for selected disks

Similar to blacklisting we can also add a blacklist exception so that these devices are not blacklisted. Add below function in /etc/multipath.conf with the list of wwid which you wish to add as an exception for blacklist.

blacklist_exceptions {
wwid "3600d0230000000000e13955cc3757803"
}

Followed by reload of multipathd

# systemctl reload multipathd.service

How to add path_selector in multipath?

Add your choice of path_selector in /etc/multipath.conf as shown below

defaults {
user_friendly_names yes
failback immediate
path_selector "round-robin 0"
}

Either you add it under default function or you can add a device function if you wish to add to change path selector only for a selected device

devices {
device {
vendor "HP"
product "P2000 G3 FC|P2000G3 FC/iSCSI|P2000 G3 SAS|P2000 G3 iSCSI"
path_grouping_policy "failover"
path_selector "round-robin 0"
}
}

NOTE: You can get the device detail from “multipathd show config

Related post:

David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 275

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *