Defragmenting an XFS File System
You can use the xfs_fsr command to defragment whole XFS file systems or individual files within an XFS file system. As XFS is an extent-based file system, defragmenting a whole file system is unnecessary and also discouraged.
To defragment an individual file, use the following command to specify the name of the file as the argument to xfs_fsr:
sudo xfs_fsr pathname
Running the xfs_fsr command without any options defragments all the
mounted and writeable XFS file systems that are listed in /etc/mtab
. For two
hours, the command passes over each file system, in turn, and defragments the top 10 percent
of files with the greatest number of extents. After two hours, the command records its
progress in the /var/tmp/.fsrlast_xfs
file. If you run the command again, the
process is resumed from that point.
For more information, see the xfs_fsr(8)
manual
page.