How To Extend A Partition With Unallocated Space In RHEL/CentOS

Extend A Partition

In the world of Linux systems, storage management is a critical aspect of maintaining a healthy and functioning server. One common task that administrators often face is the need to extend a partition with unallocated space. This task can seem daunting, especially for those who are new to Linux. However, with the right tools and knowledge, extending a partition in Red Hat Enterprise Linux (RHEL) or CentOS is a straightforward process. In this blog post, we’ll guide you through the steps to successfully extend a partition using unallocated space in RHEL/CentOS, ensuring that your server continues to run smoothly.

You can resize a partition and volume group without rebooting the server. If done correctly this process is non destructive to existing data.


Assuming your disk is /dev/sda and standard RHEL/CentOS partitioning:

Extend partition

fdisk /dev/sda

Enter p to print your initial partition table.

Enter d (delete) followed by 2 to delete the exiting partition definition (partition 1 is usually /boot and partition 2 is usually the root partition).

Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept the start block and enter again to accept the end block which is defaulted to the end of the disk.

Enter t (type) then 2 then 8e to change the new partition type to Linux LVM.

Enter p to print your new partition table and make sure the start block matches what was in the initial partition table printed above.

Enter w to write the partition table to disk. You will see an error about device or resource busy which you can ignore.

Update kernel in-memory partition table

After changing your partition table, run the following command to update the kernel in-memory partition table:

partx -u /dev/sda

Resize physical volume

Use pvresize command to resize the pv to recognize the free space:

pvresize /dev/sda2

Resize logical volume and filesystem

In this command rhel is the VG, root is the LV and /dev/sda2 is the partition that was extended. Use pvs and lvs commands to see your physical and logical volume names if you don’t know them. The -r option in this command resizes the filesystem appropriately so you don’t have to call resize2fs or xfs_growfs separately.

lvextend -r rhel/root /dev/sda2

Leave a Reply

Your email address will not be published. Required fields are marked *