LearnViz CompSci
Home / Learn / Operating Systems / Journaling File Systems

Advanced Topic 39 of 51 Operating Systems

Journaling File Systems

File systems logging changes to recover after crashes.

How it works

A journaling file system records intended changes to metadata, and optionally data, in a log called the journal before applying them to the main structures. After a crash or power loss, it replays or discards the journal entries to restore consistency quickly instead of scanning the whole disk with fsck. Modes include writeback, ordered and full data journaling, with different safety and performance trade-offs.

Step-by-step walkthrough

  1. The application changes a file.
  2. The change is first written to the journal and committed.
  3. Then it is applied to the main file system.
  4. After a crash the journal is replayed.
  5. The file system returns to a consistent state without a long scan.

Where it is used

ext3, ext4, NTFS, XFS and JFS use journaling to protect against corruption. Databases use the same write-ahead logging idea.

Common pitfall

Journaling protects file-system consistency, not necessarily the contents of your latest writes, unless full data journaling or fsync is used. Disk caches that lie about flushes can defeat it. Journal writes add overhead, and a small or corrupted journal limits recovery. Copy-on-write file systems such as ZFS and Btrfs take a different approach.

Where it fits in the course

Journaling File Systems is topic 39 of 51 in Operating Systems, rated Advanced. It follows File Allocation Methods. The next topic is Disk Scheduling.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Operating Systems quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Journaling File Systems?
File systems logging changes to recover after crashes. It belongs to Operating Systems and is an advanced-level topic.
Where do people use Journaling File Systems?
ext3, ext4, NTFS, XFS and JFS use journaling to protect against corruption.
What is the most common mistake with Journaling File Systems?
Journaling protects file-system consistency, not necessarily the contents of your latest writes, unless full data journaling or fsync is used.
What should I learn before this topic?
Start with File Allocation Methods, the topic just before it in Operating Systems.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Operating Systems quiz.
Is Journaling File Systems hard to learn?
It is an Advanced topic. Expect to read the explanation more than once and to connect it with earlier topics. Working through a small example by hand helps most.
How long does it take to learn Journaling File Systems?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Journaling File Systems?
File Allocation Methods, Disk Scheduling, Directory Structures are closely connected. The full list is in the related topics section of this page.
What should I study after Journaling File Systems?
Continue with Disk Scheduling, the next topic in Operating Systems.

Related topics