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 device partition_number
PARAMETERS
device
The device (e.g., /dev/sda) containing the partition to be resized.
partition_number
The partition number to be resized (e.g., 1 for /dev/sda1).
DESCRIPTION
The growpart command is a utility designed to inform the operating system's kernel about a partition that has been expanded in size. This is typically used after increasing the size of a virtual disk or a physical disk where the partition table has been extended to utilize the new space. It's essential because simply resizing the underlying disk image doesn't automatically make the extra space available to the partition. growpart reads the partition table and tells the kernel to update its knowledge of the partition's size. Without it, file systems residing on the partition won't be able to utilize the added space. This is crucial in dynamic environments like cloud computing, where disks are often resized on-the-fly. After running growpart, you will typically need to resize the filesystem to use the new available space. growpart relies on the Linux kernel's partition management capabilities and interacts with the kernel via ioctl calls. If the partition lies in an LVM volume group you may need to extend the PV first. Note that some kernel versions require a reboot to recognise the change.
CAVEATS
growpart only informs the kernel about the new partition size. You must still resize the filesystem on the partition (e.g., using resize2fs, xfs_growfs, etc.) to actually use the new space.
The partition number must be valid and exist on the specified device.
This command may not work on all partition table types, especially older or less common ones. Ensure compatibility with your system before use.
EXAMPLE USAGE
To resize partition 1 on /dev/xvda:growpart /dev/xvda 1
Then resize the filesystem:resize2fs /dev/xvda1
DEPENDENCIES
growpart typically requires the `parted` library or similar partition table handling tools to be installed on the system.
HISTORY
growpart emerged as a necessary tool in environments where dynamic disk resizing is common, particularly with virtual machines and cloud infrastructure. Its development addresses the gap between disk image resizing and the kernel's awareness of those changes. Initially, such tasks required manual manipulation of partition tables or reboots. growpart simplified this process by providing a dedicated command for notifying the kernel. It is now widely adopted across many Linux distributions and systems employing dynamic storage management.
SEE ALSO
resize2fs(8), xfs_growfs(8), parted(8)