How do I find out badly fragmented a particular file might be under Linux operating systems?
You need to use the filefrag command. It reports on how badly fragmented a particular file might be. It makesallowances for indirect blocks for ext2 and ext3 filesystems, but can be used on files for any filesystem. The syntax is:
filefrag file filefrag files filefrag file1 file2
In this example find how how badly fragmented rhel-workstation-6.3-x86_64-dvd.iso:
# filefrag /home/vivek/Downloads/rhel-workstation-6.3-x86_64-dvd.iso
/home/vivek/Downloads/rhel-workstation-6.3-x86_64-dvd.iso: 2093 extents found
You can verbose when checking for file fragmentation with the -v option:
# filefrag -v /etc/passwd
Filesystem type is: ef53 Filesystem cylinder groups is approximately 3547 File size of /etc/passwd is 1808 (1 block, blocksize 4096) ext logical physical expected length flags 0 0 103071773 1 merged,eof /etc/passwd: 1 extent found
Other options (taken from the man page):
-B Force the use of the older FIBMAP ioctl instead of the FIEMAP ioctl for testing purposes. -b Use 1024 byte blocksize for the output. -s Sync the file before requesting the mapping. -x Display mapping of extended attributes.Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?