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
-
Fedora 39 Beta is Now Available for Testing
For fans and users of Fedora Linux, the first beta of release 39 is now available, which is a minor upgrade but does include GNOME 45.
-
Fedora Linux 40 to Drop X11 for KDE Plasma
When Fedora 40 arrives in 2024, there will be a few big changes coming, especially for the KDE Plasma option.
-
Real-Time Ubuntu Available in AWS Marketplace
Anyone looking for a Linux distribution for real-time processing could do a whole lot worse than Real-Time Ubuntu.
-
KSMBD Finally Reaches a Stable State
For those who've been looking forward to the first release of KSMBD, after two years it's no longer considered experimental.
-
Nitrux 3.0.0 Has Been Released
The latest version of Nitrux brings plenty of innovation and fresh apps to the table.
-
Linux From Scratch 12.0 Now Available
If you're looking to roll your own Linux distribution, the latest version of Linux From Scratch is now available with plenty of updates.
-
Linux Kernel 6.5 Has Been Released
The newest Linux kernel, version 6.5, now includes initial support for two very exciting features.
-
UbuntuDDE 23.04 Now Available
A new version of the UbuntuDDE remix has finally arrived with all the updates from the Deepin desktop and everything that comes with the Ubuntu 23.04 base.
-
Star Labs Reveals a New Surface-Like Linux Tablet
If you've ever wanted a tablet that rivals the MS Surface, you're in luck as Star Labs has created such a device.
-
SUSE Going Private (Again)
The company behind SUSE Linux Enterprise, Rancher, and NeuVector recently announced that Marcel LUX III SARL (Marcel), its majority shareholder, intends to delist it from the Frankfurt Stock Exchange by way of a merger.