In this case, 100G was added and we need to extend the root partition without any reboots. The root partition is using the block device /dev/vda2 and we’ve to extend it. For extending the partitions, we use fdisk command utility.

Start the fdisk utility like below:

# fdisk /dev/vda

Print the current partition layout by typing p and note down the start sector for /dev/vda2

We used the default value for First & Last Sector, Since the default First Sector was 1050624 and if its different, we must manually put 1050624 in place of First Sector. For the Last Sector we could use the default value and it’ll take the rest of the space.

When the partition layout is identical to that of the previous one, except for End sector and blocks, then we could write the changes to the partition table.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

The above step has re-written the partition layout. However, to make it active we need to reboot the server or instruct the kernel to re-read it. Rebooting the server is not recommended, so we use partx command line utility to instruct kernel about the partition layout change.

# partx -u /dev/vda2

Please note, in centos7 the above command works. But for other older servers, -u option won’t be present. So we could use -a flag, or use other utilities like partprobe, kpartx etc.
Now the partition has grown by a 100G

We used the default value for First & Last Sector, Since the default First Sector was 1050624 and if its different, we must manually put 1050624 in place of First Sector. For the Last Sector we could use the default value and it’ll take the rest of the space.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

The above step has re-written the partition layout. However, to make it active we need to reboot the server or instruct the kernel to re-read it. Rebooting the server is not recommended, so we use partx command line utility to instruct kernel about the partition layout change.

# partx -u /dev/vda2

Please note, in centos7 the above command works. But for other older servers, -u option won’t be present. So we could use -a flag, or use other utilities like partprobe, kpartx etc.
Now the partition has grown by a 100G
Run pvresize

pvresize /dev/vda2

Run lvextend

lvextend -l +100%FREE /dev/vg_cpanel/lv_root

Resize the file system

resize2fs /dev/vg_cpanel/lv_root

[If format type is xfs, then the above will fail. Use xfs_growfs]

resize2fs /dev/vg_cpanel/lv_root

Finally check whether fstab is using a valid UUID of the extended lvm or else ignore