Disk Tutorial

Disk Tutorial

A separate Alquist series for building a real disk stack: MMC hardware, partitions, FAT32 read-only, file loading, ext4, journaled writes, diagnostics, and flash storage.

The Kernel Tutorial grew the machine from first blink to user programs. Storage deserves its own lane. This is not a throwaway demo path: each chapter grows a professional program-driver in small, testable steps, with a clear read-only phase before any write path is allowed near real media.

Shape of the work

The disk stack is split into a small universal core and filesystem-specific modules. The universal core owns the hardware driver, block reads, partition tables, partition devices, request pacing, and shared diagnostics. Filesystem modules own their own on-disk formats: FAT32 first, then ext4, and later flash filesystems. The shell talks to the disk program; the disk program talks to the right module for the selected partition and filesystem.

The safety ladder is explicit: read-only on real SD media, writes only on disposable images, then journaled writes with background diagnostics before writes are trusted on real devices.

The series

Long-term contract

The end goal is a complete storage subsystem, not a collection of UART tricks. Early chapters are small because the system is learning the vocabulary of disks: cards, sectors, partitions, directories, files, caches, metadata, failure modes. Later chapters use that vocabulary to build write paths, journal replay, fsck-style repair, and background diagnostic programs without changing the public shape of the disk stack.