How to Resize an Online Multipath Device on Linux

Disk space on Linux can be expanded by adding a new LUN or resizing an existing LUN on the system.

In most cases, the online resizing of the multipath device involves two things: resizing the the logical unit (LUN) size and reflecting the size on the corresponding multipath device.

In this article, we will show you how to resize an online multipath device on Linux.

1) Identify the multipath device 'mpath22' to be resized using the ‘multipath -ll’ command.

multipath -ll | grep 'mpath22'

2) Request the storage team to increase the LUN size on the SAN as needed.

3) After changing the LUN size on the storage end, run the following command to re-scan the block device on the server. Replace 'X' with your device name instead.

echo 1 > /sys/block/sd[X]/device/rescan

If the multipath device is mapping to more than one path, make sure you scan all paths on disk. For example, if your multipath devices are sda, sdb, sdc and sde, you would execute the following commands.

echo 1 > /sys/block/sda/device/rescan
echo 1 > /sys/block/sdb/device/rescan
echo 1 > /sys/block/sdc/device/rescan
echo 1 > /sys/block/sdd/device/rescan

3a) If you have more than one path to a device, you can use the for loop to scan all at once instead of manually running the echo command multiple times against a device.

for device_name in sdb sdc sdd sde; do echo 1 > /sys/block/$device_name/device/rescan; done

4) After re-scan the LUN, check that the multipath device shows additional space using the lsblk command.

lsblk | grep -B1 mpath22

5) If yes, you should reflect the change on the corresponding multipath device of the logical unit as shown below.

Syntax:

multipathd -k'resize map [MPIO_MAP_NAME]'

You can resize the multipath device using multipathd command.

multipathd -k'resize map /dev/mapper/mpath22'
or
multipathd -k'resize map mpath22'

Make a Note:

  • There is no space between the -k and ‘resize in the multipathd command.
  • Please replace ‘MPIO_MAP_NAME’ with your actual mutlipath device name.
  • The ‘multipath_device’ variable is the corresponding multipath entry of your device in ‘/dev/mapper/XXXX’ based on the multipathing set up on your system.
  • It could be ‘/dev/mapper/mpath[X]’, where ‘X’ is the corresponding entry of your device if you configured user friendly name.
  • Otherwise, you can see ‘/dev/mapper/WWID’, where ‘WWID’ is the corresponding entry of your device. For example, 3600508b400105e210000900000490000.

6) Finally resize the Filesystem if LVM is not used.

Fox EXT4:

resize2fs /dev/mapper/mpath22

For XFS:

xfs_growfs /dev/mapper/vg01-lv002

Use the following steps if LVM is configured:

Scan LVM to check the disk changes detected under LVM.

pvscan

If it’s detected, now the VG should reflect the additional space that was added into the PV (mpath22).

pvresize /dev/mapper/mpath22
Physical volume "/dev/mapper/mpath22" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

Extend the LVM.

lvextend -l +100%FREE /dev/mapper/vg01-lv002
Finally resize the Filesystem.

For Ext4.

resize2fs /dev/mapper/vg01-lv002

For XFS.

xfs_growfs /dev/mapper/vg01-lv002

Finally, use the df command to view the file system size.

df -h /lvmtest1

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv002 15360M 34M 15326M 4% /lvmtest1

Conclusion

In this tutorial, we’ve shown you how to resize an online multipath device on Linux.

If you have any questions or feedback, feel free to comment below.

Leave a Reply

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