File System Component  Version 6.15.3
MDK Middleware for Devices with Flash File System
Journaling for the FAT File System

The File System Component supports a proprietary journaling mechanism for FAT which makes file I/O functions robust against system crashes or power failures. When FAT Journaling is enabled, the file allocation table and directory entries are protected.

FAT Journaling keeps track of the changes in the file system using a journal before committing them to the main file system. In the event of a system failure, file system does not become corrupted. Only content of files that are opened in writing mode may be lost. Other files are not affected.

Journaling can be enabled individually for each drive that is using the FAT File System. For information on how to enable Journaling refer to:

System Initialization and Drive Formatting

There requirements for creating a journal are:

  • the drive must be formatted with two FAT tables (two consecutive tables in the FAT section of the drive)
  • the drive must have at least 64 sectors (= 32kB) of contiguous free space at the end of a partition (in the last 1% space).

If journaling is enabled, mounting a drive triggers the File System to search for the journal.

When journal is found the journaling system is initialized and the journal content is checked for any incomplete data transactions that may be the result of a system crash. When incomplete data transactions are found the file system restores the drive to the last known valid state.

When no journal is found, the journal is automatically created. The required space (32kB) for journal is reserved by marking the adequate amount of clusters in the last 1% of the drive partition. This reduces the reported amount of free space on the drive accordingly.

No special drive formatting is required. When a drive is formatted on a different computer (running Window or Linux) free space is typical available at the end of a partition. Creation of a journal may fail on removable media when above requirements are not meet. This may happen if the drive is fragmented or there is not enough space. In this case the drive should be defragmented or some files should be deleted.

When using the fformat function of the File System Component, the journal is automatically created on drives with enabled option "Use FAT Journal".

System failure behavior

When File System Component experiences a power loss or crashes before a file opened for writing is successfully closed the content of that file is lost. This results in lost data clusters which can be restored using a file system repair utility tool such as chkdsk on Windows or fsck on Linux.