How UNIX systems maintain files and filesystems
Filesystem data is not stored on the hard disk
in locations that correspond to individual files.
On the contrary, the data is probably scattered across the disk.
The data is spread around because the operating system
does not really deal with files, but rather with units of data.
For example, when you create a file,
it might be stored on one part of the disk.
If you edit that file and delete a few sentences here and there,
you now use less disk space than you did before.
This space amounts to a series of gaps in the area where your file was stored.
Because disk space is a precious commodity,
the system allocates those small amounts of disk space to other files.
Each filesystem contains special structures that allow the
operating system to access and maintain the files and data
stored on the filesystem:
Several configurable filesystem mechanisms affect how transactions
are managed and committed.
Some involve tradeoffs in performance against data integrity,
others tradeoff performance against system recovery time.
A ``block'' is a 1024-byte unit of data stored on the disk.
A data block can contain either directory entries or file data.
A directory entry consists of an inode number, a filename,
and a version number for
An ``inode'' (information node) contains all the
information about a file (except file data),
including its location, size, file type, permissions, owner,
and the number of directory entries linked to the file.
The inode also contains the locations of all the data that make up a file
so the operating system can collect it all when needed.
The only information the inode does not contain
is the name of the file and the contents;
directories contain the actual filenames.
One special data block, the ``superblock'',
contains overall information about the filesystem,
just as the inode contains information about a specific file.
The superblock contains the information necessary to
mount a filesystem and access its data,
including the size of the filesystem, the number of free inodes,
and information about free space available.
When the filesystem is mounted, the system reads information
from the disk version of the superblock into memory.
To minimize seeking data on the hard disk,
recently used data blocks are held in a cache of special memory
structures called ``buffers''.
Buffers make the operating system more efficient.
Depending on the filesystem type and the setting of kernel parameters,
the buffer cache is ``flushed'' (written to the disk)
at set intervals.
When this feature is enabled, filesystem transactions are recorded in
a log and then committed to disk.
This increases system recovery speed with a very small
When enabled, each filesystem is marked clean at regular intervals.
If a filesystem is clean when the system halts, it will not be
necessary for it to be checked by fsck.
Like intent logging (which works in tandem with checkpointing),
there is a small performance penalty.
Maintaining free space in filesystems
filesystem check Phase 3
© 2007 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 05 June 2007