Operating Systems
📂 File System
· 3 of 3
41 min read
Disk Structure, Formatting & RAID — CHS/LBA, RAID 0/1/5/6/10
Master Disk Structure, Formatting, and RAID from Galvin's Operating System Concepts through four interactive step-by-step animations. Walk through CHS↔LBA conversion math, watch RAID 0 vs RAID 1 write blocks side-by-side, see RAID 5 compute XOR parity and recover a failed disk, and size five RAID levels on a 12-disk array. Two worked numericals cover 8×500 GB and 12×2 TB scenarios.
Section 01
The Story That Explains Disk Structure & RAID
📖 Real World Analogy
The Warehouse of Rotating Shelves
Imagine a book warehouse where books live on rotating circular shelves stacked
vertically. A single robotic arm can slide up-and-down to reach any shelf level, and each
shelf spins to bring the right book past the arm. The warehouse manager has to solve
three separate problems:
Structure — how are books physically organised on the shelves? By
subject, alphabetical, or radial position? Formatting — before any books arrive, we must pre-print the labels on
every shelf slot so the arm knows where to place and find each book. Redundancy — what happens if a shelf catches fire? A responsible manager
doesn't keep one copy of every book. She uses mirror shelves or clever
error-correction codes so a single failure doesn't lose data.
These three concerns — physical geometry, formatting, and fault tolerance — are the same
ones an OS solves for disk drives. Physical layout is disk structure.
Pre-printing the labels is disk formatting. Multiple redundant copies
is RAID.
💡
Why It All Matters Together
A file system sits on top of a formatted disk. That formatted disk may itself sit on
top of a RAID array of many physical disks. Understanding all three layers is essential
for any system administrator, backend engineer, or storage architect.
Section 02
Physical Disk Structure
Anatomy of a Hard Disk
A hard disk contains one or more platters rotating on a common spindle. Each
platter has two magnetic surfaces, each served by one read/write head. All
heads move together on a single actuator arm.
🛠️ Geometry Vocabulary
Platter
A physical disc coated with magnetic material. 3–8 typical in a modern HDD.
Surface
One side of a platter (each platter has two — top and bottom).
Head
Read/write device flying above one surface. One head per surface.
Track
Circular path at a fixed radius on a surface.
Sector
Fixed-size arc (usually 512 B or 4 KB) — smallest addressable unit.
Cylinder
All tracks at the same radius across every platter. Reading a whole cylinder needs no arm movement.
Cluster
File-system-level grouping of several sectors, used for allocation.
Section 03
Disk Addressing — CHS vs LBA
Every sector on the disk needs a unique address. Two schemes exist historically.
🏠 CHS — Cylinder / Head / Sector
Legacy three-part address: (C, H, S)
Reflects the physical geometry
Limited by BIOS: max ~8 GB on old systems
Sector numbering starts at 1, cylinder/head at 0
🔢 LBA — Logical Block Addressing
Single integer: LBA 0, 1, 2, …
OS-friendly, hides physical geometry
Modern systems use 48-bit or 64-bit LBAs
The disk controller translates LBA → internal geometry
Conversion Formulas
// Given: H heads/cylinder, S sectors/track// CHS (c, h, s) → LBA
LBA = (c × H + h) × S + (s − 1)
// LBA → CHS
c = LBA / (H × S)
h = (LBA / S) mod H
s = (LBA mod S) + 1
🎮 Interactive — CHS ↔ LBA Conversion
Disk geometry: H = 4 heads, S = 20 sectors/track. Convert CHS (5, 2, 15)
to LBA, then convert LBA 454 back to CHS.
CHS ↔ LBA conversion — step through the math
Given
H = 4, S = 20 sectors/track
Result
—
Computation Trace
Click Next to begin
Step 0 of 8
START
Two conversions to walk through: (1) CHS (5, 2, 15) → LBA, then (2) LBA 454 → CHS. Click Next.
Section 04
Disk Formatting
Before a disk can store user files, it must be formatted. This actually
happens in two stages, at very different levels.
Low-Level (Physical) Formatting
⚙️ Low-Level Format — done by manufacturer
Divide
Split each track into equal-length sectors.
Header
Write a header before each sector containing: sector number, sync pattern, and ECC.
Trailer
Write a trailer after each sector containing more ECC bits for error detection/correction.
Result
Disk is "raw formatted" — controller can now address sectors by number.
Sector Anatomy
A single sector on disk — 512 bytes of data + overhead
High-Level (Logical) Formatting
💾 High-Level Format — done by OS
Partition
Divide raw disk into one or more logical partitions.
FS Metadata
Write empty file-system data structures — FAT tables, i-node table, MFT, superblock — depending on the chosen file system.
Boot Block
Reserved first sector(s) hold bootstrap code that the BIOS/UEFI runs to start the OS.
Free-space Map
Bitmap or list marking which blocks are free.
Bad Blocks
⚠️
Sector Sparing
Every disk ships with a pool of spare sectors. When a sector goes bad,
the controller silently substitutes a spare (sector remapping / sector forwarding). The
OS never sees the failure — it just gets a slightly slower response. Modern SMART
monitoring exposes remap counts as an early warning of impending disk death.
Section 05
RAID — Redundant Array of Independent Disks
A single disk has three big problems: it's slow, it's small, and it fails. RAID
attacks all three by combining multiple physical disks into one logical unit. Different RAID
levels balance the three axes: speed, capacity, and fault tolerance.
⚡
RAID 0 — Striping
speed + capacity, no safety
Split data across N disks. Read/write in parallel → N× throughput. Use all N disks'
capacity. But one disk failure loses everything.
🔖
RAID 1 — Mirroring
safety + read speed
Every block written to two disks. Usable capacity halves, but survives one full disk
failure. Reads can come from either copy.
🔢
RAID 4 & 5 — Parity
safety with less overhead
Store N−1 disks of data + 1 disk of XOR parity. Survives one disk failure. Uses only
1/N of raw capacity as overhead — much cheaper than mirroring for large arrays.
🔢
RAID 6
double parity
Two independent parity blocks per stripe. Survives two simultaneous disk
failures. Essential for large arrays where rebuild times are long.
🔁
RAID 10 (1+0)
nested — mirror + stripe
Mirror pairs, then stripe across pairs. High performance and high fault tolerance.
Popular for databases. Uses 50% of raw capacity.
🛡️
RAID 0+1 vs RAID 1+0
order matters
RAID 0+1 (stripe of mirrors) and RAID 1+0 (mirror of stripes) sound similar but have
different failure modes. RAID 10 (1+0) tolerates more disk failures than 0+1.
🎮 Interactive — RAID 0 vs RAID 1
Write 4 data blocks (A, B, C, D) to a 2-disk array. Watch how RAID 0 (striping) and RAID 1
(mirroring) distribute them.
RAID 0 vs RAID 1 — striping vs mirroring
RAID 0 — Striping (2 disks)
—
RAID 1 — Mirroring (2 disks)
—
Ready — click Next to write block A
Step 0 of 5
START
Both arrays start empty. Four blocks A, B, C, D queued for writing. Click Next.
Section 06
RAID 5 — Distributed Parity
RAID 5 stores parity blocks alongside data blocks. For each stripe, one
block holds the XOR of all other blocks in that stripe. Parity blocks
rotate across disks to avoid concentrating writes on one disk (unlike RAID 4).
🔑
The XOR Magic
If P = A ⊕ B ⊕ C, then losing any one of A, B, C, or P still leaves the other
three, and the missing one can be recovered by XORing them together. This is the
mathematical heart of RAID 5.
Usable capacity = N/2 × C = 4 × 500 GB = 2 TB
Failures tolerated = up to 4 (one per pair)
Efficiency = 50%
RAID
Usable
Failures
Efficiency
Best For
0
4 TB
0
100%
Scratch space, video editing
1
2 TB
1–4
50%
Boot drives, small critical data
5
3.5 TB
1
87.5%
General file servers
6
3 TB
2
75%
Large arrays, long rebuilds
10
2 TB
1–4
50%
Databases, OLTP
Section 08
Numerical Problem 2 — Interactive RAID Sizing
Different problem: 12 disks of 2 TB each. Click Next to compute usable
capacity for each RAID level one at a time.
RAID sizing walkthrough — 12 × 2 TB
Given
N = 12 disks, C = 2 TB each
Raw total = 24 TB
Current RAID Level
—
Calculation
Waiting for first step…
Verdict
—
Step 0 of 5
START
12 disks × 2 TB = 24 TB raw. We'll compute usable capacity for each RAID level. Click Next.
Section 09
Real-World Applications
💾
Enterprise Servers
Most enterprise data centers use RAID 5 or RAID 6 for capacity-heavy workloads (file
shares, backups) and RAID 10 for latency-sensitive workloads (databases, OLTP).
RAID 5 · RAID 10
🖥️
Home NAS Devices
Synology, QNAP, and TrueNAS home boxes typically default to RAID 5 or RAID 6. Modern
software equivalents (Btrfs raid5, ZFS raidz1/raidz2) offer the same guarantees.
Synology · QNAP · ZFS
🌐
Cloud Object Storage
AWS S3, Azure Blob, and Google Cloud Storage use erasure coding — a generalized
RAID that spreads data across many disks with configurable redundancy. Some services use
10-of-16 or 14-of-18 codes.
Erasure coding · S3
🎮
Video Editing Workstations
RAID 0 with multiple NVMe SSDs is common for 4K/8K video scratch space. Speed matters
more than durability — source footage lives on backup elsewhere.
RAID 0 · NVMe
📡
Cellular Base Stations
Telecom equipment uses RAID 1 for boot drives — small, dual-mirrored SSDs so a single
failure never takes a cell tower offline.
RAID 1 · Telecom
🔥
Boot Drives Everywhere
Windows Server, Linux, and VMware all support RAID 1 for OS partitions. If one drive
dies, the server keeps running from the other — you replace the failed drive at leisure.
Boot mirroring
Section 10
Golden Rules — Disk Structure, Formatting & RAID
🔑 Galvin's Non-Negotiable Rules
1
A hard disk's physical structure — platter, surface, head, track, sector, cylinder — dictates every access-time calculation. Master this vocabulary before anything else.
2
Modern OSes use LBA (logical block addressing) rather than CHS. LBA hides physical geometry behind a single integer index. The disk controller translates internally.
3
Low-level formatting is done by the manufacturer — writes sector headers, ECC, and boot records. High-level formatting is done by the OS — writes file-system data structures onto partitions.
4
Every disk reserves spare sectors for automatic remapping of bad blocks. SMART tools expose the remap count as an early warning sign of impending failure.
5
RAID 0 stripes data for speed — capacity 100%, but zero fault tolerance. Any single disk failure loses everything. Use only for scratch data.
6
RAID 1 mirrors data across two disks — capacity 50%, tolerates one full failure per mirror. Ideal for boot volumes and small critical data.
7
RAID 5 uses distributed parity — capacity (N−1)/N, tolerates one failure. The best general-purpose choice for large file servers.
8
RAID 6 uses double parity — capacity (N−2)/N, tolerates two failures. Essential for large arrays where rebuild takes hours and second failures are likely.
9
RAID 10 (1+0) is the go-to for high-performance databases — capacity 50%, but excellent write throughput and up to N/2 failure tolerance (one per pair).
10
RAID is not backup. A single ransomware attack or human deletion propagates instantly to all RAID copies. Always keep offline backups separate from the array.