Journaling File System in Linux


You all must have heard a lot about Journal feature of ext3fs or ext4fs file system. You might have learned during your RHCE Training or RHCSS Training that journal feature is there with ext3fs and ext4fs file system.

Lets go deep inside the Journal feature and learn how it really help Linux system admin.

Lets understand first what happens to a Linux Box using a non-journaling file system shut down disgracefully. During this kind of even the OS detects this and performs a consistency check using the fsck utility. fsck scans the file system (can take a hell lot of time) and tries to fix any issues that can be safely corrected. In some cases, the file system can be in such bad shape that the operating system boots into single user mode to allow the user to further the repair process.

Waiting is the name of the game. 😦

Now here comes Journaling file system. Its actually for all those people who are sick of watching that boot time fsck running and time consumption. Journaling file systems are also for anyone who likes the idea of a fault-resilient file system.

Journaling file systems avoid file system crash or damage by maintaining a journal.

The journal is a special file that logs the changes destined for the file system in a circular buffer. At periodic intervals, the journal is committed to the file system. If a crash occurs, the journal can be used as a checkpoint to recover unsaved information and avoid corrupting file system metadata (something like snapshots of VM’s … hmmm).

To sum up, journaling file systems are fault-resilient file systems that use a journal to log changes before they’re committed to the file system to avoid metadata corruption.

You must be pleased to learn that you have more than one methods of Journaling, depending on your needs.

Three of the most common strategies for Journaling are writeback, ordered, and data.

1. Writeback mode – only the metadata is journaled, and the data blocks are written directly to their location on the disk. This preserves the file system structure and avoids corruption, but data corruption can occur (for example, if the system crashes after the metadata is journaled but before the data block is written).

2. Ordered mode – DEFAULT – Metadata journaling only but writes the data before journaling the metadata. In this way, data and file system are guaranteed consistent after a recovery.

3. Data mode – Both metadata and data are journaled. This mode offers the greatest protection against file system corruption and data loss but can suffer from performance degradation, as all data is written twice (first to the journal, then to the disk).

And you can use the “dumpe2fs” command to check the status of Journal on your file system. Here is a screenshot from my machine.

dumpe2fs in Linux

dumpe2fs in Linux

Connect with us on Facebook.