How to Resize Existing LUN/Disk on Linux

In most cases, disk space can be expanded by adding a new LUN to the system.

But in some scenario, you may need to resize the existing LUN in order to extend the file system.

Extending the file system involves two parts, extending the corresponding logical volume and then growing FS over it.

Adding, resizing or deleting the LUN on a Linux system can be done without restarting.

In this article, we will show you how to extend the Logical Volume (LVM) by resizing the existing LUN on Linux.

Resizing LUN or Disk on Linux

Please follow the below procedure for resizing an existing LUN or Disk on Linux.

Step-1: Identify the device '/dev/sd[X]' to be resized.

Step-2: Verify the LUN ID mapped with the block device using the 'smartctl' command as shown below.

smartctl -a /dev/sd[X]

Step-3: Request the Storage team to increase the LUN size on the SAN as required. It should go through a Change Request (CR), but create a ticket based on the process that will be followed in your organization.

Step-4: After resizing the LUN at storage team end, run the following command to re-scan the block device on the server.

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

Step-5: Check for additional space using the 'lsblk' command. It should show the new size.

lsblk | grep sd[X]

Step-6: Resize the PV. Now the VG should reflect the additional space that added to the PV (sd[X]).

pvresize /dev/sd[X]

Physical volume "/dev/sd[X]" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

Make a Note: Please replace 'X' with your actual device name.

Step-7: Run the below command to extend the LVM.

lvextend -l +100%FREE /dev/mapper/vg01-lv002

Step-8: Finally resize the Filesystem.

For Ext4.

resize2fs /dev/mapper/vg01-lv002

For XFS.

xfs_growfs /dev/mapper/vg01-lv002

Step-9: 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 existing LUN/Disk in Linux with detailed steps.

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

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

Leave a Reply

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