[Sussex] Why Linux doesn't need defrag

Steven Dobson steve at dobson.org
Thu Aug 17 20:42:57 UTC 2006


John

On Thu, 2006-08-17 at 17:53 +0100, John Crowhurst wrote:
> On Thu, August 17, 2006 15:01, Steven Dobson wrote:
> For ext2, ext3, minix and xiafs the command is e2defrag. The program
> can
> be found here (in a modified form):
> http://e2compr.sourceforge.net/attic/defrag.html
> or as defrag here:
> http://revu.tauware.de/revu1-incoming/defrag-0601080159/

I don't trust the first from a quick scan of the web page, but the
second has a README with a copyright notice from Stephen C. Tweedie.
I'd trust this more as Tweedie is one of the top Linux experts esp on
file systens.  The read me file is well worth reading if you're into
this disk layout stuff that we have be chatting about:

http://revu.tauware.de/revu1-incoming/defrag-0601080159/defrag-0.73pjm1/README

The defrag program is also packaged for Debian (apt-get install defrag)
where as the first one is not.

> >> It seems that as Linux and Unix in general passes its file and disk
> >> handling to underlying drivers, some of these formats require
> >> defragmentation.
> >
> > But, generally. that defragmentation code is written into the
> filesystem
> > code in *nux, but is a separate program in win32land.  I kinda think
> > that is the reason.  All disks need defraging.  If you defrag as you
> > write noramlly it is a small overhead on your disk output, but if it
> is
> > a seperate program to be run by the user then the disk performance
> can
> > suffer and the defrag time become significant.
> 
> I suspect with some file systems, defragging happens on-the-fly or
> doesn't
> happen at all. Reiserfs stores the file structure as a b+ tree,
> perhaps
> that removes the need for fragments and defragmenting, as the
> filesystem
> has no defrag program. 

I use XFS as my main filesystem.  I've had this system now for around
six months and it is my main machine, so I use it every day and do a
fair bit of compiling on it.

It should be noted that I've upgraded the disk (about three months ago)
to a SATA driver and moved my filesystems over using  "cp -a" which
would have defrag the filesystems at that point.

I just when looking for the defrag program for XFS and found one in the
xfsdump package.  Installed it and ran it over all my XFS file systems.
It did not take long (<10mins) to defrag the lot.  I kinda expected this
because XFS (like ext2/3, JFS, ...) has code to resist fragmentation.

Just though some of you might be intrested.

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20060817/07bd5a1d/attachment.pgp 


More information about the Sussex mailing list