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

by nixcraft on March 22, 2006 · 2 comments

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

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 2 comments… read them below or add one }

1 Anonymous March 22, 2006

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

Reply

2 nixcraft March 23, 2006

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.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 11 + 11 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: