Increase or Decrease the size of an EBS volume in AWS.
Tags: aws, cloud, devops
Published: 2022-01-20 16:59:02

Suppose you have created an EC2 instance and attached an EBS volume to it.

Lets first check how can we increase the storage capacity of the EBS volume.

To do so go to the volume section, select the volume whose storage capacity you want to increase then click on action and then click on modify volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1mmmw6x4sshioek1hp3k.png)

Now you can increase the storage size to your desired size.
(My present size is 15Gb I am going to convert it to 20 Gb)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8cxw2til1lgerc9b7x0v.png)

PLEASE NOTE THAT YOU CAN ONLY INCREASE THE SIZE HERE,YOU CAN NOT DECREASE THE STORAGE SIZE FROM HERE.

Now after changing the size click on modify and then again click on modify.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8aa5eevmdbc79fqdluya.png)

Now wait until the volume to optimize 100%, you can check it by going to the volume section


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8e4zioce0bt5wgrfrc6.png)

Once its optimized 100% you can go to Xshell and type **lsblk**. You can see that the storage size have increased to your desired size.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr25vgfy083c9zyv6rac.png)

But if you type **df -h** then you will see that the size of the external storage is still 15gb.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fuiqne5k92ie66pf0vpp.png)

This is because we have not resized the size of volume in the instance end. So, we can resize by typing a command in the Xshell.
Just write **resize2fs /dev/xvdf** and then if you type **df -h** then you will find that the size of your volume is increased.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dq1v5h43ecic7r9z98rf.png)

This is how you can increase the size of your EBS volume.

**Procedure to decrease the size**

The process to decrease the size of the EBS volume is totally different form that of increasing the size. But this is also quite easy.

Suppose your current volume size is 20Gb and you want to convert it to 10Gb then you just need to go to the volume section and create a EBS volume of 10Gb at the same Availability Zone as of your EC2 instance.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04w7b1oeud39jg8j231b.png)

Now give it a name tag(its optional) then click on create volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0hgj8bhh1qkcyl19vkn.png)

Then select the newly created volume and click on action and then press on attach volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6sryddi0c70knsbdkv0.png)

Then select the instance and then press attach volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26naetb5fodh0sfpl4lf.png)

Now do the same old process of formatting and mounting the new volume in the instance.

Now we just need to sync all the data from the previous external storage to the new reduced external storage. The command to do so is  **rsync -aHAXxSP /ext_vol /red_ext_vol/**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5d9o7xy156ttqs7xped.png)

Now all the data from the previous External storage is transferred to the new external storage, so now we need to unmount the previous external storage. The command to do so is** umount /dev/xvdf**.After doing that go the volume section and select external volume and click on detach volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqc5qwve6nv9ixk6r9cj.png)

Now once its status become available just select the volume again click on action and click on delete volume.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jt7idbv939m69ddrliz.png)

This is the whole process by which we can reduce the size of an EBS volume.