Linux is a Unix-like operating system which was implemented first as an extension to the Minix operating system. However, the restrictions in the design of the Minix filesystem were too limiting and a new filesystem, called the Extended File System or ext, was implemented in April 1992.
In 1993, it was superseded by both the Second Extended File System or Ext2 and xiafs, which competed for a time, but ext2 won because of its long-term viability.
The third Extended File System or ext3 was introduced in November 2001 with Linux 2.4.15. Ext3 supports the same features as Ext2, but also included journaling. This was further superseded by Ext 4 in 2008.
Basic Concepts
Inodes
It is Short for index-node. Each file is represented by a structure, called an inode. An inode is a 256-byte block on the disk that stores data about the file. This includes the file’s size; the user IDs of the file’s user and group owners; access permissions; and three timestamps specifying the time and date when the file was last accessed, last modified, and the data in the inode was last modified.
The inode also contains data that points to the location of the file’s data on the hard drive.
Directories
Directories are structured in a hierarchical tree which can further contain files and subdirectories. A directory is simply a file containing a list of entries. Each entry contains an inode number and a file name.
Links
Several names can be associated with an inode. Adding a link simply creates a directory entry, where the inode number points to the inode.
A symbolic link is a way to create a named entity in the file system that simply refers to another file; that is, a symbolic link is a named entity in a directory, but instead of the associated i-node referring to a file, the symbolic link contains the name of another file that should be opened.
Another form of link is known as a hard link. With a hard link, a named entity in a directory simply contains the i-node number, instead of a name, of some other file instead of its own i-node.
Ext2
The Second Extended File System has been designed and implemented to fix some problems present in the first Extended File System. The ext2 file system simply divides the disk into fixed-size block groups, each of which appears as a miniature file system.
The first block in any Ext2 partition is never managed by the Ext2 filesystem, since it is reserved for the partition boot sector. The rest of the Ext2 partition is split into block groups and each block group contains one of the following pieces of information:
• A copy of the filesystem’s superblock – contains the metadata that defines the other filesystem structures and locates them on the physical disk assigned to the partition.
- A copy of the group of block group descriptors – contains information on block bitmap, node bitmap and node table.
- A data block bitmap – to keep track of the used and free data blocks within the filesystem.
- A group of inodes – Each inode contains information about one file, including the locations of the data blocks, i.e., zones belonging to the file.
- An inode bitmap – determines which inodes are used and which are free within that group, including the locations of the data blocks belonging to the file.
• A chunk of data that belongs to a file; i.e., a data block
However, one of the biggest problems with the ext2 filesystem, was that it could take many hours to recover after a crash because the fsck (file system check) program took a very long time to locate and correct any inconsistencies in the filesystem.
Ext3
Ext3 (the third extended filesystem) is the most commonly used filesystem on Linux. It is basically an extension of ext2 to which a journaling capability has been added.
A journaling filesystem is a filesystem that maintains a special file called a journal that is used to repair any inconsistencies in the filesystem that occur as the result of an unclean shutdown of a computer and thus always maintains an internal consistency. Such shutdowns are usually due to an interruption of the power supply or to a software crash that cannot be resolved without rebooting.
The rest of the disk structure is the same as it was in ext2.The only addition to the ext3 filesystem was the journal, which records in advance the changes that will be performed to the filesystem. Thus, instead of writing data to the disk’s data areas directly, as in previous versions, the journal in ext3 writes file data, along with its metadata, to a specified area on the disk.
Once the data is safely on the hard drive, it can be merged in or appended to the target file with almost zero chance of losing data. On the next boot, the filesystem will be checked for inconsistencies, and data remaining in the journal will then be committed to the data areas of the disk to complete the updates to the target file.
Ext3 offers three different journaling modes:
- Journal: All file system data and metadata changes are logged into the journal. This mode minimizes the chance of losing the updates made to each file, but it requires many additional disk accesses. This is the safest and slowest Ext3 journaling mode.
- Ordered: Only changes to filesystem metadata are logged into the journal. However, the Ext3 filesystem groups the metadata and relative data blocks so that data blocks are written to disk before the metadata. This way, the chance to have data corruption inside the files is reduced. This is the default Ext3 journaling mode.
- Write back: Only changes to filesystem metadata are logged; this is the method found on the other journaling filesystems and is the fastest mode.
Ext4
The EXT4 filesystem primarily improves performance, reliability by adding metadata and journal checksums, and capacity. Furthermore, in order to meet various mission-critical requirements, the filesystem timestamps were improved with the addition of intervals down to nanoseconds.
In Ext4, data allocation was changed from fixed blocks to extents. An extent is described by its starting and ending place on the hard drive. This makes it possible to describe very long, physically contiguous files in a single inode pointer entry, which can significantly reduce the number of pointers required to describe the location of all the data in larger files.
Furthermore, in order to reduce performance difficulties due to fragmentation (when a collection of data in storage is broken up into many pieces that are not close together), the block allocator tries very hard to keep each file’s blocks within the same group, thereby reducing seek times (time taken for a hard disk controller to locate a specific piece of stored data).
Leave a Reply