The second extended filesystem (ext2) is designed much better than FAT or,
you might think, NTFS (which is pretty much a hacked-up FAT fs).  ext2
(a.k.a. e2fs) keeps track of which conseutive blocks are open, and when a
file needs to be written, the filesystem will try to write it to a place
where it won't be fragmented.  Thus, fragmentation is kept to a
minimum.  As a rule, you don't need to defragment ext2, it pretty much
keeps itself defragmented.

If you're interested, fsck can tell you what level of fragmentation you
have.  It refers to it as "non-contiguous files."

If, however, you're really big on no fragmentation, there is a defrag
program for ext2.  It's available at
ftp://ftp.uk.linux.org/pub/linux/sct/defrag/

I've not used it.  I don't feel I need to (but, then again, I only defrag
my FAT partitions before resizing them).  In the README, it's noted that
on an ext2 partition, the performance increase is usually only about
5%-10% after a defragging.  It's also noted that larger files on ext2 are
never really completely defragmented, because of balancing that is done
between block groups.

In the words of the README, "Defragmenting an ext2fs partition involves a
compromise between making files contiguous and filling [block] 
groups: some groups may simply contain far too many files for all those
files to be stored within a single group.  So, don't be too surprised if,
after defragmentation... a very few of your larger files still
are not entirely contiguous."

So, unless you really need that extra little bit of filesystem
performance, you don't need to defragment your ext2 filesystems.

If you're interested in reading more, look at:
http://www.penguin.cz/~mhi/fs/Filesystems-HOWTO/Filesystems-HOWTO-6.html
http://web.mit.edu/tytso/www/linux/ext2intro.html

-Matt Stegman
<[EMAIL PROTECTED]>

On Wed, 15 Mar 2000, Wayne wrote:

> Just a qucik non-help related email.  How does Linux deal with thinigs like
> fragmentation on your hard disks?  Does it suffer the same problems wind'ohs
> does or is this rectified by the FS itself or during boot?  I have looked for
> some docs but cant find anything about it.  Would appreciate any insight into
> the FS

Reply via email to