Definition
Disk Structure: Physical and logical organization of hard disk drives (HDD) and solid-state drives (SSD), including how data is organized, accessed, and managed.
HDD Physical Structure
Platter
Rotating magnetic disk:
Platter (circular magnetic surface):
┌─────────────────┐
│ Magnetic │
│ Coating │
│ (Iron oxide) │
└─────────────────┘
Size: 3.5", 2.5", 1.8" diameter
Thickness: ~1.2mm
Rotating at: 5400-15000 RPM
Speed impact: Higher RPM = faster access
Spindle
Motor rotating platters:
HDD Assembly:
┌─────────┐
│ Spindle │ (motor)
└─────────┘
║
║ Rotation
║
┌─────────┐
│Platter 1│ (5.9GB @ 15000 RPM)
│Platter 2│
│Platter 3│
│Platter 4│
└─────────┘
Multiple platters: More storage (one device)
Track
Concentric circle on platter:
Platter view (top):
Center
↓
┌──────•─────────┐
│ Track 0 (innermost) (outermost)
│ Track 1 Track n
│ Track 2
│ ......
│ Track n
└────────────────┘
Tracks: Numbered from outer (0) to inner
Each track: Data storage location
Seek: Move arm to different track (expensive!)
Sector
Small arc segment of track:
Track divided into sectors:
┌─ Sector 0
│ Sector 1
╱─┴─ Sector 2
╱ Sector 3
╱ ...
╱ Sector 31 (32 sectors per track typical)
Sector: Smallest addressable unit (512B or 4KB)
Block: OS unit (usually multiple sectors)
Cylinder
Vertical stack across platters:
Multiple platters, same track position:
Platter 0: Track 5
Platter 1: Track 5 ← Cylinder 5
Platter 2: Track 5
Platter 3: Track 5
Cylinder: All tracks at same radius across all platters
Access sequence:
Read cylinder 5 on all platters (no seek!)
Then move to cylinder 6
More efficient than jumping between cylinders
Disk Access Characteristics
Seek Time
Time to move arm to track:
Current Position: Track 10
Target Position: Track 50
Arm moves: 40 tracks
Speed: ~10 ms per 1000 tracks
Time: ~0.4 ms
Total: 2-5 ms typical
Fastest: 0.5 ms (minimal distance)
Worst: 10 ms (full stroke)
Rotational Latency
Wait for sector to rotate under head:
Sector needed is not under read head
Must wait for rotation
Average: Half rotation = (1 minute / RPM) / 2
Examples:
7200 RPM: 60/7200 = 8.33ms per rotation
Average wait: 4.17ms
15000 RPM: 60/15000 = 4ms per rotation
Average wait: 2ms
Higher RPM = Lower latency!
Transfer Time
Read sector data:
Sector size: 4KB = 4096 bytes
Transfer rate: 150 MB/s (typical modern HDD)
Time: 4096 / (150×10^6) = 27 microseconds
Negligible compared to seek + latency
Total Access Time
Total = Seek + Rotational Latency + Transfer
Example (7200 RPM HDD):
= 3ms + 4.17ms + 0.027ms
= 7.2 milliseconds
Implication:
One disk access = execute 7 million CPU instructions!
Disk I/O extremely expensive
Avoid random disk access!
Sequentially better (sequential access)
SSD Structure
No Moving Parts
Traditional HDD: Mechanical (slow, fragile)
SSD: Electronic (fast, durable)
SSD uses:
NAND Flash Memory (similar to USB drives)
No spinning, no seeking
Cell Architecture
SSD Data Storage:
┌──────────────────┐
│ Cell (bit storage)│ MLC: 2 bits per cell
│ Cell │ TLC: 3 bits per cell
│ Cell │ QLC: 4 bits per cell
│ Cell │ PLC: 5 bits per cell
└──────────────────┘
More bits per cell = cheaper but slower
SSD: 256GB, 512GB, 1TB, 2TB common
Access Time
Read: ~100 microseconds (100x faster than HDD!)
Write: ~100 microseconds
Seek: None (direct electronic access)
Sequential vs Random: Minimal difference!
Why SSDs became dominant:
- 100x faster than HDD
- No mechanical latency
- Random access as fast as sequential
Logical Organization
Blocks
Minimum read/write unit from OS perspective:
Sector (physical): 512 bytes or 4KB
Block (logical): 4KB typical
Multiple sectors grouped:
Sector 0 + Sector 1 + Sector 2 + Sector 3 = Block 0
OS always reads/writes whole blocks
Never partial blocks!
File System
Layout files on disk:
Disk organized by file system:
Boot sector
File Allocation Table (FAT)
Root directory
Data blocks
...
Different file systems:
FAT32, NTFS (Windows)
ext4, XFS (Linux)
APFS (macOS)
Disk Scheduling
Why Scheduling?
Multiple I/O requests queue:
Requests in queue:
Read cylinder 50
Read cylinder 10
Read cylinder 100
Read cylinder 30
Order matters!
If serve in order: 50→10→100→30
Seek: 40 + 90 + 70 = 200 tracks
If optimize: 10→30→50→100
Seek: 20 + 20 + 50 = 90 tracks
2.2x better!
Disk scheduling minimizes seeking
NAND Flash Memory Considerations
Write Amplification
SSD has flash cells (blocks)
To modify data:
1. Read entire block (erase unit)
2. Update portion
3. Write back entire block
Original write: 4KB
Actual write: 64KB (worst case)
Write Amplification: 16×
Reduces SSD lifetime!
Optimization: Use levels, wear leveling
Wear Leveling
Flash cells have limited write cycles:
~10,000-1,000,000 writes per cell
Issue: If same block written repeatedly:
Cell wears out quickly
Solution: Distribute writes across all cells
SSD controller transparently moves data
Extends lifespan
User transparent (automatic)
Modern Disk Management
TRIM Command
OS tells SSD: "This data no longer used"
Example:
User deletes file (file deleted, data physical blocks freed)
HDD: Data still on disk, wasted space
SSD: TRIM tells controller to erase blocks
Frees physical space
Improves performance
Linux: fstrim command
macOS: Automatic on modern versions
Windows: Scheduled weekly
Garbage Collection
SSD Controller background process:
1. Identify mostly-empty blocks
2. Consolidate valid data
3. Erase empty blocks
4. Improves free space
5. Restores performance
Transparent to user
May cause latency spikes (noticed as lag)
Performance Characteristics
| Metric | HDD | SSD |
|---|---|---|
| Seek Time | 3-10ms | N/A (instant) |
| Latency | 2-5ms | N/A |
| Transfer Rate | 100-200 MB/s | 300-550 MB/s |
| Random Access | Slow | Fast |
| Sequential Access | Fast | Fast |
| IOPS (4KB) | 100-200 | 10,000-100,000 |
| Lifespan | 1000-2000 power cycles | Limited writes |
| Cost per GB | Low | Higher |
Disk Organization Examples
Example 1: Traditional HDD Layout
Sector 0-63: Boot code
Sector 64-511: File Allocation Table
Sector 512+: Data blocks
Data access sequence:
1. Read FAT (disk scheduling)
2. Find file's blocks in FAT
3. Schedule reads for those blocks
4. Read data in optimized order
Example 2: Modern SSD Layout
LBA (Logical Block Address): 0, 1, 2, ..., N
Maps to Physical Block Address: May be scattered
Controller maintains FTL (Flash Translation Layer)
Transparently manages:
- Wear leveling
- Garbage collection
- Error correction
- TRIM support
User sees: Single LBA space (0-N)
Actually scattered across physical cells
Summary
HDD uses mechanical seeking (slow) with tracks, sectors, cylinders. SSD uses electronic flash memory (fast) with no mechanical latency. Disk scheduling optimizes access order to minimize seeking. HDD access time dominated by mechanical latency (milliseconds). SSD access electronic (microseconds). Modern systems almost exclusively SSD. Understanding disk structure important for appreciating I/O subsystem and why disk I/O expensive. Optimization strategies differ for HDD (sequential access, scheduling) vs SSD (wear leveling, TRIM, GC).