E4DEFRAG(8)                System Manager's Manual               E4DEFRAG(8)

NAME         top

       e4defrag - online defragmenter for ext4 filesystem

SYNOPSIS         top

       e4defrag [ -c ] [ -v ] target ...

DESCRIPTION         top

       e4defrag reduces fragmentation of extent based file. The file
       targeted by e4defrag is created on ext4 filesystem made with "-O
       extent" option (see mke2fs(8)).  The targeted file gets more
       contiguous blocks and improves the file access speed.

       target is a regular file, a directory, or a device that is mounted as
       ext4 filesystem.  If target is a directory, e4defrag reduces
       fragmentation of all files in it. If target is a device, e4defrag
       gets the mount point of it and reduces fragmentation of all files in
       this mount point.

OPTIONS         top

       -c     Get a current fragmentation count and an ideal fragmentation
              count, and calculate fragmentation score based on them. By
              seeing this score, we can determine whether we should execute
              e4defrag to target.  When used with -v option, the current
              fragmentation count and the ideal fragmentation count are
              printed for each file.

              Also this option outputs the average data size in one extent.
              If you see it, you'll find the file has ideal extents or not.
              Note that the maximum extent size is 131072KB in ext4
              filesystem (if block size is 4KB).

              If this option is specified, target is never defragmented.

       -v     Print error messages and the fragmentation count before and
              after defrag for each file.

NOTES         top

       e4defrag does not support swap file, files in lost+found directory,
       and files allocated in indirect blocks. When target is a device or a
       mount point, e4defrag doesn't defragment files in mount point of
       other device.

       It safe to run e4defrag on a file while it is actively in use by
       another application.  Since the contents of file blocks are copied
       using the page cache, this can result in a performance slowdown to
       both e4defrag and the application due to contention over the system's
       memory and disk bandwidth.

       If the file system's free space is fragmented, or if there is
       insufficient free space available, e4defrag may not be able to
       improve the file's fragmentation.

       Non-privileged users can execute e4defrag to their own file, but the
       score is not printed if -c option is specified. Therefore, it is
       desirable to be executed by root user.

AUTHOR         top

       Written by Akira Fujita <> and Takashi Sato <t->.

SEE ALSO         top

       mke2fs(8), mount(8).

COLOPHON         top

       This page is part of the e2fsprogs (utilities for ext2/3/4
       filesystems) project.  Information about the project can be found at
       ⟨⟩.  It is not known how to report
       bugs for this man page; if you know, please send a mail to  This page was obtained from the project's
       upstream Git repository 
       ⟨git://⟩ on 2017-03-13.
       If you discover any rendering problems in this HTML version of the
       page, or you believe there is a better or more up-to-date source for
       the page, or you have corrections or improvements to the information
       in this COLOPHON (which is not part of the original manual page),
       send a mail to

e4defrag version 2.0              May 2009                       E4DEFRAG(8)