Skip to main content

Increase disk storage of EC2 instance

Amazon Docs

Step 1 - Check file system

df -h

Screenshot 2023-10-04 at 10.07.45.png

Step 2 - Find partition 

lsblk

Screenshot 2023-10-04 at 10.08.15.png

Step 3 - Extend disk

Check which disk and which partition to extend. In this case the disk is

nvme0n1

 and the partition is

nvme0n1p1

 (partition 1).

This means the command for expanding the disk is

sudo growpart /dev/nvme0n1 1

where the partition is the 1 at the end of the command.

Step 4 - Resize the partition

sudo resize2fs /dev/nvme0n1p1

Done

You are now done, the expected message after this command is something like this:

root@ip-10-0-1-71:/home/deploy# sudo resize2fs /dev/nvme0n1p1
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/nvme0n1p1 is now 8360187 (4k) blocks long.

Running df -hT will result in something like this, showing the new size.

Screenshot 2023-10-04 at 10.27.15.png