Recently we posted “how to extend filesystem using pvresize command in the virtual server“, and today we will tell you how you can extend the filesystem of a physical server using pvresize command.
The process will remain the same as of virtual server and only will differ in a few commands.
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) with the help of lvextend command 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.
I want to add that sometimes it is necessary to reboot the server before using pvresize for the change to take effect
No reboot is required. But if you have downtime you can do it for the sanity check.
hi all,
I’m trying to resize sdb1 to 1000gb but I’m running into some issues with this.
fdisk output:
Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes, 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe6ea346b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048575999 524286976 8e Linux LVM
but
Disk /dev/mapper/rhel2-lv_apps: 536.9 GB, 536866717696 bytes, 1048567808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
and
#
pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a– <19.00g 0
/dev/sdb1 rhel2 lvm2 a– <500.00g 0
/dev/sdc1 rhel3 lvm2 a– <1024.00g 0
Hence,
# lvextend -L +500G -r /dev/rhel2/lv_apps
Insufficient free space: 128000 extents needed, but only 0 available
Could you please help?
As per your pvs output, sdb1 is showing 0% FREE, so there is no space. Deleting the partition sdb1 and recreating for more space is risky, so if you have space in /dev/sdb, create a new partition and then extend vg “rhel2”. Once you verify the space the try to extend the lv.
Also, use “lvextend -l +100%PVS LV_Name /dev/mapper/sdbX”
If you want to delete the partition follow this Red Hat guide: https://access.redhat.com/articles/1190213
Hi Does doing pvresize is harm in production environment , as we have 4 TB of data on one of the patriation and need to increase pv as from storage side the existing lun was got increased.
Could you please help us with the defects on it or straight i way i can increase it.