Understand the securefs Full Format (Versions 1, 2, 3)
masterThe Full Format is designed for high security and randomized encryption.
Key characteristics:
- Identity: Every file, directory, or symlink is identified by a 256-bit ID generated by a CSPRNG. The root directory always has an ID of zero.
- Storage Model: Uses a pair of files in the underlying filesystem for every virtual file. The structure is similar to a
gitobject store. - Encryption: Data is divided into 4KiB blocks. Each block is separately encrypted and authenticated using AES256-GCM. A new IV/nonce is generated via CSPRNG for every block modification.
- Metadata: IVs and MACs are stored in an associated meta file. The meta file's integrity is protected by a leading HMAC-SHA256 of its remaining contents.
- Directory Implementation: Directories are implemented as normal files containing a B-tree rather than using the underlying filesystem's directory structure. This allows for randomized encryption while maintaining logarithmic access complexity ($O(\log n)$). The maximum filename length is 255.
- Version Differences:
- v1: Original format.
- v2 & v3: Use less paranoid parameters than v1.
- v3: Stores timestamps in the meta file (instead of relying on the underlying filesystem) to facilitate synchronization across cloud services.