How to Increase AWS EBS Volume Size Quickly and Safely
To increase an AWS
EBS volume size, modify the volume using the AWS Management Console or AWS CLI with the new desired size. After resizing, extend the file system on your instance to use the additional space.Syntax
Use the AWS CLI command modify-volume to increase the size of an EBS volume. The key parts are:
--volume-id: The ID of the volume to resize.--size: The new size in GiB (must be equal or larger than current size).
Example syntax:
bash
aws ec2 modify-volume --volume-id vol-1234567890abcdef0 --size 100
Example
This example shows how to increase an EBS volume from 50 GiB to 100 GiB using AWS CLI, then extend the file system on a Linux instance.
bash
# Step 1: Modify the volume size aws ec2 modify-volume --volume-id vol-0abcd1234efgh5678 --size 100 # Step 2: Check modification status aws ec2 describe-volumes-modifications --volume-ids vol-0abcd1234efgh5678 # Step 3: Connect to your EC2 instance and extend the file system sudo growpart /dev/xvdf 1 sudo resize2fs /dev/xvdf1
Output
ModifyVolume: volume modification started
DescribeVolumesModifications: modification state: optimizing
File system resized successfully
Common Pitfalls
- Trying to shrink the volume size is not supported; you can only increase it.
- Forgetting to extend the file system after resizing will leave the extra space unusable.
- Using the wrong device name when extending the partition or file system can cause errors.
- Not waiting for the volume modification to complete before resizing the file system can cause failures.
bash
# Wrong: resizing file system before volume modification completes sudo resize2fs /dev/xvdf1 # Right: wait for modification, then resize aws ec2 wait volume-modified --volume-ids vol-0abcd1234efgh5678 sudo resize2fs /dev/xvdf1
Quick Reference
| Step | Command / Action | Notes |
|---|---|---|
| 1 | Modify volume size | aws ec2 modify-volume --volume-id |
| 2 | Wait for modification | aws ec2 wait volume-modified --volume-ids |
| 3 | Extend partition | sudo growpart /dev/ |
| 4 | Resize file system | sudo resize2fs /dev/ |
Key Takeaways
You can only increase EBS volume size, not decrease it.
Use AWS CLI or Console to modify the volume size safely.
Always extend the file system after resizing the volume to use new space.
Wait for the volume modification to complete before resizing the file system.
Check your device names carefully when extending partitions and file systems.