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 increased from 500MB to ~36GB.

 

?האם התשובה שקיבלתם הייתה מועילה 0 משתמשים שמצאו מאמר זה מועיל (0 הצבעות)