0%

How to modify the volume of EBS on AWS

When I created my EC2 instance, since the limitation of free version, I allocated only 8GB to the root volume. I soon realized that this volume was almost used up.

As the free instance, Amazon gave us 30GB size to be used. It’s better estimate the size according to your purpose before allocate.

Anyway, if you have the same problem, dont worry, let’s see how to expand it within 3 steps.

Modify the volume size on the EC2 dashboard

AWS DASHBOARD
  1. On the dashboard, select “ELASTIC BLOCK STORE - Volumes”.

    AWS EBS
  2. Right click the volume which you want to modify, select “Modify Volume”.

    Modify volume
  3. Enter the volume size you want to reset, pay attention if you’re using a free instance, the total size don’t over 30GB, otherwise you will receive the bill from Amazon.

Login your instance to modify partition

lsblk
  1. From ssh login to your instance, enter command “lsblk”, you will see the real size of all volumes and the partitions. You will see that the size of the volume has been modified, but the patition has not used all of the volume yet.

    growpart command
  2. Enter command “sudo growpart /dev/xvda 1”, to make partition “xvda1” use all of the volume available.

    lsblk
  3. Now you can see that the partition size is equal to the volume size.

Ajust the filesystem

filesystem not recognize the new space
  1. But the filesystem has not yet recognized this new space, therefor we have to tell him through the command “sudo resize2fs /dev/xvda1”. (if your filesystem shows as /dev/root, you should use “sudo resize2fs /dev/root”)

    expand done
  2. Congratulations, the volume has been expanded.

PS: Since I forgot to screenshot the picture when I was procesing, there is a few pictures from internet. If it violates your rights, please let me know and I will delete them.