What is growpart utility and how to use it ?
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
Issue
- How to extend a partition using the
growpart
utility online?
Resolution
Disclaimer: The following information has been provided by Red Hat, but is outside the scope of the posted Service Level Agreements and support procedures (Production Support - Red Hat Customer Portal). The information is provided as-is and any configuration settings or installed applications made from the information in this article could make the Operating System unsupported by Red Hat Global Support Services. The intent of this article is to provide information to accomplish the system's needs. Use of the information in this article at the user's own risk.
From a technical point of view, resizing filesystems and their underlying partitions (making changes to the existing partition table) can be very dangerous. Also, it is only possible to resize partitions from their end position on the disk. It is not possible to move partitions on the disk or resize them from their beginning. Such operations can result in a corrupted partition table, which will render all data on the disk device inaccessible, leading to data loss. While it is possible to perform online partition resize operation, it is not recommended simply from a data integrity standpoint and not because it's not possible.
- What is
growpart
utility?
growpart
is one of the utility to extend thelast partition
of the disk to fill the available free space on the disk. It changes thesector position
to the end sector of the disk.- It only extends the last partition. It doesn't create or delete any existing partition.
- It can be run
online
. Dry run test can also be done to check the same.
- Extend the partition:
root@rhelbox ~]# growpart -v /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). - From
cloud-utils-growpart-0.33*
on-wards, Underlying physical volume automatically gets resized once the partition is increased.
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
OR
# rpm -ivh cloud-utils-growpart/path/to/rpm
- Verify the
partition
table using the below command before runninggrowpart
:
[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.
Comments