Subject: RE: Fragmentation. (was: Change User Password and Fragmentation
To: Richard Rauch <rkr@rkr.kcnet.com>
From: Tim Rightnour <root@garbled.net>
List: netbsd-help
Date: 12/24/1999 09:00:56
On 24-Dec-99 Richard Rauch wrote:
> * What is fragmentation?  (You may know this already...but just in
>    case...)  Ideally, files are laid out in a manner convient for fast
>    reading (or perhaps rewriting) of successive blocks.

Actually this is a common misunderstanding in ffs derrived filesystems.  What
you described was dos fragmentation..  FFS fragmentation is far less annoying:

if you type disklabel wd0 (or whatevr your disk happens to be..you will see
something like:

#        size   offset     fstype   [fsize bsize   cpg]
  a: 17755481      133     4.2BSD     1024  8192    16   # (Cyl.    0*- 4944*)

where fsize = frag size, bsize = block size, and cpg = cylinders per group.

So.. In my case I have a 8k block..  That means that files are allocated in 8k
chunks.  Obviously this wastes a bit of space..  So ffs has block fragments.. 
Ie.. I have a 3k file.  This file will take a 3k fragment of another block.
(well.. it might actualy take a 4k fragment.. but...) This makes the remainder
of that block a fragment block, which can later be used to fill other
non-block sized requests.

So how do you get rid of fragmentation?  You don't.  Its really not harmful, as
the system was designed that way.  If you find that you are getting an overly
large number of fragments, perhaps your block size is just too big. 
Fragmentation doesn't really slow things down alot, as it would in dos, as the
filesystem is designed to keep blocks of a file close together.  There is
probably a very slight head seek when finding a frag block.. but its most
likely nothing to fret about.

If you really really want to see 0% fragmentation.. you can set your block size
and frag size the same.  Kiss alot of diskspace goodbye like that however.

---
Tim Rightnour <root@garbled.net>
NetBSD: Free multi-architecture OS http://www.netbsd.org/
NetBSD Mailing lists on the web: http://mail-index.netbsd.org/