# xfs_fsr(8) - man - phpman

[xfs_fsr(8)](https://www.chedong.com/phpMan.php/man/xfsfsr/8/markdown)                             System Manager's Manual                            [xfs_fsr(8)](https://www.chedong.com/phpMan.php/man/xfsfsr/8/markdown)



## NAME
       xfs_fsr - filesystem reorganizer for XFS

## SYNOPSIS
       **xfs**___**fsr** [**-vdg**] [**-t** seconds] [**-p** passes] [**-f** leftoff] [**-m** mtab]
       **xfs**___**fsr** [**-vdg**] [xfsdev | file] ...
       **xfs**___**fsr** **-V**

## DESCRIPTION
       _xfs_fsr_ is applicable only to XFS filesystems.

       _xfs_fsr_ improves the organization of mounted filesystems.  The reorganization algorithm oper‐
       ates on one file at a time, compacting or otherwise improving the layout of the file  extents
       (contiguous blocks of file data).

       The following options are accepted by _xfs_fsr_.  The **-m**, **-t**, and **-f** options have no meaning if
       any filesystems or files are specified on the command line.

### -m
                    _/etc/mtab_.

### -t

### -p

### -f
                    and as the file to store the state of where reorganization left off.

### -v

### -d

### -g

### -V


       When invoked with no arguments _xfs_fsr_ reorganizes all regular files in all mounted  filesys‐
       tems.   _xfs_fsr_ makes many cycles over _/etc/mtab_ each time making a single pass over each XFS
       filesystem.  Each pass goes through and selects files that have the  largest  number  of  ex‐
       tents.  It attempts to defragment the top 10% of these files on each pass.

       It  runs  for  up to two hours after which it records the filesystem where it left off, so it
       can start there the next time.  This information is stored in the file _/var/tmp/.fsrlast_xfs._
       If  the information found here is somehow inconsistent or out of date it is ignored and reor‐
       ganization starts at the beginning of the first filesystem found in _/etc/mtab_.

       _xfs_fsr_ can be called with one or more arguments naming filesystems (block device name),  and
       files  to  reorganize.  In this mode _xfs_fsr_ does not read or write _/var/tmp/.fsrlast_xfs_ nor
       does it run for a fixed time interval.  It makes one pass through each specified regular file
       and  all regular files in each specified filesystem.  A command line name referring to a sym‐
       bolic link (except to a file system device), FIFO, or UNIX domain socket generates a  warning
       message,  but is otherwise ignored.  While traversing the filesystem these types of files are
       silently skipped.

## FILES
       /etc/mtab            contains default list of filesystems to reorganize.
       /var/tmp/.fsrlast_xfs
                            records the state where reorganization left off.

## SEE ALSO
       [xfs_fsr(8)](https://www.chedong.com/phpMan.php/man/xfsfsr/8/markdown), [mkfs.xfs(8)](https://www.chedong.com/phpMan.php/man/mkfs.xfs/8/markdown), [xfs_ncheck(8)](https://www.chedong.com/phpMan.php/man/xfsncheck/8/markdown), [xfs(5)](https://www.chedong.com/phpMan.php/man/xfs/5/markdown).

## NOTES
       _xfs_fsr_ improves the layout of extents for each file by copying the entire file to  a  tempo‐
       rary location and then interchanging the data extents of the target and temporary files in an
       atomic manner.  This method requires that enough free disk space be  available  to  copy  any
       given  file  and  that the space be less fragmented than the original file.  It also requires
       the owner of the file to have enough remaining filespace quota to do the copy on systems run‐
       ning  quotas.   _xfs_fsr_ generates a warning message if space is not sufficient to improve the
       target file.

       A temporary file used in improving a file given on the command line is created  in  the  same
       parent  directory  of  the  target  file and is prefixed by the string '**.fsr**'.  The temporary
       files used in improving an entire XFS device are stored in a directory at  the  root  of  the
       target device and use the same naming scheme.  The temporary files are unlinked upon creation
       so data will not be readable by any other process.

       _xfs_fsr_ does not operate on files that are currently mapped in memory.  A 'file  busy'  error
       can be seen for these files if the verbose flag (**-v**) is set.

       Files  marked as no-defrag will be skipped. The [_xfs_io_(8)](https://www.chedong.com/phpMan.php/man/xfsio/8/markdown) chattr command with the f attribute
       can be used to set or clear this flag. Files and directories created in a directory with  the
       no-defrag flag will inherit the attribute.

       An entry in _/etc/mtab_ or the file specified using the **-m** option must have the **rw** option spec‐
       ified for read and write access.  If this option is  not  present,  then  _xfs_fsr_  skips  the
       filesystem described by that line.  See the [_fstab_(5)](https://www.chedong.com/phpMan.php/man/fstab/5/markdown) reference page for more details.

       In  general  we  do not foresee the need to run _xfs_fsr_ on system partitions such as _/_, _/boot_
       and _/usr_ as in general these will not suffer from fragmentation.  There are also issues  with
       defragmenting  files  [_lilo_(8)](https://www.chedong.com/phpMan.php/man/lilo/8/markdown)  uses  to  boot your system. It is recommended that these files
       should be flagged as no-defrag with the [_xfs_io_(8)](https://www.chedong.com/phpMan.php/man/xfsio/8/markdown) chattr command. Should these files be moved
       by _xfs_fsr_ then you must rerun _lilo_ before you reboot or you may have an unbootable system.



                                                                                          [xfs_fsr(8)](https://www.chedong.com/phpMan.php/man/xfsfsr/8/markdown)
