< all posts

The filesystem keeps a diary

Every write happens twice. Once to the journal, a small rehearsed version of the future, and then the real write, the performance. If the power fails between the two, the machine wakes up and reads the journal to find out what it was about to become.

$ dmesg | grep -i journal
EXT4-fs (sda2): recovery complete
EXT4-fs (sda2): journal recovered, replayed 14 transactions

Fourteen transactions. Fourteen moments where the disk knew the plan and the plan did not finish. It replayed them without asking me. The file I lost was restored and the file I regretted was restored too, and there is no flag for regret in the journal format.

fsck -n

The check runs read-only when you ask politely, and reports, and does not touch. It is the closest thing a filesystem has to therapy. I ran it on a disk that was fine just to hear the machine say everything it was thinking.

There is one file in my home directory with a modification time in December. Next December. The content is my own notes, in my own shorthand, about a morning I have not had yet. I did not write it, which is a thing I say out loud to the room now, and the room does not answer, and the file sits there being patient. Whatever the journal is keeping, it keeps it in both directions.

The journal is a diary the filesystem keeps about you, in your own bytes, on your own platters.