xfs_fsr(8)
β¨ NAME β¨
xfs_fsr(8) Β· System Manager's Manual π
okay so the manual name is xfs_fsr, and it's the filesystem reorganizer for XFS π§ it's basically a tidy-up queen for XFS filesystems only, so no other filesystem types get to join the party π
β¨ SYNOPSIS β¨
xfs_fsr [-vdg] [-t seconds] [-p passes] [-f leftoff] [-m mtab]
xfs_fsr [-vdg] [xfsdev | file] ...
xfs_fsr -V
πΈ DESCRIPTION πΈ
bestie, xfs_fsr is only for XFS filesystems π¦ don't try it on anything else lol
xfs_fsr improves how mounted filesystems are organized β¨ it works on one file at a time, compacting or otherwise improving the layout of each file's extents (the contiguous chunks of file data) π«Ά
the -m, -t, and -f options have no meaning if you specify any filesystems or files on the command line, so keep that in mind π
Here are the options xfs_fsr takes:
-m mtabβ use this file as the list of filesystems to reorganize π the default is/etc/mtab-t secondsβ how long to reorganize π the default is7200seconds, which is 2 hours-p passesβ number of passes before the global re-org wraps up π the default is10passes-f leftoffβ use this file instead of/var/tmp/.fsrlastto read where to start, and also as the file where the reorganization leaves off π-vβ verbose mode π it prints cryptic info about each file being reorganized (very mysterious, very iconic)-dβ debug mode π§ͺ it prints even more cryptic info, so buckle up-gβ prints to syslog π this is the default if stdout isn't a tty-Vβ prints the version number and exits π
When you run xfs_fsr with no arguments, it reorganizes all regular files in all mounted filesystems π
it makes many cycles over /etc/mtab, and each time it makes a single pass over each XFS filesystem. each pass selects the files with the largest number of extents, and it tries to defragment the top 10% of those files on every pass. main character behavior π
It runs for up to two hours, and then it records the filesystem where it left off so it can start there next time π°οΈ that info lives in /var/tmp/.fsrlast_xfs. if that info is somehow inconsistent or out of date, it gets ignored and reorganization starts at the beginning of the first filesystem found in /etc/mtab π«
You can also call xfs_fsr with one or more arguments naming filesystems (block device names) and files to reorganize π§ββοΈ in this mode it does not read or write /var/tmp/.fsrlast_xfs, and it doesn't run for a fixed time interval either. it makes one pass through each specified regular file and all regular files in each specified filesystem.
β οΈ if a command-line name refers to a symbolic link (except to a file system device), a FIFO, or a UNIX domain socket, you get a warning message, but it's otherwise ignored. while traversing a filesystem, these types of files are silently skipped, so no drama there π
π FILES π
/etc/mtabβ contains the default list of filesystems to reorganize π/var/tmp/.fsrlast_xfsβ records the state where reorganization left off π
π SEE ALSO π
xfs_fsr(8), mkfs.xfs(8), xfs_ncheck(8), xfs(5). go explore these, they're giving useful π¦
π‘ NOTES π‘
okay, the tea β xfs_fsr improves the layout of extents for each file by copying the entire file to a temporary location, then swapping the data extents of the target and temporary files in an atomic manner. this needs enough free disk space to copy any given file, and that space has to be less fragmented than the original file. on systems running quotas, the file's owner also needs enough remaining filespace quota to do the copy. if there isn't enough space to improve the target file, xfs_fsr throws a warning message at you π
when you improve a file given on the command line, the temporary file is created in the same parent directory as the target file and is prefixed with the string .fsr. the temporary files used when improving an entire XFS device are stored in a directory at the root of the target device, using the same naming scheme π§ the temporary files get unlinked upon creation, so no other process can read the data β¨
xfs_fsr does not operate on files that are currently mapped in memory π if the verbose flag (-v) is set, you may see a file busy error for these files.
Files marked as no-defrag get skipped π
ββοΈ the xfs_io(8) chattr command with the f attribute can set or clear this flag. files and directories created inside a directory with the no-defrag flag inherit the attribute π«Ά
An entry in /etc/mtab (or the file given with the -m option) must have the rw option for read and write access π if it doesn't, xfs_fsr skips the filesystem described by that line. see the fstab(5) reference page for more details.
In general, we don't foresee needing to run xfs_fsr on system partitions like /, /boot, and /usr, since these usually won't suffer from fragmentation π there are also issues with defragmenting files that lilo(8) uses to boot your system. it's recommended to flag these files as no-defrag with the xfs_io(8) chattr command.
π¨ ifxfs_fsrmoves these files, you must rerunlilobefore you reboot, or you may end up with an unbootable system. please don't be that person π
bestie, that's the whole manual π xfs_fsr(8), no version or date to report, just vibes β¨ go defrag something responsibly ππ«Ά
π¦ where this page comes from
- alpine 3.22: xfsprogs-doc 6.14.0-r0 Β· LGPL-2.1-or-later
- alpine 3.23: xfsprogs-doc 6.17.0-r0 Β· LGPL-2.1-or-later
- alpine 3.24: xfsprogs-doc 7.0.1-r0 Β· LGPL-2.1-or-later
- arch rolling: xfsprogs 7.2.0-1
- arch rolling: xfsprogs 7.2.1-1 Β· GPL-2.0-only AND LGPL-2.1-only
- centos-stream 10: xfsprogs 6.16.0-1.el10 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- centos-stream 9: xfsprogs 6.4.0-9.el9 Β· GPL+ and LGPLv2+
- centos-stream 9: xfsprogs 6.4.0-9.el9 Β· GPL+ and LGPLv2+
- debian bookworm: xfsprogs 6.1.0-1 Β· GPL-2.0-only
- debian trixie: xfsprogs 6.13.0-2+deb13u1 Β· GPL-2.0-only
- fedora 43: xfsprogs 6.15.0-3.fc43 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 43: xfsprogs 6.15.0-3.fc43 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 6.18.0-2.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 6.18.0-2.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 7.1.1-1.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- fedora 44: xfsprogs 7.1.1-1.fc44 Β· GPL-1.0-or-later AND LGPL-2.1-or-later
- nixos 26.05: xfsprogs 6.19.0
- nixpkgs unstable: xfsprogs 7.2.1
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- opensuse-leap 16.0: xfsprogs 6.19.0-160000.3.1 Β· GPL-2.0-or-later
- ubuntu jammy: xfsprogs 5.13.0-1ubuntu2 Β· GPL-2.0-only
- ubuntu jammy: xfsprogs 5.13.0-1ubuntu2.1 Β· GPL-2.0-only
- ubuntu noble: xfsprogs 6.6.0-1ubuntu2 Β· GPL-2.0-only
- ubuntu noble: xfsprogs 6.6.0-1ubuntu2.1 Β· GPL-2.0-only
- ubuntu questing: xfsprogs 6.13.0-2ubuntu2 Β· GPL-2.0-only
- ubuntu resolute: xfsprogs 6.18.0-3 Β· GPL-2.0-only
- ubuntu stonking: xfsprogs 6.19.0-1 Β· GPL-2.0-only
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms