Forrest logo
tool overview
On this page you find all important commands for the CLI tool e4defrag. If the command you are looking for is missing please ask our AI.


e4defrag is a command line tool designed for defragmenting ext4 file systems, which is the default file system for many Linux distributions.

  1. The purpose of e4defrag is to optimize the layout of files on an ext4 file system, ultimately improving system performance.
  2. It is specifically designed to reduce file fragmentation, which occurs when files are divided into multiple fragmented parts across the disk.
  3. By defragmenting the file system, e4defrag rearranges the contents of files on the disk, bringing related data closer together and reducing seek times.
  4. The tool uses the online defragmentation method, meaning it can defragment the file system while it is mounted and in use.
  5. To use e4defrag, you need to have root privileges or run the command as sudo.
  6. It operates on a file system level, analyzing and defragmenting whole files rather than individual fragments.
  7. e4defrag provides various options for defragmentation, including different strategies for optimization and specifying a target range of extents to defragment.
  8. The tool uses a log-based approach, tracking changes made during defragmentation, so it is capable of resuming interrupted defragmentations.
  9. It can display detailed statistics about the defragmentation process, such as the number of files and extents defragmented.
  10. e4defrag can significantly improve the file system's read and write performance, particularly on systems with heavy file activity or large files.

List of commands for e4defrag:

  • e4defrag:tldr:13a20 e4defrag: See how fragmented a filesystem is.
    $ e4defrag -c ${-dev-sdXN}
    try on your machine
    explain this command
  • e4defrag:tldr:82521 e4defrag: Defragment the filesystem.
    $ e4defrag ${-dev-sdXN}
    try on your machine
    explain this command
  • e4defrag:tldr:e6dd3 e4defrag: Print errors and the fragmentation count before and after each file.
    $ e4defrag -v ${-dev-sdXN}
    try on your machine
    explain this command
tool overview