Pirun Seng

Ruby on Rails Developer

Modify EBS Volume or Disk Space of Amazon EC2

Amazon has provided us cool and easy ways to modify EBS volume, or in other word is to modify disk space of our instance or server.

I am going to sum up of how we can achieve it by using AWS Console. However, the FIRST thing you need to know is that you CAN increase the volume, but CANNOT decrease.

Go on if you are about to increase your volume!

If we are running multiple instances and volumes, the first thing we need to know is which volume that is associated with which instance we want to modify.

If we open the Amazon EC2 console and navigate to Volumes page, we will see a list of some volumes if we are running multiple instances. For somebody who has already named their volumes, that is okay for them, but as my first experience, I haven’t named any of the volumes, so I don’t know which Volume of my instance I am looking for to modify.

Worry not! To know which instance our volume is attached to, just click on the volume, and in the Description tab below, we can see the instance in Attachment information. After find out the instance it is attached to, I recommend to name your volume at this point, if you haven’t, so it is helpful when we come back later and that we can catch it up immediately.

Okay so now we know which volume to be modified! BUT! Wait! It is recommended to create a Snapshot of your current volume before modifying.

I will just leave a link for How to create a Snapshot. It might take some time due to how big your volume is.

Once you already create a snapshot, then you’re ready for modifying the volume.

Let select a volume, and choose the dropdown Actions button on the top, and select Modify Volume. We will see a modal window of Modify Volume, verify the Volume Type, adjust the size in GiB you like, and click Modify button, and Yes.

Last, modifying volume size has no effect until we tell the file system to get advantage of new storage size. This is how you can Extending a Linux File System after Resizing the Volume. In my case, I just need to run the following two commands.

sudo growpart /dev/xvda 1
sudo resize2fs /dev/xvda1

Please… keep in mind that when we want to modify something like this, eg. Volume (disk space), Data, etc, we do have to do a back-up, like we were creating a Snapshot of the volume, so it safe in case we want to rollback or something. Plus, it is even more better if you can try it on a test instance and volume first before working on the live one.

Reference: Modifying an EBS Volume from the Console