Extend CentOS partition - Already have 4 Primary Partitions

Solution 1:

You could do it like described here: https://nacko.net/resizing-a-raw-virtual-machine-lvm-partition-using-fdisk/

Restating the main points: you can unmount the partition, delete it using a partitioning tool, then recreate it with identical data, except the end of partiton, which can be greater. You can only do this to the last partition on the disk.

Be aware that this requires extra caution, please have backups before doing this.

After that you should make sure that the changes are picked up.

Once that is done, you can pvresize, lvextend and finally resize2fs.

Solution 2:

There is another method that would do the job. I happened to encounter such an issue with one of our customers and this method worked. It is a comparatively low risk as you are not removing any partition. But a proper back is in any case very important.

Instead of increasing the space for the existing hard disk in VMWare, just add another VMDK. This will appear in fdisk as /dev/sdb or any subsequent hard disk to the existing one. The number of primary partition restrictions is only applicable to that particular hard disk. You can add as many hard disks as you want and have individual partition tables.

Create a new partition in the new hard disk and then you can do pvcreate, vgextend, and then resize2fs.

This method worked for me getting rid of the risk of converting an existing Primary partition to an Extended partition and possible chances of data loss.