How to increase the size of your EBS (Elastic Block Store) volume— Amazon Web Services
Hi friends, hope everyone is doing well. It’s been a long time since I wrote an article in the Medium. So just wanted to share some of my knowledge on how to change the size of volume storage (EBS) for your EC2 instance.
I was asked to change the storage size of an EC2 instance. The size was 8 GB, the requirement is to change that to 20 GB.
Always remember to stop your EC2 instance before doing any configuration change to the attached volume. Of course, you could do the without any downtime but to be careful with your data storage I suggest you always follow the ethics.
Note: For the purpose of demonstration I have not stopped my instance while resizing the volume.
I’m using Ubuntu server 18.04 free tier. Just accept the default configurations and security groups if you want. Below screenshots are my basic configuration settings.
Whenever we connect to the instance, it will provide system information like below.
If you look at the system information, there you will find usage of system space with information on how much the server has utilised and how much the total storage is. Currently the server has used 13.6% of total storage space which is 7.69 GB (8 GB).
Well, let us increase the volume size to 20 GB now. Under the AWS management console, you will find volumes section. Check the attachment information of your selected volume. That should refer to your instance like below.
After selecting the volume, click on “Actions” and choose “Modify Volume” option.
Now increase size to 20 GB.
It will provide a confirmation dialog, choose “yes” and that’s it.
The process will take some time approximately 5 mins depending on the size. The progress will be shown like below screenshot.
After successful completion of optimisation, volume information will show like below screenshot.
Note: Sometimes, the above steps are sufficient to increase the size and it reflects automatically to your increased volume. The below command will show whether your instance is using increased size or not.
lsblk
If your xvda has your increased space then it means your instance has newly increased size. If that is not the case then you need to extend the file system.
To verify the file system, enter this command,
sudo file -s /dev/xvd*
The above command shows the boot volume with an ext4 file system.
If you want to extend your partition, then follow this command.
sudo growpart /dev/xvda 1
Now finally extend your file system by using this command.
sudo resize2fs /dev/xvda1
Now verify whether file system reflects the increased volume size or not by using this command.
df -h
So that’s it. I have referred official AWS website to get these steps. They have a full and detailed explanation on how to resize your volume. For more information please visit this link below.
Thanks a lot for your time. Please give me feedback and suggestions on my article, let me know is there anything I have missed. I’m always open for suggestions. Failures and mistakes are the stepping stones to success and perfection. Thank you once again.