Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Hard disks and RAID

Basics of magnetic hard disks (geometry, timings, throughput) and RAID (levels, capacity, reliability, parity) with formulas, derivations, worked numerical examples, common exam mistakes and quick checks.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Hard disks provide large, persistent secondary storage in many computer systems. An engineer uses disk geometry and timing calculations to estimate I/O latency and throughput, and uses RAID (Redundant Array of Independent Disks) designs to trade capacity, performance and reliability in servers and storage systems.

Key ideas

Start from definitions.

  • Hard disk (HDD): a magnetic storage device where data are stored on one or more spinning platters; each platter surface is read/written by a head. I will call the combination of one platter surface and its head a surface.
  • Track: a concentric circle on a surface where data is recorded. Draw a single platter top view: concentric circles (tracks); label one track.
  • Sector: a small angular slice of a track that stores a fixed block of bytes (e.g., 512 B or 4096 B). Indicate one sector on the track as a wedge and label "sector".
  • Cylinder: the set of tracks at the same radius on all surfaces; draw multiple platters (stack), draw a vertical dashed line through their tracks and label "cylinder".
  • Seek: movement of the head assembly to position a head over the desired track. Draw an actuator arm moving radially and label start and end tracks.
  • Rotational latency: waiting time for the desired sector to rotate under the head. If the platter rotates at RPM (revolutions per minute), one revolution = 60/RPM seconds.
  • Transfer time: time to read or write the requested bytes once the head is positioned and the sector arrives under it; depends on data rate (bytes per second).
  • Access time: total time to complete the transfer = seek time + rotational latency + transfer time.

Disk geometry and performance principles:

  1. A block read normally requires: position the head (seek), wait for the sector to rotate (rotational latency), then transfer bytes (transfer time). If data spans multiple contiguous sectors on the same track, transfer time increases but additional seeks/rotations may not be needed.
  2. Modern disks use zoned recording: outer tracks hold more sectors per track than inner tracks. For exam derivations, assume uniform sectors per track unless stated.
  3. Reliability of multiple-disk systems depends on independent disk failure probabilities and on whether redundancy (mirroring or parity) allows continued operation after disk failure.

RAID concepts (each term defined when first used):

  • RAID: Redundant Array of Independent Disks — a set of disks organized to improve performance and/or reliability compared with a single disk.
  • Striping: dividing data into blocks (stripes) and placing consecutive blocks on different disks to increase parallelism. Draw a table: rows = disks, columns = stripe units; fill with block labels A1, A2,...
  • Mirroring: keeping an exact copy of data on two (or more) disks. Useful for fast reads and high reliability.
  • Parity: extra bits computed from data blocks that allow recovery of one failed disk by recomputing missing data. Parity for two data blocks D1 and D2 is P = D1 XOR D2 (bitwise exclusive OR). Show a stripe of three disks: D1, D2, P. For k+1-disk stripes (k data disks plus one parity), parity is XOR across all data blocks: P = D0 XOR D1 XOR ... XOR Dk. RAID 6 uses two independent parity calculations (often called P and Q, with Q based on Galois field arithmetic), enabling recovery from any two disk failures in a stripe.
  • Common RAID levels covered: RAID 0 (striping, no redundancy), RAID 1 (mirroring), RAID 5 (distributed single parity across disks), RAID 6 (double parity — can tolerate two simultaneous disk failures), RAID 10 (a stripe of mirrors; combine RAID 1 and RAID 0). Minimum disks: RAID 0 ≥ 1, RAID 1 = 2 (or m-way mirror with m ≥ 2), RAID 5 ≥ 3, RAID 6 ≥ 4, RAID 10 ≥ 4. Small-write performance: RAID 5 incurs the read–modify–write penalty (≈4 I/Os per small write), RAID 6 ≈6 I/Os; mirrored reads can be load-balanced across copies, mirrored writes go to all copies.

Exact reliability statements and assumptions used in standard exam solutions:

  • Assume disk failures are independent and have small probability p over the considered time period (e.g., one year). For small p, probability of k failures among n disks ≈ C(n,k) p^k (neglecting higher-order terms when k is small). State independence and small-p assumption explicitly.
  • For RAID 0 (n disks): data survives only if every disk survives. Survival probability = (1 - p)^n. Data-loss probability = 1 - (1 - p)^n.
  • For RAID 1 (mirror of 2 disks): data lost only if both disks fail. Data-loss probability ≈ p^2. For an m-way mirror (m identical copies), over a short period ignoring rebuild, approximate data-loss probability ≈ p^m.
  • For RAID 5 (n disks): can survive one disk failure; data loss occurs if two (or more) disks fail before rebuild completes. For small p and short period where rebuild not considered, approximate one-period failure probability ≈ C(n,2) p^2. More accurate reliability analysis must include rebuild time and transient increased risk; see MTTDL formulas below, and also account for unrecoverable read errors (UREs) during rebuild.

Describe diagram to draw for parity recovery: draw three disks with blocks D0, D1 and parity P=D0 XOR D1. Show recovery of D0 by computing D0 = D1 XOR P. Label XOR operation.

Formulas

