Skip to Content

15 Linux multipath examples

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"

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

This is an alternate command which can be used to check the loaded configuration for selected values as shown below.

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

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

# 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:

4 Commands to Check HBA WWN WWNN WWPN on Linux

Resize Multipath disk on Linux

How Disk Multipath works on Linux