How to see fragmentation of a specific file?

Is there a tool that would show me a specific file on disk, how fragmented is it? (How many queries on a physical disk do I need to do if I were to read this file in a linear fashion)

+7
performance filesystems fragmentation ntfs
source share
5 answers

You can use DeviceIoControl with FSCTL_GET_VOLUME_BITMAP , FSCTL_GET_RETRIEVAL_POINTERS and FSCTL_MOVE_FILE , see Defragmenting files .

You can also find different code examples if you are looking for FSCTL_MOVE_FILE .
Here is one of C and the other is . NET

+9
source share

The Sysinternals contig tool with the -a option can do this for a file or all files in a folder and its subfolders.

+14
source share

fsutil file queryallocranges offset=<o> length=<l> <file> will show you the extents of the files, you will need administrator rights.

+2
source share

And, of course, “fragmentation” is suspicious:

  • A file can be in pieces in one cylinder. No overhead, just rotational latency. Or not like the parts can be the optimal order (the odds are close to zero for this).
  • The file may be “contiguous,” but after a few cylinders. Even reading will consistently lead to a search.
  • The file may be in a set of stripes, and you do not know where the borders are. You can move to another controller, another spindle, or another partition on the same drive.

Be careful what conclusions you make.

+2
source share

filefrag is the tool you are looking for if you are using Linux. Use the -v option with the file name to get a detailed list of fragmentation. http://linux.die.net/man/8/filefrag

+2
source share

All Articles