Disk defragmenter in Linux

David G. Miller (aka DaveAtFraud) dave at davenjudy.org
Fri Dec 30 05:24:30 UTC 2005


mike.mccarty at sbcglobal.net wrote:

> Jim Cornette wrote:
>
>> John Summerfied wrote:
>>
>>> Jeff Vian wrote:
>>>
>>>>
>>>> Exactly, and IIRC the filesystem knows that if it needs X amount of
>>>> space for a file, then Y number of inodes are marked for use for that
>>>> file at the beginning.  Thus space allocated is as contiguous as is
>>>> efficient for read/write on the disk.
>>>
>>>
>>>
>>>
>>> If "the filesystem knows that if it needs X amount of space for a 
>>> file," that implies there's a way of telling it that.
>>>
>>> How's that done? I don't recall any system call for *x (there is one 
>>> for OS/2), and one could do it in JCL in IBM's OS in the 60s), but 
>>> in the *x world I've never seen a way to do it.
>>
>>
>>
>>
>> Since the discussions regarding fragmentation on ext3 filesystems was 
>> pretty long running. I decided to try
>> filefrag /usr/bin/* |sort |grep 'would be'
>> and the output showed a lot of fragmentation. One of the files was up 
>> to 45.
>
>
> On my system I did this...
>
> # filefrag /usr/bin/* | sort -k2 -nr | grep 'would be'
>
> Here're the first few entries...
>
> /usr/bin/emacs: 248 extents found, perfection would be 1 extent
> /usr/bin/emacs-21.3: 248 extents found, perfection would be 1 extent
> /usr/bin/kermit: 80 extents found, perfection would be 1 extent
> /usr/bin/kbabel: 45 extents found, perfection would be 1 extent
> /usr/bin/ddd: 45 extents found, perfection would be 1 extent
> /usr/bin/gthumb: 41 extents found, perfection would be 1 extent
> /usr/bin/gdbtui: 36 extents found, perfection would be 1 extent
> /usr/bin/elinks: 30 extents found, perfection would be 1 extent
> /usr/bin/iniomega: 22 extents found, perfection would be 1 extent
> /usr/bin/kpersonalizer: 21 extents found, perfection would be 1 extent
> /usr/bin/artsd: 21 extents found, perfection would be 1 extent
> /usr/bin/artscat: 20 extents found, perfection would be 1 extent
> /usr/bin/kiconedit: 19 extents found, perfection would be 1 extent
> /usr/bin/glade-2: 19 extents found, perfection would be 1 extent
> /usr/bin/karm: 18 extents found, perfection would be 1 extent
> /usr/bin/dia: 18 extents found, perfection would be 1 extent
> /usr/bin/designer3: 18 extents found, perfection would be 1 extent
> /usr/bin/designer: 18 extents found, perfection would be 1 extent
> /usr/bin/kppplogview: 16 extents found, perfection would be 1 extent
> /usr/bin/kfontinst: 16 extents found, perfection would be 1 extent
> /usr/bin/civclient-xaw: 15 extents found, perfection would be 1 extent
> /usr/bin/cdrecord: 15 extents found, perfection would be 1 extent
> /usr/bin/knewstickerstub: 14 extents found, perfection would be 1 ext
>
> Surely those who argue that ext3 does not get fragmented
> during install don't think that 248 extents is "not
> significant fragmentation".
>
> I assure you that I have done nothing on my system to try to
> fragment emacs.
>
> Mike
> -- 
> p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
> This message made from 100% recycled bits.
> You have found the bank of Larn.
> I can explain it for you, but I can't understand it for you.
> I speak only for myself, and I am unanimous in that!
>
>
Yes, but...
[root at bend ~]# filefrag /bin/* | sort -k2 -nr | grep 'would be'
/bin/netstat: 2 extents found, perfection would be 1 extent
/bin/login: 2 extents found, perfection would be 1 extent

Files that are frequently updated will often have some level of 
fragmentation.  Files that are relatively unchanged tend to be in a 
single extent.  Also, the stuff in /bin will generally be small, tight, 
command line programs.  A quick perusal of those listed in your example 
shows a number of graphical interface programs that are anything but 
small and don't even get me started about the size of emacs (the 
probability of change to a program is very directly related to the size 
of the program).

Cheers,
Dave




More information about the fedora-list mailing list