Mass Storage & Disk Scheduling

wear leveling

Think of a flight of carpeted stairs. If everyone always steps on the exact same spot of each step, that spot wears bare in a year while the rest of the carpet stays new. A smart caretaker would gently nudge people to step in different places over time, so the whole carpet ages evenly and lasts far longer. Wear leveling does this for flash memory: it spreads writes across all the cells so no single cell is worn out long before the others.

Concretely, each flash erase block can survive only a limited number of erase cycles (perhaps a few thousand to tens of thousands) before it becomes unreliable. If the drive always reused the same physical pages for hot, frequently-rewritten data (say a file system's metadata), those cells would die quickly while most of the chip stayed pristine — and a drive is only as healthy as its weakest blocks. Wear leveling, run by the flash translation layer, deliberately rotates which physical blocks hold which data, even occasionally moving rarely-changed (cold) data to free up lightly-worn blocks for hot data, so that erase counts stay roughly balanced across the whole device.

Why it matters: wear leveling is the main reason modern SSDs last for years of normal use despite flash's limited write endurance. Without it, a drive could fail in months because a few hot spots burned out. But it is a balancing act with a cost: moving cold data around to even out wear is itself extra writing, contributing to write amplification. And it does not make flash immortal — it spreads a finite budget of writes evenly, buying longevity, but a drive hammered with writes will still eventually exhaust that budget.

A file system rewrites its small journal area constantly. Without wear leveling those few blocks would hit their erase limit and fail while the rest of a 1 TB SSD was barely touched. With it, the drive keeps shifting that hot journal onto fresh blocks, so the whole chip ages together.

Spreading writes evenly is what makes an SSD's life worthwhile.

Wear leveling postpones the end, it does not abolish it. Flash still has a finite total-write budget; the technique just ensures the whole drive reaches that limit together instead of a few cells failing early.

Also called
wear levelling耗損平均均勻磨損