Connect with us

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.

  1. An running instance of Amazon EC2 cloud instance.
  2. 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:

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’

Resize EBS volume on EC2 instance

Provide the size of the volume that you want to add to the existing EC2 instance and click on the ‘Modify‘ button

Resize EBS volume on EC2 instance

When prompted whether you want to modify the volume, click on the ‘Yes‘ button.

Resize EBS volume on EC2 instance

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

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

Next, run the command below to resize the partition all the way.

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.

Continue Reading
Advertisement

Trending