• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to grow/extend XFS filesytem in CentOS / RHEL using “xfs_growfs” command

By admin

xfs_growfs Command

Use the xfs_growfs command to increase the size of an XFS file system. The XFS file system must be mounted and there must be space available on the underlying device. The xfs_growfs utility is most often used with logical volumes. The syntax of the xfs_growfs command is as follows:

# xfs_growfs [options] mount-point

The following options are available for the xfs_growfs command:

  • -d: Expand the data section of the file system to the maximum size of the underlying device.
  • -D [size]: Specify the size to expand the data section of the file system. The [size] argument is expressed in the number of file system blocks.
  • -L [size]: Specify the new size of the log area. This does not expand the size, but specifies the new size of the log area. Therefore, this option can be used to shrink the size of the log area. You cannot shrink the size of the data section of the file system.
  • -m [maxpct]: Specify the new value for the maximum percentage of space in the file system that can be allocated as inodes. With the mkfs.xfs command, this option is specified with the –i maxpct=[value] option.
CAUTION: It is currently not possible to shrink or reduce an xfs filesystem. Thus is it essential to ensure the device size is not larger than the intended size.

Extending XFS filesytem

1. Verify current size of XFS filesystem

Check the filesystem details before 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

The -n option does not actually extend the XFS filesystem, but just prints the current filesystem details. Aslo check for the “df -h” command output to view current size of the mount point.

# df -h
/dev/mapper/vg_test-lv_test  497M   26M  472M   6% /data

2. Extend the underlying device (lvextend, grow LUN, expand partition).

Before we grow the XFS filesystem, we need to extend the underlying LVM volume. If possible, you may extend an existing physical volume in the LVM VG. For the purpose of this post we will use a new PV to expand an LV.

1. Identify the new disk and create a Physical Volume.

# pvcreate /dev/sdc

2. Extent the Volume Group vg_test using the new PV.

# vgextend vg_test /dev/sdc

3. 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. Extend the logical volume to the desired size using the “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.

3. Growing 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

Note the data blocks changed from 128000 to 9303040.

4. Verify

1. You can view the XFS volume details using the “xfs_info” command as shown below. Note 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

Verify the new size of the XFS file system in “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 you can see in the output above, /data mount point size has been increase from 500MB to ~36GB.

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Beginners Guide to Managing Package Module Streams in CentOS/RHEL 8
  2. CentOS / RHEL : How to find which user run a specific command?
  3. What are Symbolic Links (Soft Links) and how to create them under Linux
  4. CentOS / RHEL 7 : Beginners guide to firewalld
  5. CentOS / RHEL : How to add a null route in Linux
  6. “Device /dev/mappper/mpath25 Not Found (or Ignored By Filtering)” – error while creating physical volume with pvcreate
  7. How to use wget to download file via proxy
  8. CentOS / RHEL : How to create new LVM based swap partition
  9. Linux OS Service ‘ntpd’
  10. How to split iso or file using ‘split’ command in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary