Enlarge XFS partition

CentOS

XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993. It was the default file system in the SGI’s IRIX operating system starting with its version 5.3; the file system was ported to the Linux kernel in 2001, currently is the default file system in CentOS 7.

xfs_growfs allows to enlarge in hot a partition with XFS file system

Note:

  • It is not possible to enlarge a partition that is not mounted
  • It is not possible to use parted to enlarge an XFS partition
  • xfs_growfs usually is used with logical volumes (LVM), but can be used with regular partitions too.
  • To enlarge a partition, it is necessary that there is available space it will occupy.

Synopsis

# xfs_growfs [OPTIONS] mount-point

xfs_growfs has around a dozen options, but in this post we will look at 2 of them:

-d: partition will be enlarged as much as possible, it will increase up to the total available space
-D: partition will be enlarged until the value specified in size. The size must be given in number of blocks.

Examples

Enlarge the partition to the total available space

# xfs_growfs -d /dev/mapper/centos-root

Enlarge the partition to a given size

If we wish to enlarge the partition up to 100 GB and file system blocks size is 4 k, then execute the following command

# xfs_growfs -D 26214400 /dev/mapper/centos-root

To know the block size of the file system we can run the command

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

Note the output of bsize = 4096 (4K)

Further readings

– man xfs_growfs
XFS




Leave a Comment

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