Managing storage growth is one of the most common operational tasks in cloud environments.
Everything works perfectly when an EC2 instance is first launched. The root volume has enough space, applications run smoothly, and monitoring dashboards look healthy.However, as applications evolve, log files accumulate, packages are installed, and data continues to grow. Eventually, storage utilization begins approaching critical levels. At that point, infrastructure teams face an important question:
How can we safely increase storage capacity without disrupting production workloads?
Fortunately, Amazon EBS allows volume expansion without stopping the instance. With the correct Linux commands, both the partition and filesystem can be expanded online with zero downtime. In this article, I'll walk through the process of expanding an EC2 root volume from 8 GiB to 12 GiB on Amazon Linux 2023 using an XFS filesystem.
Environment Overview
Component Value
Instance Name my-instance
AWS Region us-east-1
Operating System Amazon Linux 2023
Filesystem XFS
Original Volume Size 8 GiB
Expanded Volume Size 12 GiB
Downtime None
Understanding What Happens During EBS Expansion
One common misconception is that increasing an EBS volume in the AWS Console automatically makes the additional space available inside the operating system.
In reality, there are three separate layers involved:
Disk Layer
Partition Layer
Filesystem Layer
The filesystem continues using its old capacity until explicitly resized. Because of this separation, increasing an EBS volume alone is not enough.
The operating system must also be instructed to:
Extend the partition
Extend the filesystem
Only then can applications use the newly allocated storage.
Step 1: Connect to the Instance
Begin by connecting to the EC2 instance using SSH.
`ssh ec2-user@34.229.164.16 -i myec2-keypair.pem`
Once authenticated successfully, you'll gain shell access to the server.
Before making any storage-related changes, it's always good practice to verify the current disk layout.
Step 2: Inspect the Existing Storage Configuration
Run:
`sudo lsblk`
Example output:
xvda 12G
└─xvda1 8G
At first glance, this output reveals something important.
The underlying disk already shows:
12G
However, the root partition remains:
8G
This confirms that AWS has successfully expanded the EBS volume, but Linux has not yet expanded the partition.
At this stage:
EBS volume expansion is complete
Operating system partition expansion is pending
Step 3: Expand the Root Partition
To allow Linux to use the additional storage, expand the partition.
`sudo growpart /dev/xvda 1`
Let's break this down:
/dev/xvda = root disk
1 = partition number
The command instructs Linux to extend partition 1 to occupy all available free space on the disk. One major advantage of using growpart is that it performs the operation online.
No reboot is required.
No service interruption occurs.
Why Partition Expansion Matters
Without expanding the partition, the operating system continues treating the partition as 8 GiB even though the disk itself is larger. This means applications cannot use the additional storage.
Think of it as purchasing a larger warehouse but continuing to use only the original room inside it.
Step 4: Verify the Partition Growth
After running growpart, verify the results.
`sudo lsblk`
Expected output:
xvda 12G
└─xvda1 12G
Now both the disk and partition report the same size.The partition layer has been successfully expanded.However, the filesystem still needs attention.
Step 5: Check Filesystem Capacity
Next, inspect the filesystem.
`df -hT`
You may still observe something similar to:
Filesystem Type Size
/dev/xvda1 xfs 8G
This surprises many engineers during their first storage expansion.
Although the partition is now larger, the filesystem itself has not yet been instructed to grow.
Step 6: Expand the XFS Filesystem
Since Amazon Linux 2023 commonly uses XFS, the filesystem can be expanded online.
Run:
`sudo xfs_growfs -d /`
This command tells XFS to:
Detect available free space
Extend the filesystem
Make the additional capacity immediately usable
Because XFS supports online expansion, this process does not require:
Rebooting
Unmounting the filesystem
Stopping applications
This makes it highly suitable for production environments.
Step 7: Validate the Final Result
Perform one final verification.
`df -hT`
Expected result:
Filesystem Type Size
/dev/xvda1 xfs 12G
The root filesystem now reflects the expanded capacity. The additional storage is immediately available to applications running on the instance.
Common Mistakes During EBS Expansion
Many engineers stop after expanding the partition.The filesystem must also be resized before the new space becomes usable.
Operational Takeaways
This simple procedure highlights an important infrastructure concept:
Storage management involves multiple layers.
Understanding the relationship between:
EBS Volumes
Linux Partitions
Filesystems
is a valuable skill for cloud engineers, DevOps engineers, and system administrators. For production environments where uptime matters, this capability becomes an essential operational tool in every cloud engineer's toolkit.
References
AWS Documentation:
https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html
Top comments (0)