Example of enlarging an AWS EC2 stock partition from 8 GB to 15 GB

Example of enlarging a AWS EC2 stock partition from 8 GB to 15 GB.

The AWS documentation is actually pretty good but they confuse you when it comes to which file system so here is a simpler example:

root@ip-172-31-42-201:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 55.5M 1 loop /snap/core18/1988
loop1 7:1 0 31.1M 1 loop /snap/snapd/11036
loop2 7:2 0 33.3M 1 loop /snap/amazon-ssm-agent/3552
loop3 7:3 0 69.9M 1 loop /snap/lxd/19188
loop4 7:4 0 55.5M 1 loop /snap/core18/1997
loop5 7:5 0 32.3M 1 loop /snap/snapd/11588
loop6 7:6 0 70.4M 1 loop /snap/lxd/19647
nvme0n1 259:0 0 15G 0 disk 
└─nvme0n1p1 259:1 0 8G 0 part /

root@ip-172-31-42-201:~# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=31455199 end=31457247
root@ip-172-31-42-201:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 55.5M 1 loop /snap/core18/1988
loop1 7:1 0 31.1M 1 loop /snap/snapd/11036
loop2 7:2 0 33.3M 1 loop /snap/amazon-ssm-agent/3552
loop3 7:3 0 69.9M 1 loop /snap/lxd/19188
loop4 7:4 0 55.5M 1 loop /snap/core18/1997
loop5 7:5 0 32.3M 1 loop /snap/snapd/11588
loop6 7:6 0 70.4M 1 loop /snap/lxd/19647
nvme0n1 259:0 0 15G 0 disk 
└─nvme0n1p1 259:1 0 15G 0 part /

# resize2fs /dev/root
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/root is now 3931899 (4k) blocks long.

root@ip-172-31-42-201:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 6.4G 8.2G 44% /

Reference

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

Share this article

Leave a Reply

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

Scroll to Top