Block layer ⚓

Our exploration of the Linux storage stack begins with the block layer.

A block device is:

  • Read/written in the units of blocks. Typical block sizes are 512 B, 1 k and 4 k, but other sizes are possible (subject to certain restrictions).
  • Random access: data can be accessed in any order, in roughly the same time. This is in contrast to so-called character devices, which represent a stream of data which can only be read and written in order.
    • Note “roughly”: on an HDD, the access time of a block will depend on the geometry of the disk, the location of the block, the current position of the read/write head and various intrinsic properties of the drive’s I/O scheduler.
  • Cached by the kernel in the page cache.

Page cache ⚓

The page cache affects the performance and durability characteristics of the block device.