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.
Step-1: Finding multipath device
Identify the multipath device
'mpath22' to be resized using the ‘multipath -ll’ command.
multipath -ll | grep 'mpath22'
Step-2: Increasing LUN at Storage end
Request the storage team to increase the LUN size on the SAN as needed.
Step-3: Rescan the disk
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/sdb/device/rescan echo 1 > /sys/block/sdc/device/rescan echo 1 > /sys/block/sdd/device/rescan echo 1 > /sys/block/sde/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
Step-4: Checking new LUN size
After re-scan the LUN, check if the multipath device shows additional space using the lsblk command.
Let’s assume that our original LUN size is
'500GB' and we have extended the LUN by an additional
'300GB' on the storage end. After the scan, you should see
'800GB' on all four block devices (paths) as shown below. If any block devices still show the old size, you may need to rescan it.
If it’s a big size LUN, it may take a while to reflect the new size, so you may need to wait for some time and the new size discovery is completed or in-progress can be identified using ‘dmesg’ command.
lsblk | grep -B1 mpath22 sdb - 800G sdc - 800G sdd - 800G sde - 800G
Step-5: Resizing multipath device
If yes, you should reflect the change on the corresponding multipath device of the logical unit as shown below.
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 'resizein 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.
Step-6: Resizing file system
Finally resize the Filesystem if LVM is not used.
resize2fs /dev/mapper/mpath22 [For Ext4] xfs_growfs /dev/mapper/vg01-lv002 [For XFS]
Use the following steps if LVM is configured:
Scan LVM to check the disk changes detected under LVM.
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.
resize2fs /dev/mapper/vg01-lv002 [For Ext4] xfs_growfs /dev/mapper/vg01-lv002 [For XFS]
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
In this tutorial, we’ve shown you how to resize an online multipath device in Linux with detailed steps, including normal partition and LVM volumes. For LVM disks, you may need follow some additional steps.
If you have any questions or feedback, feel free to comment below.