What is growpart utility and how to use it ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8

Issue

  • How to extend a partition using the growpart utility online?

Resolution

  • What is growpart utility?
  1. growpart is one of the utility to extend the last partition of the disk to fill the available free space on the disk. It changes the sector position to the end sector of the disk.
  2. It only extends the last partition. It doesn't create or delete any existing partition.
  3. It can be run online. Dry run test can also be done to check the same.
  • Extend the partition:
root@rhel7 ~]# growpart  /dev/sde 1
CHANGED: partition=1 start=2048 old: size=1675264 end=1677312 new: size=4192223 end=4194271

Here growpart's first argument is disk and second argument is partition number.

  • Verify the partition table:
[root@rhel7 test6]# parted /dev/sde u s p
Model: VMware Virtual disk (scsi)
Disk /dev/sde: 4194304s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End       Size      Type     File system  Flags
 1      2048s  4194270s  4192223s  primary

  • Once the partition has been extended, Resize the physical volume which is using it (Only if PV exists on top of it).

Diagnostic Steps

  • Verify growpart package is installed, If not then install:
[root@rhel7 ~]# rpm -qa| grep -i growpart

[root@rhel7 ~]# yum install cloud-utils-growpart -y
  • Verify the partition table using the below command before running growpart:
[root@rhel7 test6]# parted /dev/sde u s p
Model: VMware Virtual disk (scsi)
Disk /dev/sde: 4194304s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End      Size     Type     File system  Flags
 1      2048s  839679s  837632s  primary

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.