Arno said:
I think thats something different. Otherwise allmost every
file would be reported as fragmented, not the 1-2% I typically
see on a filesystem check.
I'm going on memory here from stuff I've read years ago, so my numbers
and terminology might be a little imprecise. Also I read this stuff on
Solaris's UFS, but it's probably valid for most Unixes, including Linux.
An Unix filesystem is usually subdivided into fixed-length regions known
variously as superblocks or extents or whatever. For example, let's say
a 1TB file system might be subdivided into extents of 1GB, for
simplicity. Each extent is further subdivided by inodes, which use up
the extents by arbitrary lengths. Now, there is one inode per file per
extent.
Usually, the inodes are just the metadata of the files, containing a
bitmap of which sectors in an extent a file occupies. But the inodes
take up a bit of space themselves, usually a fixed size of a few
kilobytes. If a file is small enough, then instead of allocating a
bitmap for it, then they just stuff the file itself into the inode.
These inodes can be pretty big, like maybe in the range of 1K upto 32K,
so why allocate a whole bitmap for a file that maybe smaller than the
inode?
A file that's big enough may need to span over multiple extents. If the
final leftover data of the file is bigger than an inode can hold, then
they'll just open another bitmap inode for the last extent. If the
leftover data is small enough to fit inside an inode, then they'll stuff
the leftover into the inode. That's what they call a fragmentary inode,
or fragment in Unix. I believe that whether an inode is a bitmap or a
fragment or something else is determined by its header.
Really small files that reside entirely in a single inode are not
considered fragments. Only those big files that reside over multiple
extents and finish in a fragmentary inode are considered fragmented.
Another thing, big files that reside over multiple extents are not
necessarily in adjoining extents, each of the extents can be scattered
anywhere on the disk. So even if the extents aren't right next to each
other, then these files aren't considered fragmented. They don't worry
about the whole-disk fragmentation, just the fragmentation within extents.
Yousuf Khan