Linux Multipath Configuration: multipath.conf for iSCSI SAN - 夜莺博客

Linux Multipath Configuration: multipath.conf for iSCSI SAN

A SAN LUN is only as reliable as its path count: with a single HBA or cable, one failure takes down the filesystem. Device-mapper multipath solves this by presenting one logical device (/dev/mapper/xxx) over many physical paths, failing over and load-balancing between them. This guide covers Linux multipath configuration for iSCSI and FC SANs: discovering the multiple paths, writing /etc/multipath.conf, choosing the path grouping policy, and verifying with multipathd.

Why Multiple Paths Appear as Multiple Disks

Each portal/HBA path to the same LUN shows up as a separate sd device (sdc, sdd, sde...). Writing directly to one of them bypasses failover and risks corruption if two paths are used simultaneously. Multipath detects that all these sd devices share one WWID (World Wide Identifier) and merges them into a single dm-X/mpatha device.

Confirm the paths are visible before configuring anything:

iscsiadm -m session -P3        # show sessions, portals and attached sd devices
ls -l /dev/disk/by-id/         # multiple wwn-* entries -> same WWID
multipath -ll                  # after setup: current multipath topology

For real redundancy, iSCSI paths should use at least two dedicated NICs on separate networks and switches, so a single switch or NIC failure does not take down every path.

Writing /etc/multipath.conf

If the SAN vendor has no specific template, start from a minimal configuration:

defaults {
    user_friendly_names yes
    find_multipaths yes
}

multipaths {
    multipath {
        wwid  36001405f01c2a3b4c5d6e7f8a9b0c1d2
        alias  san-lun01
    }
}

Key parameters that matter in production:

  • uid_attribute - how the WWID is read (default ID_SERIAL for SCSI; ID_WWN for NVMe).
  • path_grouping_policy - failover (one active path) or multibus (all paths active).
  • prio alua - on active/passive arrays, path priority is driven by SCSI-3 ALUA; with prio_args "exclusive_pref_bit" the preferred controller path group gets top priority.
  • path_checker tur - Test Unit Ready is the safe checker for SCSI devices; do not use a checker that sends I/O on active/passive arrays.
  • failback - immediate or a delay, for returning to the preferred path.
  • no_path_retry - how long to queue I/O when every path is down (e.g. queue or a number of retries).

Reload and Verify

systemctl enable --now multipathd
multipath -r                 # reload configuration / re-detect
multipath -ll                # list devices, paths and their states
multipathd show paths format "%d %P"    # per-path: device and protocol
multipathd show maps

In multipath -ll output each path shows active/ready or failed/ghost; ghost is normal for the passive side of an ALUA array. After wiring multipath, format and mount /dev/mapper/alias (or use the WWID symlink in fstab) - never the raw sd device - and verify failover by pulling one path and watching multipath -ll rebalance.

Related Reading

Multipath is the host side of the SAN story; the array and fabric sides are covered in our Brocade FC zoning guide (for FC fabrics), the HPE 3PAR CLI administration reference and the NetApp ONTAP SnapMirror setup for replication on top of the LUNs.

原文链接:https://pve.proxmox.com/wiki/Multipath