About Linux FAQ

Browse More FAQs:

How do I find file fragmentation for specific file under Linux?

Posted by Vivek Gite [Last updated: March 22, 2006]

If you would like to find out file fragmentation information for specific file, use filefrag command that report on file fragmentation.

filefrag reports on how badly fragmented a particular file might be. It makes allowances for indirect blocks for ext2 and ext3 filesystems, but can be used on files for any filesystem.

For example see file fragmentation for /var/log/message file:

# filefrag -v /var/log/messages

Output:

Checking /var/log/messages
Filesystem type is: ef53
Filesystem cylinder groups is approximately 9448
Blocksize of file /var/log/messages is 4096
File size of /var/log/messages is 72 (1 blocks)
First block: 1841075
Last block: 1841075
/var/log/messages: 1 extent found

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Discussion on This FAQ

  1. Anonymous Says:

    Nice tip. Is there also a command to defrag a file?

  2. nixcraft Says:

    Use defrag (ext2, minix and xiafs filesystem defragmenter ) command. Read man page of defrag for more info.

    Ext3 file system donot need defrag as it is optimized and do not suffer from fragmentation problem in general.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.