You must be knowing how to extend filesystem by adding new disks to Linux/Unix server and then increasing the filesystem capacity, but this tutorial will teach you how to extend filesystem using the pvresize command. You just have to increase existing VMDK disk and you are good to grow your filesystem in Linux servers.
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 vmdk from vSphere 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.
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 of all, login to vSphere client and increase the size of the vmdk disk as per your requirements.
You can identify the corresponding VMDK disk by reading our tutorial.
2. Now rescan the disk from the server.
echo 1 > /sys/block/sdc/device/rescan
Here, sdc is the disk which corresponds to particular filesystem 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 | grep -i sdc
4. Now use “blockdev” command to re-read the partition table.
blockdev --rereadpt /dev/sdc
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.
7. Verify new expanded size of 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/sdc
9. Now it’s time to resize the LV and see the expanded filesystem.
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 virtual Linux server. If you have any issue in extending your filesystem using “pvresize” command, you can comment below.
Similarly, we can also extend filesystem of physical server using pvresize, there is only few commands difference and we are going to cover that tutorial in our future posts. Till then you can subscribe to us through email.
If you like the article do not forget to share it.