Basic File Systems on Linux: ext2, ext3, ext4, jfs & xfs
The original Linux system uses a simple file system that is similar in functionality to the Unix file system. In this article, we will discuss the basic file systems used in Linux.
Ext File System
This file system, which goes into use with the Linux operating system, is called extended filesystem or ext. It provides a Unix-like file system for Linux, virtual directories are used to process physical devices, and data is stored in blocks of a certain length on physical devices.
The ext file system uses a system called inode, which provides trace information about files stored in the virtual directory. The inode system creates a separate table on each physical device to store file information, and this is called the inode table. Each file stored in the virtual directory has an entry in the inode table. The extended word in the name of this file system type is due to the additional data listed in each file, listed below:
Filename
File size
The owner of the file
The group to which the file belongs
Access permissions for the file
Pointers to each disk block containing data from the file
Linux marks each inode in the inode table using a unique number (inode number) assigned to create data files by the file system. The file system uses the inode number rather than the full filename and path to identify a file.
Ext2 File System
The original ext file system restricted the file size to 2GB. It was not long since the announcement of Linux that the ext file system was upgraded to the second extended file system, ext2.
As you can imagine, the ext2 file system is an extended version of the ext file system's basic capabilities; but it maintains the same structure. The Ext2 file system extends the inode table format about each file in the system to trace callout.
The Ext2 inode table contains the values for creation, modification, and last access time for files to help the system administrator to access files on the system. The maximum allowable file size in the ext2 file system is 2TB (Up to 32 TB increase in subsequent versions of ext2.). In this way, it helps to adapt to large files that are frequently found in the databases of the servers. In addition to the expansion of the İnode table, the ext2 file system has also changed how files are stored in data blocks. The common problem with the Ext file system was that the blocks used to store data as a file was written to the physical device tend to spread across the device (called fragmentation). Fragmentation of data blocks can reduce the performance of the file system while accessing all blocks takes a long time to search the storage device for a particular file.
The Ext2 file system helps reduce fragmentation by splitting disk blocks into groups when you save a file. When data blocks are grouped for a file, the file system does not have to search all data blocks on the physical device to read a particular file. The Ext2 file system has been the default file system for many Linux distributions for many years, but it also had its limitations. In addition to its nice feature such as providing additional information about files to trace the file system, İnode table could create serious problems for the system. Every time the system updated and stored a file, it had to change the inode table according to the new situation. The problem is that this process is not always fluid.
If something happens to the system on the computer while storing the file and updating the inode table, both will be incompatible. The Ext2 file system is already famous for its corruption due to system crashes and power outages. If the inode table entry is not completed even if the data file is properly stored on the physical device, the ext2 file system will not even know that such a file exists! For these reasons, the developers searched for a different Linux file system.
Logging File Systems
Logging file systems provide a new level of security to Linux. Instead of writing data directly to the storage device and then updating the inode table, these file systems initially write the changes to the file in a temporary file (called journal). After the data is successfully written to the device and the inode table, the journal entry is deleted.
If the system crashes or a power outage before writing to the storage device, the logging file system only reads the journal file and no unprocessed data remains in the process.
There are three different logging methods commonly used in Linux, each providing a different level of protection. These are shown in the table below.
Logging File System Methods
method Description
Data mode Both inode and file data are logged. Data loss probability is very low, but my performance is also low.
Regular mode Only inode data is written to the log; however, the data is not deleted until it is successfully written. A good combination of performance and security.
Rewrite mode Only inode data is written to the log, no control is made when file data is written. High risk of data loss but still better than not using logging.
Limitations
The data mode update method is a much safer data protection method; but it is also the slowest. All data written to the storage device must be written twice, first logged, and then to the current storage device. This can cause poor performance, especially in systems that write a lot of data. Over the years, many logging file systems have appeared in Linux. The following sections will describe the Linux logging file systems commonly used.
Extended Linux Logging File Systems
The same team developing ext and ext2 file systems created logging versions of these file systems as part of the Linux project. Logging file systems are compatible with ext2 and it is easy to go back or forth between them. Currently, there are two separate logging systems based on the ext2 file system.
Ext3 File System
The Ext3 file system was added to the Linux kernel in 2001 and was the default file system used by almost all Linux distributions until recent years. It uses the same inode table structure just like the ext2 file system, but adds a logging file to each storage device to log data written to the storage device.
By default, the ext3 file system uses the edited mode of logging, writes only inode information to the log file, and does not delete this information until data blocks are successfully written to the storage device. You can also change your logging method used in the ext3 file system to one of the data or write back modes while creating your file system with a simple command-line operation.
The Ext3 file system still had a few shortcomings when it was added to the basic logging of the Linux file system. For example, the ext3 file system does not have a recovery mode for accidental deletion of files, there is no existing embedded data compression feature (there is a patch that is installed separately and provides this feature only), and the ext3 file system does not support encryption of files. For these reasons, the developers have chosen to continue working on the issue of upgrading the ext3 file system.
Ext4 File System
As a result of the expanding ext3 file system (as you can imagine) ext4 has emerged. The Ext4 file system was officially supported in the Linux kernel in 2008. Now it is the default file system on the most used Linux distributions such as Fedora and Ubuntu.
In addition to compression and encryption support, the ext4 file system also supports a feature called extent. The skin allocates blocks in the storage device in blocks and stores it only in the starting position block in the inode table. This process helps to save space without having to list all the data blocks used for storing data from the file.
The Ext4 file system allows block allocation in advance. If you want to reserve a place on a storage device for some time that you can increase its size, it is possible to reserve all the expected blocks for not only physically existing blocks, but also the file. The Ext4 file system fills the allocated data blocks with zeros and knows that they should not be split into other files.
Reiser File System
In 2001, Hans Reiser created the first logging file system for Linux, which he called ReiserFS. The ReiserFS file system only supports write-back logging mode, it only writes the log file to the inode table data. The ReiserFS file system is one of the fastest logging file systems in Linux since it only writes inode table data to the log.
One of the two interesting features combined with the ReiserFS file system is the ability to resize a file system while it is still active. The other is also known as the Tailpacking technique, it fills the data from one file to another in the space in a data block. The effective file system resizes feature is an excellent feature to expand to place more data on the file system you have already created.
Logging File Systems (JFS)
Probably the oldest logging file system circulating around is JFS (Journaled File System) developed by IBM for AIX, which resembles Unix. However, it was not the second version until it was moved to the Linux environment.
Note: The second version of JFS under the name IBM is JFS2; however, most Linux systems also call JFS2 just as JFS.
JFS file system uses a regular logging method, it only stores inode table data in the log, but it does not remove the updated file data until it is written to the storage device. This method is a compromise between the speed of ReiserFS and the robustness of the data mode logging method.
The JFS file system uses overlay-based file sharing, allocating a group of blocks for each file written to the storage device. This method results in less fragmentation in the storage device. Apart from the release of IBM Linux, the JFS file system is not widely used; but you can come across your Linux surfing. Also, you can follow me on IBM community.
XFS File System
The XFS logging file system is actually a file system designed for a commercial Unix system whose path passes through the world of Linux. Silicon Graphics Incorporated (SGI- Silicon Graphics Corporation) originally created the XFS file system in 1994 for its own IRIX Unix system. In the Linux environment, it started to show up in 2002.
The XFS file system uses rewrite mode logging, this method provides high performance but also brings some risk because the current data is not recorded in the logging file. The XFS file system offers the ability to resize the file system online, similar to the ReiserFS file system, except that XFS file systems can only be expanded but not collapsed.