Increase the size of EBS volume in your EC2 instance

Yunan Helmy
3 min readApr 23, 2019

--

If you are familiar with Amazon EC2 and EBS volume, you might have experiences modifying the size of EBS volume. AWS provide an easy way to increase the size of your EBS volume. In fact, we could increase it without detaching the volume or restarting the instance. That’s quite a nice work done there because we would not need to have a downtime for our instance.

Let’s exercise. Assume we have volume name my-volume.

Create snapshot

It is best practice to create a snapshot of your volume in case something bad happens.

  1. Go to your EBS volume list from your EC2 Dashboard.
  2. Right click the volume.
  3. Click Create Snapshot link.
  4. Add the description value snapshot-my-volume.
  5. Add key : Name and value : snapshot-my-volume.
  6. Click button Create Snapshot.
  7. Go grab some snack while it is in progress.
[2, 3] Right click on the volume
[4, 5, 6] Create snapshot

Increase the volume

This is how we will increase the volume size. Make sure your snapshot is finished.

Let’s assume that previous volume size is 30GB and we want increase it to 40GB.

  1. Right click on the volume you wish to increase.
  2. Add your desired size; In our example type 40.
  3. Click Modify.
  4. You will get confirmation to extend OS file system.
  5. Click Yes.
[2, 3] Increase volume
[4, 5] Confirmation to extend OS file system

Extending OS file system

After you finish modifying volume, you need to extend OS file system in order to see your increased volume size. The example below is the command I used for Ubuntu OS.

  1. SSH into you instance.
  2. Type df -h to check volume size; You will still have 30GB of volume size.
  3. Type lsblk ; Your increased volume will be shown just above your current volume, e.g. xvda1 is your current volume with 30GB size and xvda with 40GB size.
  4. Extend the partition by typing sudo growpart /dev/xvda 1 ; Note that dev/xvda is the partition name and 1 is the partition number.
  5. Extend the volume by typing sudo resize2fs /dev/xvda1 .
  6. Type df -h to check volume size; It will show 40GB of volume size.
[2] The previous volume size before extending
[3] lsblk show we could extend the partition
[4] growpart show we have successfully extend the partition
[5] resize2fs show we have successfully extend the volume
[6] the new size after extending

Conclusion

AWS provide a straightforward method to increase the volume size of EBS. We need to extend the OS file system in order to see the changes.

Hope it works!

--

--