On Wed, Sep 5, 2012 at 1:02 PM, Dale <[email protected]> wrote:
> Peter Humphrey wrote:
>> On Wednesday 05 September 2012 13:02:01 Dale wrote:
>>
>>> I find that after a big update, like KDE, it helps to defrag /usr.
>> Interesting. I've just run sudo e4defrag -c /usr and got a fragmentation
>> of zero. That's after upgrading KDE last week.
>>
>> Then I ran it on all the nine ext4 partitions here and only two had
>> nonzero fragmentations; one was 1 and the other 2.
>>
>> Looks like I can forget about it on this box.
>>
>
> I have to say that here, it is not a whole lot of fragmentation but it
> does seem a bit faster afterwards.  I guess it depends on what is
> fragmented and such.  I sometimes wonder if it defrags itself.  Even
> when I watch the fsck when booting, all the ext4 partitions have a very
> small percentage of fragmentation.  My /boot which is ext2 is fragmented
> as heck.  lol  I'm not worried about it tho.  ;-)  When I was using
> reiserfs, it was always a good bit of fragmentation.
>
> Just thought it was worth a mention since this is the first time I saw a
> Linux defrag tool.

I think almost all linux defrag tools/techniques deal with file
fragmentation only, that is to say one file with more than 1 extent,
but don't deal with filesystem fragmentation (10000 small files
scattered all over the drive, rather than written contiguously). So
I'm not surprised that Peter did not see fragmentation after
installing KDE.

AFAIK almost all that modern defrag tools do is just copy the file,
allocating the whole file at once in the copy process, and if that new
copy has fewer extents than the old copy, it fills in the data, then
removes the original file. The concept is not entirely dissimilar to
the old "backup, format, restore" defrag process.

Over the years I have used a poor-man's version of that concept to
defrag files. Just move it to another drive (or -- even better -- a
ramdrive/tmpfs), then move it back to disk (with a tool that performs
preallocation).

There is a userland defrag tool that does exactly this, on any
filesystem. It is called "shake".

Typically I only see fragmentation on large files that were copied
from a slow source (over the network/internet), or bittorrent clients
that do not preallocate space, etc. Any kind of streaming file that
was written, huge multi-gigabyte video recording files, that kind of
stuff. But the key to avoiding file fragmentation is preallocation...

Reply via email to