A journaling file system is a file system that logs changes that you make to a ‘journal’. The journal itself is like a circular log that tracks, records and maintains the changes it is going to make ahead of time and places them in a separate area of the file system on your hard drive.
How does the journal see into the future to write the changes you ask? well it doesn’t. The changes are stored in the journal before the data is actually written to the file. Once the journal receives the data, the file system will then write the data to the file on the drive. This only takes place after the writing of the data to the journal is complete.
The journaling file system began as a way to overcome issues with data corruption after a crash. In the event of a system crash or power failure, instead of doing a lengthy filesystem check, it reads the contents of the journal to make sure that the files are in a state that they are supposed to be in, so they can be re-written to the drive and the file system brought back online quicker with a less likelihood of corruption.
It will replay the changes from this journal until the file system is stable and consistent again. The changes are considered to be “indivisible”, which means that either the files, when replayed from the journal:
– succeed; which means the changes have successfully been stored and can be replayed completely from the original during recovery or
– are not replayed at all; they are skipped because they had not yet been completely written to the journal.
Some file systems allow the journal to grow, shrink and be re-allocated just as a regular file would; most however, put the journal in a contiguous area or a special hidden file that is guaranteed not to move or change size while the file system is mounted.
The main objective of a journaling filesystem is one simple thing: availability. With ext3, the user gets this. A robust and fast filesystem with a minimum of downtime. There is one disadvantage with a journaling filesystem, when files are deleted they are for all intents and purposes, unrecoverable.
All in all, a journaling filesystem is a brilliantly thought out idea, bringing together robust stability and reliability in a fast, scalable system.