Disk Defragmentation

Alan McKinnon alan at linuxholdings.co.za
Mon Sep 18 17:00:37 UTC 2006

On Monday 18 September 2006 18:46, ac wrote:
> Mario Vukelic wrote:
> > On Sun, 2006-09-17 at 19:23 +0800, Joel Bryan Juliano wrote:
> >> There is still some fragmentation on ext3 filesystems, on
> >> most cases it's very minimal, but it also depends on time
> >> or overall usage of ext3 filesystem before the
> >> fragmentation is visible. In general fragmentation only
> >> happens when you do many deletes and writes on a disk that
> >> is nearly full.
> >
> > In general fragmentation only happens when you do many
> > deletes and writes on a disk that is nearly full.
> This is I understand, the important point.
> If a disk is used as nearly full, it will not be able to
> self-defrag as it would with more space. I understand that a
> windows  file is placed in the earliest space, and the disk
> then fills in sequence, rather inflexible. Deletions and size
> changes cause fragmentation immediately. I think that ext3
> places a file in the body of the (empty space) partition, so
> that a deletion will result in a (still large) empty space. A
> bit simplistic but ok for my simplistic brain. --
> ac

The important point to consider is that on a typical windows 
system, the entire system is one partition. That includes every 
file in every directory for all possible usage patterns. The 
disk rapidly takes on the appearance of a pig's breakfast. 
There's a minimally 750M swap file in there as well, scattered 
over most of the disk.

Contrast that with conventional usage on *nix: swap is a 
partition, so it has no effect on the rest of the 
filesystem. /tmp is often a separate filesystem, or a tmpfs 
which has no effect on the disk. /usr tends to be rather static 
and files on it tend to remain in a contiguous group anyway, 
which is the entire end purpose of defrag after all. The 
various *bin and *lib directories tend to have files added 
incrementally which then stay the same until significantly 
large protions of them are changed at one time (upgrades). 
Only /home would really benefit from defrag, but again the most 
common usage is to incrementally add files which then stay put 
(think large mp3 collections).

The reason Linux doesn't have a defrag isn't so much because 
it's not needed, but more that it doesn't feature at all (much 
like a plane doesn't need oars because it's not a boat).


More information about the ubuntu-users mailing list