File systems and journaling
In short: A file system organises how files and folders are stored on a storage device. Journaling file systems (ext4, NTFS) log changes so they stay consistent after a crash.
In more detail: The disk is divided into blocks. A structure (inode or MFT entry) describes each file: size, permissions, location of blocks. Directories are files that map names to these entries. In journaling a change is noted in the journal first and then carried out.
In Depth
- Inode: Metadata of a file, without its name. Names live in the directory (hence hard links).
- Journal: Metadata only or data as well. Protects against half-finished changes.
- Copy-on-write file systems (ZFS, Btrfs): Never write in place, snapshots almost free, checksums detect silent data errors.
- Fragmentation: Files split into pieces; uncritical on SSDs.
- Encryption and quotas: At file system or block level.
- FAT32/exFAT: Simple, compatible, for USB sticks; no journal, FAT32 max. 4 GB per file.
- fsync: Forces writing to the device, needed for durability.
See also: Write-ahead log and recovery, Virtual memory and paging