growpart Fails After EBS Volume Expansion on Amazon Linux 2
growpart Fails After EBS Volume Expansion on Amazon Linux 2
After expanding an EBS volume in the console, you still need to extend the partition and filesystem from within the operating system. If the root partition is already 100% full, growpart may fail because it cannot write temporary files, and the error may look like an sfdisk issue.
Symptoms
Executing partition expansion:
sudo growpart /dev/nvme0n1 1Returns an error like:
failed [sfd_list:1] sfdisk --list --unit=S /dev/nvme0n1
FAILED: failed: sfdisk --list /dev/nvme0n1The environment is typically:
- Nitro architecture instance.
- Amazon Linux 2.
- Root filesystem is XFS.
- Device name is
/dev/nvme0n1, root partition is/dev/nvme0n1p1. /is at or near 100%.
Root Cause
growpart needs to create temporary files in system directories and rewrite the partition table when executing. If the root filesystem is so full that only a few tens of KB remain, the underlying sfdisk call may not complete successfully, resulting in partition expansion failure.
In this case, the first priority is not to keep running growpart repeatedly, but to first free up some space on the root partition.
Resolution Steps
1. Clean the yum Cache
On Amazon Linux 2, you can start by cleaning the yum cache:
sudo yum clean allConfirm the root partition has at least a few MB of free space:
df -h /2. Expand the Partition
sudo growpart /dev/nvme0n1 13. Expand the XFS Filesystem
XFS requires using the mount point for expansion:
sudo xfs_growfs -d /For ext4, you should use:
sudo resize2fs /dev/nvme0n1p14. Verify
df -hT /
lsblkConfirm the root partition size and available space have been updated.
Notes
- After modifying the volume size in the EBS console, wait for the status to complete before proceeding with in-system expansion.
- Individual EBS volumes have modification frequency limits — do not repeatedly attempt expansion.
- When the root partition is nearly full, it is recommended to prioritize cleaning caches, old logs, and temporary files.
- For the long term, it is recommended to use CloudWatch Agent to collect disk usage metrics and set up advance alerts.
Summary
growpart reporting an sfdisk failure does not necessarily mean the partition table is corrupted — it may simply be that the root filesystem has no space for the tool to operate. For root volume expansion on Amazon Linux 2 + XFS, follow this order:
- Free up a small amount of space.
- Expand the partition with
growpart. - Expand the filesystem with
xfs_growfs. - Verify with
df -hT.
