A deep technical design document for littlefs, a fail-safe filesystem built for microcontrollers with limited RAM and NOR flash storage. It explains the three core requirements: power-loss resilience, wear leveling, and bounded RAM/ROM usage. The design combines two-block metadata pairs (small circular logs providing atomic updates) with CTZ (count-trailing-zeros) skip-lists as a COW data structure for compact file storage. Metadata pairs handle atomic commits via append-then-compact cycles, splitting at 50% capacity to maintain O(1) amortized cost. CTZ skip-lists enable O(1) appends and O(n log n) reads with only 2 pointers of overhead per block. Block allocation uses a lookahead bitmap instead of a persistent free list, avoiding consistency issues under power loss. Wear leveling is handled by distributing writes across blocks and detecting/relocating bad blocks during write-verify cycles. ECC is left to the block device layer.