Bobcares

Extending XFS filesystem – How to do it?

by | Nov 18, 2021

Extending XFS filesystem is possible using the xfs_growfs Command

As part of our Server Management Services, we assist our customers with several XFS queries.

Today, let us see how our techs extend their filesystem size.

 

Extending XFS filesystem

We can use the xfs_growfs command to increase the size of an XFS file system. It must be mounted and there must be space available on the underlying device.

The syntax of the xfs_growfs command is as follows:

# xfs_growfs [options] mount-point

Currently, we cannot shrink or reduce an XFX filesystem. So, ensuring the device size is not larger than the intended size is essential.

  • Verify the current size

We can check the filesystem details prior to growing the filesystem:

# xfs_growfs -n /dev/vg_test/lv_test
meta-data=/dev/mapper/vg_test-lv_test isize=512 agcount=4, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=128000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

Here, the -n option does not extend, but prints the current filesystem details.

In addition, to view the current size of the mount point, we check the “df -h” command output:

# df -h
/dev/mapper/vg_test-lv_test 497M 26M 472M 6% /data
  • Extend the underlying device (lvextend, grow LUN, expand partition).

Now, we need to extend the underlying LVM volume. We need to perform this before growing the XFS filesystem.

It is also beneficial if we can extend an existing physical volume in the LVM VG.

In this article, we use a new PV to expand an LV.

1. Initially, we identify the new disk and create a Physical Volume:

# pvcreate /dev/sdc

2. Then we extent the Volume Group vg_test using the new PV:

# vgextend vg_test /dev/sdc

3. Eventually, we verify the new size of the volume group:

# vgdisplay vg_test
--- Volume group ---
VG Name vg_test
System ID 
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 125 / 500.00 MiB
Free PE / Size 10113 / 39.50 GiB
VG UUID wrd9eB-aZo3-HCmD-Rlgr-NcGP-vS2Z-cm2CeQ

4. Finally, we extend the logical volume to the size we require with the help of “lvresize” command:

# lvresize -L +35g /dev/vg_test/lv_test
Size of logical volume vg_test/lv_test changed from 500.00 MiB (125 extents) to 35.49 GiB (9085 extents).
Logical volume vg_test/lv_test successfully resized.
  • Grow the XFS file system

Now, we go ahead and grow the XFS file system:

# xfs_growfs /dev/vg_test/lv_test
meta-data=/dev/mapper/vg_test-lv_test isize=512 agcount=4, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=128000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 128000 to 9303040

As you can see, there is a change in the data blocks from 128000 to 9303040.

  • Verify

Now that we did the steps above, we need to verify the same.

1. To view the XFS volume details, we can use the “xfs_info” command.

Make note of the blocks for the data volume.

# xfs_info /dev/vg_test/lv_test
meta-data=/dev/mapper/vg_test-lv_test isize=512 agcount=291, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=9303040, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

2. After that, we verify the new size of the XFS file system in the “df -h” command output:

# df -hP /data
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_test 36G 35M 36G 1% /data

As we can see, /data mount point size increases from 500MB to ~36GB.

[Need further assistance? We are here for you]

 

Conclusion

In short, we saw how our Support Techs fix the XFS filesystem query for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.