AWS EC2 Debian: Guide to Increase EBS Volume Size

Here’s the scenario: You want to add storage space to a volume (drive) attached to an EC2 Debian instance.

Expand EC2 Linux Storage AWS Debian
Filed under: Guide For People That Aren’t Linux System Administrators That Don’t Want To Piece Together A StackOverflow Article And 3 Web Search Results To Expand EC2 Volume Storage.

There are three steps. First, increasing the volume size in the AWS Management Console. Second, the partition needs to be expanded in Linux, and finally, the Linux filesystem needs to register the updated available space.

TL;DR

Here are the three steps in brief:

  1. Navigate to the AWS console, locate the volume to resize, select Actions -> Modify volume, enter the new target size, and click Modify.
  2. On the Linux instance, type lsblk to identify the volume to expand and then type sudo growpart [device] [partition] to expand it. In my use case it is: sudo growpart /dev/nvme0n1 1
  3. Then, on the Linux instance, type sudo resize2fs [device] to expand the filesystem. In my use case, it is sudo resize2fs /dev/nvme0n1p1

That’s all there is to it. For a full walkthrough of the above steps, continue below.

Step 1 / 3 – Increase Volume Size in the AWS Management Console

Sign in to the AWS Management Console and navigate to EC2. You can go directly to the EBS volume, but I prefer to find the target instance first, and then click the link to the relevant volume in the Storage tab.

AWS Console EC2 Storage Screenshot
Right-click the volume (or select the volume and click the Actions drop-down) and select Modify volume.
AWS Console Modify Volume Context Menu Screenshot
In the Modify Volume screen, enter the new desired size and click Modify.
AWS EBS Modify Volume Modal Modify Screen Screenshot

You’ll likely see a confirmation modal, click Modify to proceed.

AWS EBS Modify Volume Modal Confirm Dialog Screenshot
AWS will automatically navigate to the Volumes screen. If you don’t see the updated volume size, click the refresh button (circular arrow) next to the Actions menu. You should see the new volume size (16 GiB in this case) like this:
AWS Console EBS After Resize Screenshot
Now it’s time to adjust the partition size and expand the volume on the Linux instance.

Step 2 / 3 – Expand the Partition

Connect to your Linux instance with a terminal, then type lsblk to list details about block devices (volumes). It may look like this. Note: our “15G” shows up as “14.9G” due to the small amount used by the boot partition (127M).

Linux lsblk Before Resize Screenshot

This shows that the primary partition (nvme0n1p1) has 14.9G in size, but the total available partition space is 16G.

To grow the partition, type sudo growpart /dev/nvme0n1 1. The error displayed when you execute this without sufficient permissions is a “not found” error, which isn’t easily associated with insufficient permissions. In the screenshot below I also ran this without sudo so you can see the error displayed when you try to execute this without sufficient permissions.

Linux growpart Screenshot

Execute lsblk again to see the expanded partition. Presto!

Linux lsblk After Resize Screenshot

Step 3 / 3 – Resize the Filesystem

Linux df -h Before Resize Screenshot

As you can see in the screenshot below, /dev/nvme0n1p1 still only registers 15G of total size. The command resize2fs [device] can now be executed to expand the filesystem to the total available partition space.

Linux resize2fs Screenshot

Once again, to highlight what happens if you omit sudo or do not have sufficient privileges, I ran the command without sudo first.

Finally, run df -h to view the system’s reported usable volume space.

Linux df -h After Resize Screenshot
That’s it!

Helpful Links

I found the following links/sites helpful when expanding storage.

N2WS – How to Resize EBS Volumes on AWS
https://n2ws.com/blog/how-to-guides/how-to-increase-the-size-of-an-aws-ebs-cloud-volume-attached-to-a-linux-machine
StackOverflow – How to increase AWS EBS NVME size
https://stackoverflow.com/questions/52508038/how-to-increase-aws-ebs-nvme-size

Leave a Reply

Your email address will not be published. Required fields are marked *