Life and times of the classic ext Linux filesystem
Superpowers
For an ext filesystem to be able to organize itself, it keeps a record of some important configuration parameters and current states. This information lives in the superblock, which always follows the first 1024 bytes of a storage medium (Figure 2).
This fixed position is important, for example, for the mount operation or for checking the filesystem. Among other things, the superblock contains the following:
- the exact block size
- the number of blocks and block groups
- the number of free and used inodes
- the date of the last successful mount
- the last change date
- the name of the operating system that created the filesystem
- the current state of the filesystem.
The superblock is more or less the heart of the ext filesystem. To avoid damage to the superblock that could destroy the filesystem, ext2 creates several copies of the superblock distributed across block groups. For repairs, tools rely on these backup copies.
Each block group has a group descriptor that holds some information about the block group. For security reasons, all block groups store all group descriptors of the ext filesystem.
Additionally, each block group contains inode and block bitmaps. These bitmaps act as registers that list all the inodes and blocks of each block group. A bit with a value of 0
marks an inode or block as free; a value of 1
indicates an occupied inode or block. A bitmap must always fit in one block, which also limits the size of a block group.
Storage in Action
If you create a new file or folder on ext2, the filesystem first makes a decision on the exact storage location. For an empty filesystem, the data could theoretically end up anywhere, but for performance reasons, it makes sense to store contiguous data as close together as possible. Ext2 thus tries to put subfolders and files in the block group in which the directory that holds them resides. The filesystem assumes that this data is related and the system will retrieve it, in quick succession if necessary. If the block group fills up, ext2 is forced to divert to another location. To determine which blocks and inodes are usable for storage, ext2 looks at the inode and block bitmaps.
Good References
Ext2 also introduced support for symbolic links, or symlinks for short. A symlink is a special type of file that only contains a reference to another file or directory instead of data. In contrast to hard links, Symlinks point to targets on all filesystems, not just their own.
Unlike hard links, you can recognize a symlink. Applications that access the files or folders hiding behind symlinks treat them as ordinary files. But when it matters, such as when creating backups, a program needs to handle a symlink separately.
Symlinks exist independently of the target. If you delete the file that is referenced by a symlink, the link will remain – after all, it is a separate file with its own inode. The potential downside: If you change the name or location of a file, you also need to modify the symlink accordingly.
The filesystem stores all symlinks fewer than 60 bytes in size directly in the associated inode. Storing the symlink in the inode avoids the association of a separate block in the ext2 filesystem. (Actually, this same procedure is also used for normal files: If the content of a file takes up fewer than 60 bytes, the filesystem writes the data directly to the associated inode as "inline data.")
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.