growpart
Increase partition size after disk resize
TLDR
Extend partition n from sdX to fill empty space until end of disk or beginning of next partition
Show what modifications would be made when growing partition n in a disk image
SYNOPSIS
growpart [options] partition_number device
PARAMETERS
-h, --help
show this help message and exit
-n, --dry-run
simulate actions without changes
-N
verbose dry-run mode
-v, --verbose
enable verbose output
--version
display program version and exit
DESCRIPTION
growpart is a command-line utility from the cloud-utils-growpart package used to non-destructively extend a Linux partition to utilize all available space on its disk device. It is especially valuable in cloud and virtual machine environments, such as AWS EC2 or Google Compute Engine, where the virtual disk is resized online, but the partition table remains unchanged.
The tool targets a specific partition number on a block device (e.g., /dev/sda 1) and, if it is the final partition on the disk, relocates and resizes it to the disk's end. It employs a safe resizing algorithm that backs up the partition table beforehand and verifies changes, minimizing data loss risk. However, it only adjusts the partition boundaries, not the filesystem; subsequent steps like resize2fs or xfs_growfs are required to expand the filesystem.
Common workflow: After disk resize (e.g., via cloud console), run growpart, then resize the filesystem, and notify the kernel with partprobe or reboot. Supports MBR and GPT labels.
CAVEATS
Only resizes the last partition on the disk; fails otherwise. Modifies partition table in-place—backup first. Does not resize filesystems; run resize2fs(8) after. Risk of data loss if device is active or misidentified.
EXAMPLE
growpart /dev/sda 1
Extends partition 1 on /dev/sda.
Then: resize2fs /dev/sda1
partprobe to update kernel.
DRY-RUN
growpart -n /dev/sda 1
Preview changes safely before committing.
HISTORY
Introduced in cloud-utils package (~2010) for cloud-init to automate disk growth in AWS, OpenStack, etc. Maintained by cloud providers; current versions handle GPT/MBR, with fixes for large disks.


