no "defrag" in Linux?

Henk Postma henkpm at gmail.com
Wed Jul 19 21:43:30 UTC 2006


On 7/17/06, James Gray <james at grayonline.id.au> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Peter Clutton wrote:

> I agree - defragmenting ext2/3 is more a waste of time than anything
> else,

Not really. First off: you can check the fragmentation of individual files with
# sudo filefrag $file

I disagree with the assertion that file fragmentation is no issue, or
defragmentation is a waste of time on ext3. The argument is usually as
follows: since multiple users and programs are running on the system
at the same time, it doesn't really matter, and ext3 is very good at
minimizing travel to minimize seek time.

Well guess what? Most of the time, on desktop systems, there are only
a few programs that are heavily using the hard drive. In fact, the
moment you will feel the fragmentation the most is when there is _one_
process that is reading or writing lots of data.

Go ahead and try the following.
1) locate a large file (divx movie?).
2) sudo filefrag $movie, note the level of fragmentation
3) time cat $movie > /dev/null, note the time it took
4) now make a copy of the movie:
cp $movie $movie.new
5) sudo filefrag $movie.new Most likely, you will find that it is less
fragmented
6) time cat $movie.new > /dev/null

I guarantee you will see a big reduction in time it takes to dump the
file to /dev/null

Try the same with your mailbox file, it makes a big difference.

Now you may say: "I use maildir, and not an mbox file, so this doesn't
matter". You would be wrong. I wrote a small perl script that goes
through my maildir, makes a copy of every file, and checks with
filefrag if the fragmentation is less. In that case, it will keep the
new one. My mutt startup time went from 63 seconds to 11 seconds.

> However, this
> amount of fragmentation on these file systems, coupled with the way the
> Linux kernel uses buffers and caching for disk access, results in no
> appreciable reduction in performance.

See above, I think this argument does not apply for large files, and
or effectively single user systems. But I'm not expert. I'm just
reporting what I experienced.

Sorry all, I had to get this off my chest :)

-- Henk

-- 
http://www.its.caltech.edu/~postma/




More information about the ubuntu-users mailing list