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
Sample outputs:
/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
Sample outputs:
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.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop






![Linux Copy File Command [ cp Command Examples ]](http://s13.cyberciti.org/images/shared/rp/3/3.jpg)



![Linux Download Password Protected Large ISO Images [ Authentication Credentials ]](http://s13.cyberciti.org/images/shared/rp/3/11.jpg)


{ 1 comment… read it below or add one }
Hi,
Thanks a lot, very useful article
and useful command for admin