Check file fragmentation in Linux

All file systems get fragmented. some more then others.

To check file fragmentation of a file under linux you use the program filefrag

filefrag myfile.zip

 

Show file fragmentation of a file

Example of how the output may be

> filefrag myfile.zip
myfile.zip: 16 extents found

If you want more information you can add the verbose (-v) flag

> filefrag -v myfile.zip
Filesystem type is: 52654973
File size of myfile.zip is 50000000 (12208 blocks, blocksize 4096)
Discontinuity: Block 765 is at 52574778 (was 52574777)
Discontinuity: Block 1768 is at 52575782 (was 52575781)
Discontinuity: Block 2788 is at 52576803 (was 52576802)
Discontinuity: Block 3791 is at 52577807 (was 52577806)
Discontinuity: Block 4811 is at 52578828 (was 52578827)
Discontinuity: Block 5814 is at 52579832 (was 52579831)
Discontinuity: Block 6834 is at 52580853 (was 52580852)
Discontinuity: Block 7837 is at 52581857 (was 52581856)
Discontinuity: Block 8857 is at 52582878 (was 52582877)
Discontinuity: Block 9877 is at 52583899 (was 52583898)
Discontinuity: Block 10519 is at 52584542 (was 52584541)
Discontinuity: Block 10520 is at 90047778 (was 52584543)
Discontinuity: Block 10521 is at 90047780 (was 90047779)
Discontinuity: Block 10880 is at 90048140 (was 90048139)
Discontinuity: Block 11900 is at 90049161 (was 90049160)
myfile.zip: 16 extents found

Above you see that the file myfile.zip is split into 16 fragments

Show file fragmentation of multiple files

It is also possible to use wildcard to scan multiple files.

>filefrag *
myfile01.zip: 15 extents found
myfile02.zip: 13 extents found
myfile03.zip: 13 extents found
myfile04.zip: 14 extents found
myfile05.zip: 13 extents found
myfile06.zip: 14 extents found
myfile07.zip: 13 extents found
myfile08.zip: 13 extents found
myfile09.zip: 14 extents found
myfile10.zip: 13 extents found
myfile11.zip: 13 extents found
myfile12.zip: 14 extents found
Tagged:  

( Try Multi Commander, A file manager for professionals )

Copyright (c) 2015 - Mathias Svensson