Skip to Content

Resize Multipath disk on Linux

A multipath disk, also known as a “multipath device,” is a logical representation of a storage device in a storage area network (SAN) environment that utilizes multiple physical paths.

In a multipath configuration, a storage device, such as a disk array or a storage area network (SAN) volume, can be accessed through multiple physical paths. These paths can be established using different communication protocols like Fibre Channel, iSCSI, or other storage interconnects.

Each physical path consists of network adapters, cables, switches, and other components that establish the connection between the server and the storage device.

Multipath device example

Let’s see one example.

In this example, there are two multipath devices: mpatha and mpathb. Each device is associated with multiple paths (sda, sdb for mpatha, and sdc, sdd for mpathb). The output provides information about the size, features, hwhandler, and status of each multipath device and its paths.

mpatha (3600508b4000152f00000000000006e08) dm-0 HP,LOGICAL VOLUME
size=100G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 3:0:0:0 sda 8:0 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
`- 4:0:0:0 sdb 8:16 active ready running

mpathb (3600508b4000152f00000000000006e09) dm-1 HP,LOGICAL VOLUME
size=50G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 3:0:1:0 sdc 8:32 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
`- 4:0:1:0 sdd 8:48 active ready running


Multipath devices internal processing

The purpose of a multipath device is to provide fault tolerance and increased availability. If one path becomes unavailable or experiences problems, the multipath driver redirects I/O operations to an alternative path, ensuring uninterrupted access to the storage device.

From the perspective of the operating system, a multipath device appears as a single logical device with its own device file (such as /dev/mapper/mpathX in Linux systems). This logical device aggregates the I/O operations across the available physical paths, providing improved throughput and load balancing.

The multipath driver handles the management of paths, monitors their health, and ensures that data is sent and received through the most optimal path.

Multipath devices are commonly used in enterprise storage environments to enhance reliability, performance, and scalability. They are especially beneficial in mission-critical systems where downtime or data loss is not acceptable. The configuration and management of multipath devices are typically handled by specialized software or utilities provided by the operating system or storage vendors.

Here are the details on how to resize a multipath device, including the rescan of SCSI devices and resizing the file system. Here’s a breakdown of each step:

Resize your physical device

Before resizing a multipath device, you need to ensure that the underlying physical storage devices or partitions have been resized or expanded.

This typically involves using storage-specific tools to extend the size of the underlying devices.

Find the paths to the LUN

To identify the paths associated with the LUN (Logical Unit Number), you can use the `multipath -l` command. This command will provide information about the multipath devices and their associated paths.

Here’s an example output of the multipath -l command with a multipath device having four paths:

mpathd (3600508b4000152f00000000000006e0d) dm-2 HP,LOGICAL VOLUME
size=200G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| |- 3:0:2:0 sde 8:64 active ready running
| `- 4:0:2:0 sdf 8:80 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
|- 5:0:2:0 sdg 8:96 active ready running
`- 6:0:2:0 sdh 8:112 active ready running

Resize the paths

For SCSI devices, you can initiate a rescan of each path to detect the updated size of the underlying storage. This can be done by writing a value of 1 to the `rescan` file for each path device.

For example, you would run the following commands for each path device:

# echo 1 > /sys/block/sde/device/rescan
# echo 1 > /sys/block/sdf/device/rescan
# echo 1 > /sys/block/sdg/device/rescan
# echo 1 > /sys/block/sdh/device/rescan

Resize the multipath device

After resizing the underlying paths, you can resize the multipath device itself using the `multipathd resize` command.

This command instructs the multipath daemon to update the size of the multipath device based on the resized paths. Replace `multipath_device` with the appropriate name of your multipath device.

For example:

# multipathd resize map multipath_device

For example:

multipathd  resize map mpath22


multipathd resize map /dev/mapper/mpath22

Resize the file system

If you have a file system (such as ext4) on top of the multipath device, you need to resize the file system to utilize the additional space. The specific command for resizing the file system depends on the file system type.

The command `resize2fs` is used for resizing ext4 file systems. You would execute this command, replacing `/dev/mapper/mpatha` with the path of your multipath device, to resize the file system. For example:

# resize2fs /dev/mapper/mpathd

These steps should guide you through the process of resizing a multipath device, including the rescan of SCSI devices and resizing the file system. It’s important to exercise caution and have proper backups in place before making any changes to your storage configuration.

If you are using xfs file system, you can use xfs_growfs command to extend it.

xfs_growfs /directory