Magnetic Disks

A hard disk drive keeps programs and files with the power off, and costs little per gigabyte. Bits are stored as magnetized regions on spinning platters. The price is speed: a read from main memory takes about 100 ns, a read from a hard drive about 10 ms. Almost all of that time is spent moving parts. This page shows where it goes.

RPM

What you are looking at

A hard drive with its lid off. Three platters sit on one spindle, and a motor spins them all together. Each surface is coated with magnetic material and has its own read/write head. The heads hang from an arm comb on a pivot, so they all move together. A voice coil on the tail of the comb swings it in and out.

The top platter shows its layout. The rings are tracks, 8 here, track 0 outermost. Each track is cut into 16 sectors. A sector is the smallest thing the drive reads or writes, 512 bytes here, 4096 on most drives made since 2011. Sector 0 starts at the dark mark on the edge. The same track on every surface is a cylinder: all of it can be read without moving the arm.

Click a sector and the drive reads it. The motion is slowed down 180 times. The arm moves with a simple rule: 1 ms plus 2 ms per track crossed.

Capacity

capacity = surfaces × tracks per surface × sectors per track × bytes per sector
Example. This drive has 3 platters, so 6 surfaces, each with 8 tracks of 16 sectors of 512 bytes. Capacity = 6 × 8 × 16 × 512 = 393,216 bytes, which is 384 KiB. A real drive has hundreds of thousands of tracks per surface, which is why it holds terabytes.

Access time

Every read pays three delays in order:

access time = seek time + rotational latency + transfer time

Seek time is the time to move the head to the right track. The arm has to speed up, slow down and settle over a track a few dozen nanometres wide, so even a short move takes about a millisecond. A desktop drive's average seek is 8 to 10 ms. If the head is already over the track, the seek is 0.

Rotational latency is the wait for the sector to come round under the head. At best it is arriving now, at worst it has just gone past. On average the drive waits half a turn:

one revolution = 60 / RPM seconds average rotational latency = ½ × 60 / RPM seconds

This is why fast server drives spin at 15,000 RPM. Try the three speeds under the figure.

Transfer time is the time for the sector itself to pass under the head. A track of n sectors passes one sector in 1/n of a turn:

transfer time for one sector = (60 / RPM) / sectors per track

Here that is 8.33 / 16 = 0.52 ms. A real track holds over a thousand sectors, so one passes in under 0.01 ms. Next to the seek and the wait, the transfer is tiny.

A worked example

Example. A 7200 RPM drive has an average seek of 9 ms and 1000 sectors per track. How long is an average random read? Seek and rotation are more than 99.9% of the time. The drive spends almost all of it waiting for parts to move.

Sequential and random access

The seek and the wait are paid once. If the next sector wanted is the next one on the same track, the head is already in place and the sector arrives right away. Press 4 sectors in a row: the first read pays a seek and a wait, the next three only 0.52 ms each.

Example. With the drive above, read 1000 sectors that fill one track, then 1000 sectors scattered at random. The same data takes about 600 times longer when it is scattered.

So file systems keep the blocks of a file next to each other, operating systems read ahead in large chunks, and drives reorder waiting requests so the arm sweeps across the platter instead of jumping back and forth.

Real drives

Check your understanding

  1. A laptop drive spins at 5400 RPM. What is its average rotational latency? Check with the 5400 button.
  2. The head is over track 1 and the next request is for track 6. With the figure's rule, how long is the seek?
  3. The drive in the figure is changed to 4096 byte sectors. What is its capacity now?
  4. A 15,000 RPM drive has an average seek of 4 ms and 500 sectors per track. Find the average time to read one random sector.
  5. Press Random read ten times and note the rotation each time. Why is it never more than 8.33 ms at 7200 RPM?
  6. Why can the head reach every track even though the arm only swings around a pivot?

Summary

Takeaways