What are i missing - Expanding EC2 Instance Storage for Development Needs

What are i missing in this

[ec2-user@ip-172-31-94-107 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 2.9M 188M 2% /run
/dev/xvda1 8.0G 1.6G 6.5G 19% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
[ec2-user@ip-172-31-94-107 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 12G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
[ec2-user@ip-172-31-94-107 ~]$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=24576 old: size=16752607 end=16777183 new: size=25141215 end=25165791
[ec2-user@ip-172-31-94-107 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 12G 0 disk
├─xvda1 202:1 0 12G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
[ec2-user@ip-172-31-94-107 ~]$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs tmpfs 475M 0 475M 0% /dev/shm
tmpfs tmpfs 190M 2.9M 188M 2% /run
/dev/xvda1 xfs 8.0G 1.6G 6.5G 19% /
tmpfs tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 vfat 10M 1.3M 8.7M 13% /boot/efi
tmpfs tmpfs 95M 0 95M 0% /run/user/1000
[ec2-user@ip-172-31-94-107 ~]$ sudo xfs_growfs -d /
meta-data=/dev/xvda1 isize=512 agcount=2, agsize=1047040 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=2094075, imaxpct=25
= sunit=128 swidth=128 blks
naming =version 2 bsize=16384 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=4 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2094075 to 3142651
[ec2-user@ip-172-31-94-107 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 2.9M 188M 2% /run
/dev/xvda1 12G 1.6G 11G 13% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
[ec2-user@ip-172-31-94-107 ~]$ ^C
[ec2-user@ip-172-31-94-107 ~]$ sudo fdisk -l
Disk /dev/xvda: 12 GiB, 12884901888 bytes, 25165824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: ABF835D2-7C05-4891-80EE-060DCE9874A0

Device Start End Sectors Size Type
/dev/xvda1 24576 25165790 25141215 12G Linux filesystem
/dev/xvda127 22528 24575 2048 1M BIOS boot
/dev/xvda128 2048 22527 20480 10M EFI System

Partition table entries are not in disk order.

Hey,

When we need to expand EC2 instance storage of an EC2 instance, extending volume size in AWS management console is not enough, It just increases the overall size of the drive wheas we can create that extra size as another partition on disk or extend existing root partition as per the ask in the task.
Here is how we can achive it:

  1. Extend volume size using AWS console
  2. Login to EC2 instance using ssh
  3. lsblk → list partition blocks
  4. sudo xfs_growfs /dev/xvda 1 → extend partition size by identifying it’s block
  5. lsblk → verify partition blocks
  6. df -h → verify optional