June 21, 2018

Exploring the ext3 Filesystem - page 2

Introduction to the ext3 Filesystem

  • April 5, 2002
  • By Bill von Hagen

Since the date in the distant past when computer systems first began to read and write from magnetic storage media, guaranteeing the consistency of the files and (later) directories on that media has been a thorn in the paw of system administrators and designers everywhere. At the system level, all of the data on a computer exists as data blocks on some storage device, organized using special on-disk data structures into partitions (logical subsets of storage media) which are themselves organized into files, directories, and unallocated (free) space.

Filesystems are created on disk partitions to enable applications to store and organize data in the form of files and directories. Linux, like Unix systems, uses a hierarchical filesystem composed of files and directories, which can contain either files or other directories. The files and directories in a Linux filesystem are made available to users by mounting them using the Linux "mount" command, which is generally done as part of a Linux system's startup process. The list of filesystems that are available for use is stored in the file /etc/fstab (which stands for filesystem table), while the list of filesystems that are currently mounted is maintained by Linux in the file /etc/mtab (which stands for mount table).

As each filesystem is mounted during the boot process, a bit in the filesystem header (popularly known as the "clean bit") is cleared, which indicates that the filesystem is in use and that the data structures used to manage allocation and file and directory organization in that filesystem may actively be changing.

Filesystems are referred to as being consistent when all data blocks in the filesystem are either used or free, each allocated data block is claimed by one and only one file or directory, and all files and directories can be access by traversing a series of other directories in the filesystem. When a Linux system is intentionally shut down using operator commands, all filesystems are unmounted. Unmounting a filesystem during a standard shutdown sets the clean bit in the filesystem header, indicating that the filesystem was cleanly umounted and can therefore be assumed to be consistent.

Years of filesystem debugging and redesign and the use of some extremely clever algorithms for writing data to disk have largely eliminated filesystem corruption caused by applications or the Linux kernel itself, but eliminating data corruption and loss due to power outages and other system mishaps is still the system programmer's equivalent of the search for the holy grail. When a Linux system crashes or is simply turned off without going through the standard shutdown procedure, the clean bit in filesystem headers is not set. The next time the system boots, the mount process detects filesystems that are are not marked as being clean, and manually verifies their consistency using the Linux/Unix 'fsck' (filesystem check) utility.

Most Popular LinuxPlanet Stories

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.