Journaling file system

Also known as: journaling filesystem

On this page 7

A journaling file system is a file system that writes a description of each pending change to a dedicated log, the journal, before it modifies the main on-disk structures. After a power loss or crash, the system replays or discards journal entries instead of scanning the whole volume, which restores a consistent state in seconds.

In OS storage on desktop operating systems, journaling is the default design: NTFS on Windows, ext4 on Linux and the older HFS+ on macOS all keep a journal. The technique protects file system integrity, but it does not by itself guarantee that the contents of every file survive, and that distinction shapes how it is configured.

How a journaling file system keeps metadata consistent

A journaling file system treats each multi-step update as a transaction that must either complete fully or not at all. Creating a file, for example, touches the directory entry, the inode or Master File Table record, and the free-space bitmap. If power fails halfway, a non-journaled volume can be left with orphaned blocks or cross-linked files.

The journal follows the principle of write-ahead logging, borrowed from database systems. The process runs in a fixed order:

  1. The file system writes the intended changes to the journal.
  2. It writes a commit record that marks the transaction as complete.
  3. It applies the changes to their real locations on disk, a step called checkpointing.
  4. It marks the journal space as free for reuse.

At mount time after a crash, the system reads the journal. Committed transactions are replayed, and transactions without a commit record are ignored. Recovery time therefore depends on the size of the journal, typically tens to hundreds of megabytes, rather than on the size of the volume, which may be several terabytes.

Journaling modes and what they protect

Journaling modes differ in whether file data or only metadata passes through the journal. The choice is a direct trade-off between safety and write performance, because full data journaling writes every block twice.

ModeWhat is journaledCrash outcomePerformance cost
Journal modeMetadata and file dataMetadata and data consistentHigh, every block written twice
Ordered modeMetadata, with data written firstNo stale data in new blocksLow, the ext4 default
Writeback modeMetadata only, no orderingFiles may contain old or garbage dataLowest
Common journaling modes, using ext4 naming

Ordered mode is the practical default because it forces data blocks to disk before the metadata that points to them is committed. That prevents a recovered file from showing stale contents from deleted files, a real privacy and corruption risk in writeback mode.

NTFS journals metadata only through its $LogFile and relies on applications for data integrity. Apple File System (APFS) is not a classic journaling design: it uses copy-on-write, which never overwrites live metadata in place and so achieves crash consistency without a separate journal.

Journaling file systems on desktop platforms

Every mainstream desktop platform ships at least one journaled or crash-consistent file system for its system volume, while simple removable-media formats still lack one. The following table summarizes the formats a desktop user is most likely to meet.

File systemMain platformConsistency methodJournal scope
NTFSWindowsJournalingMetadata
ext4LinuxJournaling via JBD2Metadata by default, data optional
XFSLinuxJournalingMetadata
HFS+ (Mac OS Extended, Journaled)Older macOSJournalingMetadata
APFSCurrent macOSCopy-on-writeNot applicable
FAT32 and exFATRemovable mediaNoneNo journal
Crash-consistency approach of common file systems

The absence of a journal explains why FAT32 and exFAT drives often need a repair scan after being unplugged without ejecting, while an NTFS or ext4 system disk usually mounts cleanly after an abrupt shutdown.

Journaling compared with other crash-recovery approaches

Journaling is one of several techniques for crash consistency, and its main rivals are full consistency checks, soft updates and copy-on-write. Each places its cost at a different point in the life of a write.

ApproachCost during normal writesRecovery after a crashExample
No journal, full checkNoneSlow scan of the whole volumeFAT32 with chkdsk
JournalingExtra log writesFast replay of the journalNTFS, ext4
Soft updatesCareful write orderingFast, background cleanup of leaksFreeBSD UFS
Copy-on-writeNew block for each changeNear instant, last committed tree is validAPFS, ZFS, Btrfs
Approaches to keeping a file system consistent

Copy-on-write designs also enable cheap snapshots and checksums, which is why newer file systems favor them. Journaling remains attractive because it is mature, well understood and efficient on both hard disks and SSDs.

Limitations and common misconceptions

The most widespread misconception is that journaling prevents data loss. It guarantees that the file system structure is valid after recovery, but recently written data that sat in the page cache can still be lost, and a file may be truncated or partially updated.

  • Not a backup: journaling cannot recover deleted files or protect against disk failure.
  • Write caches can defeat it: a drive that acknowledges writes before they reach stable media can break ordering, which is why write barriers or cache flushes matter.
  • Applications still need fsync: a program that saves a document must flush it explicitly to make the data durable.
  • Silent corruption goes unnoticed: classic journaling does not checksum user data, unlike ZFS or Btrfs.
  • SSD wear concerns are overstated: metadata journaling adds only a small fraction of extra writes on modern drives.

Put simply

A journaling file system works like a careful accountant who writes each planned change in a notebook before touching the main ledger. If the lights go out mid-task, the accountant checks the notebook and either finishes the entry or crosses it out.

The result is that the disk stays orderly after a crash and starts quickly. It does not mean every unsaved document survives, so regular saving and backups are still necessary.

In practice

A video editor works on a Linux desktop with a 4 TB ext4 project drive in the default ordered mode. A storm cuts power while a render is writing a large output file and the project autosave is updating several small files.

On reboot, the kernel mounts the drive and replays the journal in about two seconds. No full disk check is needed, the directory tree is intact, and the free-space map is correct. The autosaved project, which the editor application had flushed with fsync, opens normally.

The partially written render file, however, is shorter than expected and unusable, because its data had not been flushed. The editor simply restarts that render. With a FAT-style drive of the same size, a full consistency scan could take many minutes and might still leave lost clusters to clean up.