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 is 7200 seconds, which is 2 hours
  • -p passes β€” number of passes before the global re-org wraps up πŸ” the default is 10 passes
  • -f leftoff β€” use this file instead of /var/tmp/.fsrlast to 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.

🚨 if xfs_fsr moves these files, you must rerun lilo before 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