A Cloud Architect Company
bitbucket pipeline
Amazon Web Services

How to increase an EBS volume in Amazon EC2 instance

Introduction

Elastic Block Storage known as EBS is a storage type in AWS. It is a block level storage type, we cannot access any files inside the EBS volume from AWS console. EBS volumes can be attached with EC2 instances. We can access files from SSH connection with its attached EC2 Instance. We can increase or decrease the EBS volume size at any time. But whenever you want to resize the volume, make sure to take a copy of that volume. This is a best practice incase of any failure in the resizing process, you can recover your data anytime.

Now we are going to Increase the size of the EBS volume which is attached with an EC2 Instance.

Resize EBS Volume

  • First Select the EC2 instance which is attached with the EBS volume that we need to increase size.
  • Select the Storage section and you can find the attached volumes with the EC2 Instance. Click the volume.

increase-ebs-volume-with-ec2-select volume

It will navigate you to the volumes section. Then select the volume, then click Actions followed by Modify volume.

increase-ebs-volume-with-ec2-modify-volume

Enter the number of size you want to upgrade the volume. Here I entered 20GiB, then click Modify.

Increase Ebs Volume With Ec2 Modify Volume Size

It asks you for confirmation to modify the volume. Click Modify to continue.

Increase Ebs Volume With Ec2 Modify Volume Size Confirmation

Now the volume state is optimizing. It will take a couple of minutes.

Increase Ebs Volume With Ec2 Modifying state Volume Size

Wait until the Volume state is In-use. Now the volume is successfully upgraded to 20GiB.

Increase Ebs Volume With Ec2 Modified state Volume Size

Update the Resize EBS with EC2

  • Login to your EC2 Instance with sudo privileges.
  • Type the ‘lsblk’ command in the terminal window.
  • In the below picture you can see our volume has been extended to 20GiB. But the primary partition is still the old volume’s size.

Increase Ebs Volume With Ec2 List Volumes

To expand the partition use the following command like the screenshot below.

growpart /dev/xdva 1

Increase Ebs Volume With Ec2 change Volume

Now again run the ‘lsblk’ command to see the changes made.

Increase Ebs Volume With Ec2 List Volumes again

  • From the above screenshot our primary partition is successfully extended to new volume size.
  • Now we need to check the size of the file system.
  • So run the following command: ‘df -h’
  • You can notice that it is still with the old 8GiB size.

Increase Ebs Volume With Ec2 List Volumes With New One

  • Run the following command to see the type of the file system that we used.
 file -s /dev/xvd*
  • In Amazon Linux 2 EC2 instances’ file system is XFS like the picture below.

Increase Ebs Volume With Ec2 View File Type

For the XFS file system use the following command to extend the file system.

xfs_growfs -d /

Increase Ebs Volume With Ec2 Execute XFS CommandA

Now again run the ‘df -h’ command to see the change happens.

Increase Ebs Volume With Ec2 List Modified Volumes

As you can see the above picture shows our file system successfully upgraded to new volume size.

Now the EBS volume is fully resized from 8GiB to 20GiB and ready to used.

In this process there is no downtime on our server.

 

Article written by:

Jerin Rathnam is a proficient DevOps engineer who is dedicated to streamlining software development and deployment processes. He has extensive knowledge of cloud infrastructure, containerization, and CI/CD pipelines, which enables him to effectively connect development and operations. Jerin specializes in creating numerous Terraform modules for multi-cloud infrastructure and possesses immense expertise in configuring and managing cloud infrastructure. His profound understanding of containerization, along with his experience in orchestration tools like Docker and Kubernetes, further supports his skills as a valuable DevOps engineer.

Leave a Reply

Your email address will not be published. Required fields are marked *

back to top
advanced-floating-content-close-btn

Contact Us to save your AWS bill by 40%

X