DTechs

Growing XFS File System a bit Detail

If you like to grow your xfs filesystem:

[root@c1 ~]# xfs_info / 
meta-data=/dev/mapper/centos-root isize=256 agcount=6, agsize=436992 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=2272256, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

As it can be seen from the output of the command, the blocks count of the fileystem is : bsize=4096 blocks=2272256
This is based on the blocks and we can find the total size of the filesystem by multiplying the blocks x block Unit Size.

So our root filesystem in the example is about :  4096 * 2272256 = 9307160576 Bytes ~ 8876 MBi ~ 8,66 GBi

If we want to grow our filesystem for a defined size, like extra 4MB, then we need to calculate how many blocks we need, then, we need to grow to that specific block count.

4*1024*1024 / 4096 = 1024  # which is the extra blocks to expand 4 MBi

Before we grow the filesystem,we shall increase the partion size to meet the expansion of 4MBi

[root@c1 ~]# lvextend -L +4M /dev/centos/root 
Size of logical volume centos/root changed from <8.67 GiB (2219 extents) to 8.67 GiB (2220 extents).
Logical volume centos/root successfully resized.

So,2272256 + 1024 = 2273280 blocks that needed to grow 4MBi extra.

[root@c1 ~]# xfs_growfs -D 2273280 /
meta-data=/dev/mapper/centos-root isize=256 agcount=6, agsize=436992 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=2272256, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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 2272256 to 2273280

[root@c1 ~]# xfs_info /
meta-data=/dev/mapper/centos-root isize=256 agcount=6, agsize=436992 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=2273280, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0