T_rev = 60 / RPM — period of one revolution in seconds. (RPM: revolutions per minute) T_rot_avg = T_rev / 2 = 30 / RPM — average rotational latency in seconds (assuming uniform sector distribution). Units: s. T_access = T_seek + T_rot_avg + T_transfer — average access time in seconds. T_seek (s) is average seek time, T_transfer (s) is transfer time for requested bytes. Transfer_rate = (bytes_per_rev) * RPM / 60 — bytes per second. bytes_per_rev = sectors_per_track * bytes_per_sector. Usable_capacity_RAID0 = n * S — for RAID 0 with n disks each of size S (bytes). Usable_capacity_RAID1_2disk = S — for a 2-disk mirror. For n disks arranged in m-way mirrors (m identical copies per block; all disks size S), Usable_capacity_RAID1_n_m = (n/m) * S = total_raw / m. Usable_capacity_RAID5 = (n - 1) * S — single parity across n disks. Usable_capacity_RAID6 = (n - 2) * S — double parity across n disks. Usable_capacity_RAID10 = (n/2) * S — stripe of mirrored pairs (n even; all disks same size S). Survival_prob_RAID0 = (1 - p)^n — probability data survives over the period if disk failure prob = p and disks independent. Approx_data_loss_prob_RAID5 ≈ C(n,2) * p^2 — for small p and ignoring rebuild effects; C(n,2) = n*(n-1)/2. Rebuild_time = Disk_size_bytes / Rebuild_rate_bytes_per_s — seconds. (Rebuild_rate is the sustained rate at which parity and data are rewritten during rebuild.) Approx_MTTDL_RAID5 ≈ (MTTF_disk^2) / (n*(n-1) * MTTR) — approximate mean time to data loss for RAID 5 assuming independent exponential disk failures and constant repair rate; MTTF_disk in hours (or s), MTTR = mean time to repair (rebuild) in the same time units.

Define symbols explicitly where used in formulas above.

Worked examples

  1. Average access time for a single 4 KB read on a 7200 RPM disk. Given: RPM = 7200 rpm, average seek T_seek = 9 ms (0.009 s), sector size = 4096 B, assume sectors_per_track = 100 for this example (typical varies with zone). Compute:
  • T_rev = 60 / 7200 = 0.008333... s = 8.333 ms.
  • T_rot_avg = T_rev / 2 = 4.1667 ms = 0.0041667 s.
  • bytes_per_rev = 100 * 4096 = 409600 B.
  • Transfer_rate = bytes_per_rev * RPM / 60 = 409600 * 7200 / 60 = 49,152,000 B/s ≈ 49.152 MB/s.
  • T_transfer = 4096 B / 49,152,000 B/s = 8.333e-5 s = 0.08333 ms.
  • T_access = 9 ms + 4.1667 ms + 0.08333 ms = 13.25 ms. Final answer: Average access time ≈ 13.25 ms.
  1. RAID capacity and simple reliability for 5 disks of 2 TB each in RAID 5. Given: n = 5, S = 2 TB (2 × 10^12 bytes for SI convenience), annual disk failure probability p = 2% = 0.02 (example AFR). Compute:
  • Usable_capacity = (n - 1) * S = 4 * 2 TB = 8 TB.
  • Approximate probability of data loss in one year (two or more failures) ≈ C(5,2)*p^2 = 10 * (0.02)^2 = 10 * 0.0004 = 0.004 = 0.4%. Final answers: Usable capacity = 8 TB, approx data-loss probability ≈ 0.4% per year under the small-p approximation and ignoring rebuild and correlated failures.
  1. Compare RAID 0 and RAID 5 reliability for the same 5-disk set with p = 0.02.
  • RAID 0 survival probability = (1 - p)^5 = 0.98^5 ≈ 0.9039 => data-loss probability ≈ 9.61%.
  • RAID 5 approx data-loss probability ≈ 0.4% (from previous). Conclude RAID 5 is much more reliable.

Common mistakes

  • Confusing usable capacity: students often forget parity/mirror overhead (RAID 5 uses one disk for parity capacity, RAID 1 halves usable capacity for a 2-disk mirror).
  • Miscomputing parity: parity is bitwise XOR across corresponding bits of stripe units, not arithmetic addition.
  • Using combinatorial formulas for reliability without stating independence and small-p assumptions. Correlated failures (power, controller) invalidate simple combinatorics.
  • Omitting rebuild time effects on reliability: the window while rebuilding has higher risk of data loss.
  • Ignoring RAID 5/6 small-write penalty (read–modify–write) when estimating IOPS or latency; mirrored reads can be faster due to load balancing.

For your exam

Typical question types:

  • Definitions and labeled diagrams (draw platter, head, track, sector, cylinder; draw a stripe with parity).
  • Short notes: explain parity, difference between RAID 0/1/5/6/10, advantages and disadvantages.
  • Derivations: derive average rotational latency from RPM, derive access time expression, or derive approximate RAID failure probability using combinatorics.
  • Numericals: compute access times, transfer rates, usable capacities, rebuild times, approximate data-loss probabilities.
  • Small algorithms/traces: show parity computation for small stripe, show recovery steps after one disk failure.

What full-marks answers include:

  • Clear definitions of terms used and diagram labels when requested.
  • Unit-consistent calculations (show conversions like ms ↔ s) and state assumptions (e.g., uniform sector distribution, independent failures).
  • For RAID reliability, state independence and small-p assumption, and mention rebuild time if the question involves MTTDL or time-to-failure.

Quick check

  1. Formula for average rotational latency for a 5400 RPM disk (in ms)?
  2. Usable capacity of RAID 6 with four 1 TB disks (TB)?
  3. For RAID 0 with 3 disks each with annual failure probability 5%, what is approximate probability that the array survives one year?

Answers: 1) 30 / 5400 = 0.005556 s = 5.556 ms. 2) (n - 2) * S = (4 - 2) * 1 TB = 2 TB. 3) Survival = (1 - 0.05)^3 ≈ 0.857375 -> survival ≈ 85.7375% (data-loss ≈ 14.2625%).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?