xfs_fsr
What it is
xfs_fsr is a free Linux utility in the xfsprogs project for reorganizing mounted XFS filesystems. It improves file extent layout one file at a time by copying a file to a temporary location and atomically exchanging the original and temporary files’ data extents. With no arguments, it selects files with the most extents and attempts to defragment the top 10% on each pass. A default run can last up to two hours and records where it stopped so it can resume later.
You can target named filesystems or individual files; it makes one pass through each specified target. The filesystem must be mounted read-write, and entries without the rw option are skipped. It does not process files mapped in memory or files marked no-defrag. The operation needs enough free disk space to copy the target file, with that space less fragmented than the original. On quota-enabled systems, the owner also needs enough remaining file space quota. The manual says system partitions generally do not need xfs_fsr and warns that moving bootloader files can make a system unbootable unless lilo is rerun before reboot.
For and against
For
- Can resume after its default two-hour run.
- Targets named filesystems or individual files.
- Selects highly fragmented files when run without arguments.
- Free utility for XFS filesystems.
Against
- Requires a mounted read-write filesystem.
- Needs enough less-fragmented free space to copy targets.
- Skips files mapped in memory or marked no-defrag.
- Moving bootloader files can leave a system unbootable.
The verdict
xfs_fsr reorganizes XFS file extents, with target selection and resumable runs. Before using it, account for its disk-space and quota requirements and the manual’s bootloader warning.
Who it suits
xfs_fsr is for Linux users maintaining mounted XFS filesystems who need to reorganize file extents. It is intended for selected files or filesystems, rather than system partitions generally.
Plans and prices
xfs_fsr
Applies only to XFS filesystems
Read 4 Oct 2026 · man7.org
On the record
- Access requirement
- The filesystem must be mounted read-write; entries without the rw option are skipped.man7.org · read 4 Oct 2026
- Disk space requirement
- Reorganization requires enough free disk space to copy the target file, with space less fragmented than the original file.man7.org · read 4 Oct 2026
- How it works
- It copies a file to a temporary location and atomically interchanges the data extents of the original and temporary files.man7.org · read 4 Oct 2026
- Mapped files
- It does not operate on files that are currently mapped in memory.man7.org · read 4 Oct 2026
- No-defrag flag
- Files marked no-defrag are skipped, and the flag can be set or cleared with xfs_io's chattr command.man7.org · read 4 Oct 2026
- Operational caution
- The manual says system partitions generally do not need xfs_fsr and cautions that moving bootloader files can make a system unbootable unless lilo is rerun before reboot.man7.org · read 4 Oct 2026
- Project and support
- The manual identifies xfs_fsr as part of the xfsprogs project and directs bug reports to the linux-xfs mailing list.man7.org · read 4 Oct 2026
- Purpose
- xfs_fsr reorganizes mounted XFS filesystems by improving the layout of file extents one file at a time.man7.org · read 4 Oct 2026
- Quota requirement
- On systems using quotas, the file owner must have enough remaining file space quota for the copy.man7.org · read 4 Oct 2026
- Selection
- With no arguments, it selects files with the largest numbers of extents and attempts to defragment the top 10% on each pass.man7.org · read 4 Oct 2026
- Targeting
- It can be run on named filesystems or individual files, making one pass through each specified target.man7.org · read 4 Oct 2026
- Time limit
- The default run lasts up to two hours and records where it stopped so it can resume later.man7.org · read 4 Oct 2026