Increase/Expand an XFS Filesystem in RHEL 7 / CentOS 7

Mattias Geniar, Sunday, August 2, 2015

This guide will explain how to grow an XFS filesystem once you've increased in the underlying storage.

If you're on a VMware machine, have a look at this guide to increase the block device, partition and LVM volume first: Increase A VMware Disk Size (VMDK) Formatted As Linux LVM without rebooting. Once you reach the resize2fs command, return here, as that only applies to EXT2/3/4.

To see the info of your block device, use xfs_info.

$ xfs_info /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1210880 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=4843520, 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

Once the volume group/logical volume has been extended (see this guide for increasing lvm), you can expand the partition using xfs_growfs.

$  xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1210880 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=4843520, 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

The increase will happen in near-realtime and probably won't take more than a few seconds.

Using just xfs_growfs, the filesystem will be increased to its maximum available size. If you want to only increase for a couple of blocks, use the -D option.

If you don't see any increase in disksize using df, check this guide: Df command in Linux not updating actual diskspace, wrong data.



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

EDWARD PERINES Friday, May 6, 2016 at 23:01 - Reply

thanks !!!


Peter Tran Tuesday, July 5, 2016 at 16:21 - Reply

Your article solved my issue. Thanks so much.


Eduardo Hernacki Monday, August 22, 2016 at 22:09 - Reply

Just an info: when using xfs_growfs, you must specify the mount point instead of the device name:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/xfsgrow.html

Keep up the good work!


Denise Thursday, March 23, 2017 at 22:42 - Reply

Thank you for this guide. It was very helpful!


fab Wednesday, June 7, 2017 at 20:23 - Reply

I’ve missed the boat. xfs_growfs /lvmpartition does not work for me.
says the data is unchanged skipping


Yves Haegeman Wednesday, January 31, 2018 at 22:43 - Reply

Perfect note which helped me expanding my root xfs-partition on a OVM VM-machine !! Thanks !!


David Thursday, January 17, 2019 at 20:38 - Reply

Thank you so much!


Leave a Reply

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