Effortlessly Expand Your EC2 Storage: Increasing EBS Volume Size
Amazon Elastic Block Store (EBS) volumes, give you a way to store data for your Amazon EC2 instances that lasts even if the cases themselves are turned off. As your applications grow and you need more space, you don’t need to worry. Amazon Web Services has made it easy to increase the size of your EBS volume without any downtime or losing your data. In this guide, we will take you through the steps to seamlessly expand your EC2 storage.
There are a few reasons why you might want to increase the size of your EBS Volume
Growing Data Requirements: As your application starts to store more and more data, the initial storage capacity might not be enough anymore.
Performance Boost: Increasing the volume size can improve the performance of certain workloads, especially when it comes to input/output operations.
Cost Efficiency: Sometimes, it’s more cost-effective to expand an existing volume rather than adding more volumes and dealing with the hassle of managing them separately.
Increasing disk size may seem complex. Do we need downtime? Should we stop the server? Do we need to detach the volume? These questions may cross your mind.
However, the reality is that we can increase disk size without detaching the volume or restarting the server. Moreover, this process doesn’t require any downtime.
We will follow the following outlined steps to achieve our objective. Ensure you have an active running EC2 instance in your AWS account or you can spin up one to follow along with this demo.
Step 1: Check the current disk status
Log into the EC2 console, select your running instance then move to the storage tab, you will be able to see your volume characterized by volume ID, device name, volume size, and the attachment status.
Here I have my application server instance running with 8GB of EBS volume attached.
Check the disk status by using the below command.
df -hT
The current disk size is 8GB and 20% is used. Now, let’s proceed with the next step.
Step 2: Create Snapshot
Creating a snapshot is essential to keep a backup of our existing volume in case anything unusual happens during this activity.
Click on the EBS volume ID attached to your EC2 instance, then select your EBS volume and click on actions > Create snapshot.
In the Create Snapshot UI, give a relevant description and tag to your snapshot then click Create Snapshot.
Go to snapshots and wait till your snapshot status shows Completed.
Step 3: Increase the EBS volume
Make sure your snapshot is created successfully before proceeding with this step.
Go to the volumes section, select the volume attached to the EC2, and click on modify volume.
In the create volume UI, select volume type, and choose size as your desired business need, then click modify Increase the volume size as per your requirement and click on modify. Here I have changed the volume size from 8 to 15 GB.
You can now see that the disk volume attached to the server is updated to 15GB.
Step 4: Resize the File System
Now we need to extend our OS file system to see our increased volume.
SSH into the EC2 instance
Run the below command to check the volume size.
df -hT
We can see that the disk size is still 8GB.
Run the below command to see information about the block devices attached to our EC2 instance.
lsblk
Here xvda1 is our current volume that is attached and xvda is the increased volume.
Extend the partition xvda by 1
sudo growpart /dev/xvda 1
Extend the volume
sudo xfs_growfs -d /dev/xvda1
Check the volume size
df -hT
We can see that our volume size has now increased to 15GB
Conclusion
AWS provides a straightforward method to increase the volume size of EBS. We need to extend the OS file system to see the changes. increasing the size of your EBS volume is pretty simple and can be a game-changer for your growing apps.
This brings us to the end of this blog. Clean up.
If you have any questions concerning this article or have an AWS project that requires our assistance, please reach out to us by leaving a comment below or email us at [email protected].
Thank you!
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.