DevOps
Resize EBS volume on AWS without an instance reboot
As your infrastructure grows and more resources are required of your EC2 instance, sometimes it becomes necessary to extend the volume of your cloud instance to accommodate more data. In this brief tutorial, we highlight how you can resize EBS volume on AWS without an instance reboot.
Prerequisites
Before you get started, ensure that you have the following in check.
- An running instance of Amazon EC2 cloud instance.
- SSH access to your instance
Step 1: Verify your current volume size
In my setup, I have already provisioned an EC2 instance with 20G of hard disk space. To verify this, I run the command:
1 |
$ lsblk | grep xvda |
I am going to expand this to another 20G so that I can end up with a total of 40G of hard drive space.
Step 2: Add the EBS volume to EC2
Next, access the ‘volumes‘ section right below the ‘Elastic Block Store‘ section located on the left sidebar as shown by the arrow.
This opens up the section shown below.
To add another volume, click on the ‘Actions‘ buttons and select ‘Modify Volume’
Provide the size of the volume that you want to add to the existing EC2 instance and click on the ‘Modify‘ button
When prompted whether you want to modify the volume, click on the ‘Yes‘ button.
It will take just a few moments for the changes to be effected, and thereafter, you will get a confirmation that the modification of the volume has succeeded. Click on the ‘Close’ button to exit.
Step 3: Resize EBS volume
Now let’s get back to the command-line interface and try listing the block devices once more. This time you will realize that the volume has grown to 40G up from 20G
1 |
$ lsblk | grep xvda |
From the output, you can clearly see that the xvda1 partition is still 20G. We need to resize this to 40G using the growpart command as shown
1 |
$ sudo growpart /dev/xvda 1 |
Next, run the command below to resize the partition all the way.
1 |
$ sudo resize2fs /dev/xvda1 |
Now when you list the block volume again, you’ll notice that the partition is now resized as expected.
And this concludes our topic today. We hope that you can now comfortably add and extend the size of your EC2 block volume.
-
DevOps55 years ago
Saltstack Tutorial for beginners [2023]
-
DevOps55 years ago
How to build a Docker cron job Container easily [2023]
-
Linux55 years ago
mail Command in Linux/Unix with 10+ Examples [2023]
-
DevOps55 years ago
Docker ADD vs COPY vs VOLUME – [2023]
-
DevOps55 years ago
How to setup Pritunl VPN on AWS to Access Servers
-
Linux55 years ago
Grep Command In Unix/Linux with 25+ Examples [2023]
-
Linux55 years ago
How To setup Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04
-
Linux55 years ago
Find command in Unix/Linux with 30+ Examples [2023]