Skip to main content

Source: Operating Systems: Three Easy Pieces (OSTEP) — Chapter 37, Arpaci-Dusseau & Arpaci-Dusseau

Hard Disk Drives

Hard drives were the main persistent store for decades; file-system design still leans on their behavior [RW92, ADR03].

Crux: how do HDDs store and access data? What is the interface? How does scheduling help?

Interface​

A drive is an array of sectors (classically 512 B), addressed 0 … n−1. Multi-sector I/O is common (e.g. 4 KB FS blocks), but manufacturers typically guarantee atomicity only for a single sector — larger writes can be torn on power loss.

Unwritten contract [SG04]: nearby LBAs are faster than distant ones; sequential access is fastest.

Geometry​

PieceRole
Platter / surfaceMagnetic media (often 2 sides per platter)
SpindleSpins at fixed RPM (e.g. 7.2K–15K)
TrackConcentric ring of sectors
Head / armSense or write magnetism; seek across tracks

I/O time: seek → rotational delay → transfer.

Seek phases: accelerate, coast, decelerate, settle (often 0.5–2 ms). Track skew keeps sequential I/O from missing the next sector after a track switch. Multi-zone disks put more sectors on outer tracks. On-drive cache (track buffer): reads may prefetch a track; writes may be write-back (fast, risky for ordered durability) or write-through.

Quiz

Rank the sequence

1 / 1

Order the phases of a disk arm seek (top = first).

OrderDrag the handle to rearrange — top should be first.

  1. 1Settle
  2. 2Decelerate
  3. 3Coast
  4. 4Accelerate

Drag items into the correct order (or use ↑↓), then check.

Doing the math​

T_I/O = T_seek + T_rotation + T_transfer
R_I/O = Size / T_I/O

Dimensional analysis helps: 10K RPM → 6 ms/rotation; half-rotation average ≈ 3 ms at 10K, 2 ms at 15K.

Random vs sequential (Cheetah- vs Barracuda-class numbers in the text): random 4 KB may be ~0.3–0.7 MB/s; sequential approaches ~100+ MB/s — often 200–300× apart.

Use disks sequentially

Prefer sequential transfers, or at least large contiguous chunks. Tiny random I/O destroys performance.

Average seek distance over all track pairs ≈ ⅓ of a full stroke (geometry integral) — that is where the “one-third” lore comes from.

Disk scheduling​

The scheduler estimates positioning cost and approximates SJF.

PolicyIdeaCaveat
SSTF / NBFNearest track / nearest LBA nextStarvation of far requests
SCAN / C-SCANElevator sweeps (F-SCAN freezes queue)Fairer; still weak on rotation
SPTF / SATFMinimize seek + rotationNeeds geometry; often inside the drive

Modern OS: pick a window of good requests, merge adjacent LBAs, let the drive’s SPTF finish. Sometimes wait briefly for a better request (anticipatory, non-work-conserving) [ID01].

Quiz

Rank the sequence

1 / 1

Order the steps of servicing a disk I/O request (top = first).

OrderDrag the handle to rearrange — top should be first.

  1. 1Seek the arm to the target track
  2. 2Issue the request to the drive
  3. 3Transfer the data
  4. 4Wait out the rotational delay to reach the target sector

Drag items into the correct order (or use ↑↓), then check.

Interactive​

Try: geometry · I/O time · SSTF / SCAN / SPTF.

Check your understanding​

Quiz

Hard disk drives

1 / 6

Drive manufacturers typically guarantee atomicity for…

Pick an answer to see if you are right.

Coding challenges​

Homework lab: disk.py​

Use the OSTEP disks homework (disk.py + animator).

Lab

Homework: file-disks / disk.py

0/5 started

Loading lab…

Summary​

IdeaTakeaway
Sector arrayLinear LBAs; sequential/nearby assumed fast
MechanicsSeek + rotate + transfer
WorkloadsRandom ≪ sequential (huge gap)
SchedulersSSTF → SCAN (fairness) → SPTF (rotation); merge + drive-internal reorder

Previous: I/O Devices

Next: RAID — striping, mirroring, parity.

Further Reading​