e2freefrag - Linux


e2freefrag is a command-line tool that analyzes ext2 and ext3 filesystems to identify and report on fragmented files. It provides insights into the distribution and impact of file fragmentation on performance and storage efficiency.


e2freefrag [-adfhiw] [-b byte-size] [-c max-count] [-s start-byte] [-e end-byte] [filesystem]


  • -a: Print all files, including non-fragmented ones.
  • -d: Display detailed information about each fragmented file.
  • -f: Force analysis even if the filesystem is mounted.
  • -h: Print help message.
  • -i: Ignore filesystem errors.
  • -w: Display information in graph form.
  • -b byte-size: Specify the block size in bytes.
  • -c max-count: Limit the number of fragmented files reported.
  • -s start-byte: Specify the starting byte offset to analyze.
  • -e end-byte: Specify the ending byte offset to analyze.


  • Basic usage: Analyze the filesystem mounted at /dev/sda1.
    e2freefrag /dev/sda1
  • Detailed analysis of fragmented files: Display detailed information about fragmented files.
    e2freefrag -d /dev/sda1
  • Exclude non-fragmented files: Print only fragmented files.
    e2freefrag -a /dev/sda1

Common Issues

  • Mounted filesystems: If the filesystem is mounted, e2freefrag may not be able to access all files. Use the -f option to force analysis.
  • Large filesystems: Analyzing very large filesystems can take a long time. Use the -c option to limit the number of files analyzed.


e2freefrag can be combined with other tools to optimize filesystems:

  • e2defrag: Defragment filesystems based on e2freefrag analysis.
  • fsck: Identify and fix filesystem errors, such as fragmentation.

Related Commands