A guide to increasing your AWS EC2 instance storage with no downtime.

Check current usage

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       194G  167G   27G  87% /
...

Check current partition

lsblk

NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
xvda     202:0    0   200G  0 disk 
├─xvda1  202:1    0 199.9G  0 part /
...

Log into https://aws.amazon.com/ dashboard console, locate your EBS volume associated to the EC2 instance. Under Actions → Modify volume. Input your desired new volume under Size (GiB), click Modify.

Screen Shot 2022-06-29 at 1.07.23 PM.png

Back to the terminal, check system partitions again, the disk should reflect the new storage size.

lsblk

NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
xvda     202:0    0   300G  0 disk 
├─xvda1  202:1    0 199.9G  0 part /
...

Allocate the disk space to partition

# We'll allocate to the 1st partition, which is xvda1 shown above
sudo growpart /dev/xvda 1

CHANGED: partition=1 start=227328 old: size=419203039 end=419430367 new: size=628918239 end=629145567

Then expand the file system

sudo resize2fs /dev/xvda1

resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 25, new_desc_blocks = 38
The filesystem on /dev/xvda1 is now 78614779 (4k) blocks long.

Double checking