multipath Command in Linux



multipath is a command-line utility used to manage storage SAN (Storage Area Network) disks on the Linux systems. It provides a way to organize I/O paths logically by creating a single multipath device on top of underlying devices. This ensures that even if one path fails, the system can still access the storage through another path, providing redundancy and failover capabilities.

Table of Contents

Here is a comprehensive guide to the options available with the multipath command −

Installing multipath Command

To get started with multipath, you need to install the multipath-tools package on your Linux system. The installation process varies depending on your Linux distribution.

On Debian-based Systems (e.g., Ubuntu)

sudo apt install multipath-tools

On Red Hat-based Systems (e.g., Fedora)

sudo dnf install device-mapper-multipath

On SUSE-based Systems (e.g., openSUSE)

sudo zypper install multipath-tools

Syntax of multipath Command

The basic syntax for the multipath command enables you to manage and configure multipath devices on your system. Here's the general format −

multipath [options] [arguments]

Where −

  • [options] are optional flags that modify the behavior of the command.
  • [arguments] are additional parameters required by the options, such as device paths or WWIDs.

multipath Command Options

The multipath command supports various options that you can use to customize its behavior. Here are some of the key options −

Option Description
-v Set verbosity level.
-d Dry run: Do not actually create or update multipath devices.
-r Force reconfiguration of multipath devices.
-l Show multipath topology (same as multipath -t).
-ll Show detailed multipath topology.
-f Flush a multipath device (remove it).
-F Flush all multipath devices.
-q Check if a device is multipathed.
-a Add a path device to a multipath device.
-w Remove a path device from a multipath device.
-W Remove all path devices from all multipath devices.
-c Check consistency of multipath configuration.
-h Display help information and exit.

Examples of multipath Command in Linux

Here are some practical use cases to show you how to use multipath on your system −

  • Listing Multipath Devices
  • Starting the multipathd Service
  • Checking Multipath Configuration
  • Removing a Multipath Device

Listing Multipath Devices

To list all the connected and scanned multipath devices on your Linux system, use the following command −

sudo multipath -l

This command will scan your system for all devices that have multiple I/O paths and list them. The output will include details such as the World Wide Identifier (WWID) for each device, the individual paths to the device, and their status (active or failed). This is useful for quickly verifying which devices are currently managed by multipath.

Starting the multipathd Service

The multipathd service is a daemon that manages multipath devices. It needs to be running for multipath to function correctly. To start this service, you use the systemctl command.

sudo systemctl start multipathd

This command starts the multipathd service on your system. Starting this service is essential because it continuously monitors the multipath devices, handles path failover, and performs necessary updates to the device mappings. If this service is not running, multipath may not be able to manage the devices properly.

Checking Multipath Configuration

To check the existing multipath configuration in detail, use the following command −

sudo multipath -ll

This command will display detailed information about all the multipath devices on your system. The output includes the WWIDs, the paths to each device, their statuses, priority groups, and any failover settings. This detailed view is particularly useful for troubleshooting and ensuring that all paths are configured correctly.

Removing a Multipath Device

If you need to remove a specific multipath device, you can use the multipath -f command followed by the WWID of the device.

sudo multipath -f <WWID>

Replace <WWID> with the actual World Wide Identifier of the multipath device you want to remove. This command tells multipath to flush the specified device, removing it from the system's multipath configuration. This can be necessary if a device is no longer in use, has been replaced, or you need to reconfigure it from scratch.

Note − To list the WWIDs of all disks connected to your system, use the following command −

lsscsi -i -s

Conclusion

The multipath command is an essential tool for managing SAN disks on Linux systems. By organizing multiple I/O paths into a single logical device and providing failover support, it ensures continuous access to storage and enhances system reliability.

Whether you're setting up a new storage system or managing an existing one, multipath provides the capabilities you need to maintain optimal performance and redundancy.

Advertisements