During my daily browsing of the web, I read about a concept that I have never considered before: atomicity. This concept usually refers to database transactions and means that the transaction will either completely succeed or completely fail. Journaled filesystems make use of this system in the event of a crash. Before your computer commits data to the disc, it logs what it will do to a file, called a journal, before actually committing the change, called a transaction. If the computer crashes before it finishes writing the data to the disk then the log will be incomplete. When the computer restarts, the filesystem’s journal will be replayed; incomplete entries are ignored and reverted to the most recent complete entry. Thus, if the data was not written correctly and completely, it will not be written at all.
For more information:
http://donner.cs.uni-magdeburg.de/bs/lehre/wise0001/bs2/journaling/journal-design.pdf