Skip to content

SYSTEM Cited by 1 source

Linux Device Mapper (DM)

The Linux Device Mapper is the kernel block-layer proxy mechanism that lets targets interpose on struct bio — the main unit of I/O for the Linux block layer — and either dispatch it, drop it, or mutate it and ask the kernel to resubmit. It's the backend for userland LVM2 and the substrate on which a long list of targets are built:

  • dm-linear — carve one big device into smaller ones.
  • dm-stripe — combine smaller devices into one striped device.
  • dm-raid1 — software RAID mirroring.
  • dm-snap — snapshots of arbitrary devices.
  • dm-verity — cryptographic verification of boot devices.
  • dm-clone — block-level async clone.
  • dm-crypt — full-disk encryption.

Why it looks like a network protocol

The 2024-07-30 Fly.io Making Machines Move post frames the block layer as "organized as if your computer was a network running a protocol that basically looks just like that" — a struct bio carries an opcode (read, write, flush, discard, secure erase, write-same, write-zeroes), a device, and a page/len/offset vector. DM targets plug into this bio stream the way a proxy plugs into a network protocol. "No nerd has ever looked at a fixed-format message like this without thinking about writing a proxy for it, and struct bio is no exception. The proxy system in the Linux kernel for struct bio is called device mapper, or DM."

Composition

DM targets can stack on top of each other. Fly's fleet stacks DM like this on the target worker during a migration:

  1. Source Volume mounted over the network via iSCSI appears as a block device.
  2. dm-crypt wraps it to produce the plaintext view.
  3. dm-clone takes that plaintext source device + a fresh local target device + a metadata device, and presents the cloned plaintext volume.
  4. The new Fly Machine mounts the cloned plaintext volume.

Seen in

Last updated · 200 distilled / 1,178 read