Extend Linux File System

SSH to the instance
Verify the volume that has the problem with command: lsblk
Changed the volume to 32 GB from the AWS console (chose 32 because it was sufficiently large and wouldn’t be confused with the other 16GB volumes)
Extend the partition with command: sudo growpart /dev/nvme0n1 1
Verify the partition was grown with: lsblk
Extend the file system to use the partition with: sudo xfs_growfs -d /

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html#extend-file-system-nvme
https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[ec2-user@mongo ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1 259:0 0 48G 0 disk /data
nvme0n1 259:1 0 16G 0 disk
├─nvme0n1p1 259:2 0 8G 0 part /
└─nvme0n1p128 259:3 0 1M 0 part
[ec2-user@mongo ~]$ sudo growpart /dev/nvme0n1 1
CHANGED: partition=1 start=4096 old: size=16773087 end=16777183 new: size=33550303 end=33554399
[ec2-user@mongo ~]$
[ec2-user@mongo ~]$ sudo xfs_growfs -d /
meta-data=/dev/nvme0n1p1 isize=512 agcount=4, agsize=524159 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0
= reflink=0 bigtime=0 inobtcount=0
data = bsize=4096 blocks=2096635, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2096635 to 4193787
[ec2-user@mongo ~]$
[ec2-user@mongo ~]$ df -H
Filesystem Size Used Avail Use% Mounted on
devtmpfs 8.2G 0 8.2G 0% /dev
tmpfs 8.2G 0 8.2G 0% /dev/shm
tmpfs 8.2G 517k 8.2G 1% /run
tmpfs 8.2G 0 8.2G 0% /sys/fs/cgroup
/dev/nvme0n1p1 8.6G 7.7G 954M 89% /
/dev/nvme1n1 26G 23G 3.1G 89% /data
tmpfs 1.7G 0 1.7G 0% /run/user/0
tmpfs 1.7G 0 1.7G 0% /run/user/1000
[ec2-user@mongo ~]$ sudo xfs_growfs -d /data
meta-data=/dev/nvme1n1 isize=512 agcount=6, agsize=1048576 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0
= reflink=0 bigtime=0 inobtcount=0
data = bsize=4096 blocks=6291456, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 6291456 to 12582912
[ec2-user@mongo ~]$

Extend out the root volume Amazon Linux 2023

1
2
3
[ec2-user@mongo ~] $sudo growpart /dev/nvme0n1 1
[ec2-user@mongo ~] $sudo xfs_growfs -d /
[ec2-user@mongo ~] $df -H

Extend out the data volume Amazon Linux 2023

1
2
[ec2-user@mongo ~] sudo xfs_growfs -d /data
[ec2-user@mongo ~] $df -H