Extend a Linux file system (XFS) on an NVMe EBS volumes

2 min read | by Jordi Prats

If we are using a NVMe EBS volumes, even though on the AWS Console we will see it as something like /dev/xvdait won't be visible on the Linux system using this name: We will have to look for /dev/nvme devices

If we want to resize the filesystem to the size of the volume we can use the following steps:

First, we can use growpart to resize the partition on the disk to fill it:

# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=4096 old: size=104853471 end=104857567 new: size=209711071 end=209715167

Then, depending on the file system we are using we will have to pick the right tool:

For XFS we will have to use xfs_growfs. With the -d option it will resize the file system to fill the partition:

# xfs_growfs -d /
meta-data=/dev/nvme0n1p1         isize=512    agcount=26, agsize=524159 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=0
data     =                       bsize=4096   blocks=13106683, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               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 13106683 to 26213883

Instead, if we are using some ext filesystem (like ext4), we'll have to use resize2fs:

# resize2fs /dev/nvme0n1
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/nvme0n1 to 256000 (4k) blocks.
The filesystem on /dev/nvme0n1 is now 256000 blocks long.

Posted on 07/02/2022