The ext3 filesystem now installs as the default file system in most Linux distributions. Essentially ext2 with journaling, ext3 retains the stability and robustness of ext2 while adding the much needed journal for high-availability. Part 1 of this article will discuss some filesystem basics and Part 2, some tips for working with the Linux native filesystems.
Inode Something You Don’t Node
Unix filesystems all share a few general traits:
EVERY FILE HAS AN INODE. Inodes are data structures that hold descriptive information about a file — file type, permissions, owners, timestamps, size, and pointers to data blocks on disk.
DIRECTORY TREE. The directories are structured in a hierarchical tree. Directories are files which contain a list of file names paired with inode numbers.
LINKS. Multiple file names can be associated with an inode. A hard link is a directory entry associating the inode with the new file name, a links count is is incremented in the inode each time this occurs. Symbolic links (or soft links) are just files which contain a filename (the path of the file being linked to.) Unlike hard links, they can point to any file, even a directory or a file which doesn’t exist.
DEVICE FILES. Devices, such as hard drives, are accessed via special files (eg. /dev/hda) which forward the request to the appropriate device driver.
Walk Around the Block Group
The ext* filesystems are made up of block groups, like so:
-------------------------------------------------------- Boot | Block | Block | Block | Block | AndSoOn | Sector | Group1 | Group2 | Group3 | Group4 | AndSoOn | --------------------------------------------------------
Here is the structure of a block group:
------------------------------------------------ Super | Filesystem | Block | Inode | Data | Block | Descriptors| Bitmap | Table | Blocks | ------------------------------------------------
Every single block group contains a copy of the superblock and filesystem descriptors. This makes it easy to recover a filesystem with a corrupted superblock.
Journalism 101
The ext2 and ext3 filesystems are identical except for the presence of a journal in ext3. A cleanly unmounted ext3 filesystem can be remounted as ext2. An ext2 filesystem can be upgraded to ext3 even while mounted. In a nutshell, the journal is a redo log of changes made to the filesystem. In a system crash, when the filesystem goes down before the sequence of changes is complete, the log can simply be replayed to fix resulting inconsistencies. Not only does this result in better file system integrity, but as anyone who has fsck’d a 100GB+ filesystem knows, the journal will save you hours of downtime. Ext3 also allows for three journal modes which can be specified as mount options, allowing some easy tuning depending on the useage and contents of the fs. We’ll discuss these mount options and other tools for Linux filesystems in Part 2 of this article.
SUGGESTED READING
Design and Implementation of the 2nd Extended Filesystem
Advanced filesystem implementor’s guide
Part 7
and Part 8
Linux Filesystem HowTo