Extend Filesystem using pvresize in the Physical Linux Server

Recently we posted “how to extend filesystem using pvresize command in the virtual server“, and today we will tell you how you can extend filesystem of a physical server using pvresize command. The process will remain same as of virtual server and only will differ in few commands.

 

Extend Filesystem using pvresize in the Physical Linux Server

 

There are generally 3 methods to increase or extend the size of the existing filesystem on your Linux machine as below.

i) By adding new disks to your system and then extending the filesystem with that disk.

ii) By adding new disk of the size equal to the existing filesystem plus the size by which you want to extend the filesystem and then using the pvmove command.

iii) By extending the size of the LUN from storage side and then using the pvresize command to increase the size of the PV and then the existing filesystem.

In this tutorial we are going to teach you method number 3 and you will learn how to extend the filesystem using pvresize command in a physical Linux server.

 

Note: The disk should be not partitioned like sdc1, sdc2, etc. If disk is already having the partition’s better to use method 1 or 2.

 

Steps to Extend the Filesystem using the “pvresize command”

 

1. First, please contact your storage team and see if the LUN’s can be extended or not, because storage team cannot extend all type of LUN’s from different storage devices.

 

2. Once storage team has extended the LUN, just rescan all the disks. Yes, you will have to rescan all the disk.

Suppose, you want to extend multipath device mpath1 and it has 2 multi-paths sdc and sdd, so you want to scan both the disks first.

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

 

Here, sdc and sdd are the disk which corresponds to particular multipath device and is used just for example. Device mapping can be seen by “lvs” command.

 

3. Once the disk has been re-scanned, you can confirm the increase size by using below command.

fdisk -l | egrep -i "sdc|sdd"

 

4. Now use “multipathd ” command to resize your multipath.

multipathd -k"resize map mpath

 

5. Now, just rescan the physical volume by using pvscan command. At this point, you won’t be seeing the increased size on “pvs” output.

 

6. Now it’s time to resize your physical volume (PV). Use “pvresize” command to resize the physical volume.

pvresize /dev/mapper/mpath1

 

7. Verify new expanded size of the PV by pvs command. Now it will show you new size and space left.

 

8. As your physical volume now has space, you can extend your logical volumes (LV) as below.

lvextend -l +100%PVS LV_Name /dev/mapper/mpath1

 

9. Now it’s time to resize the LV and see the expanded filesystem.

resize2fs LV_Name

 

10. Now you can verify the increase size by using “df” like below.

df -h filesystem-name

 

Hope, you are able to extend your filesystem in the physical Linux server. If you have any issue in extending your filesystem using “pvresize” command, you can comment below.

In our next tutorial, we will cover how you can extend FS using pvmove command, so to get update directly to your email subscribe to our blog.

If you like the article do not forget to Like, comment and share it.

Add Comment