Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wiki pages for btrfs and other how-tos talk about online defragmentation and other related topics but they don't say how to find out how fragmented a file system is. Is there a method to determine how many files are fragmented or to produce some other meassure of file system fragmentation?

share|improve this question

filefrag command works with btrfs as well as with other filesystems.

$ filefrag ubuntu-8.04.1-desktop-i386.iso
ubuntu-8.04.1-desktop-i386.iso: 7 extents found

It only shows the number of extents for individual files though. You may want to write a shell script to sample a number of files and calculate some number which will give an approximate indication of how the whole filesystem is fragmented.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.