How to Increase the Size of an AWS EBS Volume Without Downtime
If you're familiar with Amazon EC2 and EBS volumes, you might have encountered situations where you need to increase the size of an EBS volume. Fortunately, AWS provides a simple way to expand your EBS volume without detaching it or restarting the instance—ensuring zero downtime.
Step 1: Create a Snapshot
Before making any modifications, it's best practice to create a snapshot of your volume as a backup in case something goes wrong.
- Navigate to the EBS Volumes section in the EC2 Dashboard.
- Right-click the volume you want to modify.
- Select Create Snapshot.
- Add a description, such as
snapshot-my-volume
. - (Optional) Add a Name tag with the value
snapshot-my-volume
. - Click Create Snapshot and wait for the process to complete.
At this point, you can take a short break while AWS processes the snapshot.
Step 2: Increase the Volume Size
Once the snapshot is complete, you can proceed with increasing the volume size.
Example Scenario
- Current volume size: 30GB
- New desired size: 40GB
Follow these steps:
- Right-click the volume you want to resize.
- Select Modify Volume.
- Enter the new size (e.g., 40GB).
- Click Modify to confirm.
- You’ll receive a prompt asking if you want to extend the OS file system. Click Yes.
At this point, your volume has been expanded, but your operating system still recognizes the old size.
Step 3: Extend the OS File System
To make use of the increased volume size, you need to extend the OS file system. Here’s how to do it on an Ubuntu instance:
- Connect to your EC2 instance via SSH.
- Check the current volume size using:
df -h
The output will still show the old size (30GB).
- List available disk partitions:
lsblk
You should see the expanded volume (40GB), but your current partition is still at 30GB.
- Extend the partition:
sudo growpart /dev/xvda 1
-
/dev/xvda
is the device name. -
1
is the partition number.- Resize the file system:
sudo resize2fs /dev/xvda1
- Verify the new size:
df -h
The output should now reflect the updated 40GB volume size.
Conclusion
AWS provides a seamless method to increase an EBS volume’s size without downtime. However, after modifying the volume, you must extend the OS file system to reflect the changes. Following these steps ensures your EC2 instance can fully utilize the increased storage capacity.
Top comments (0)