- Authors

- Name
- Youngju Kim
- @fjvbn20031
Mass-Storage Structure
In operating systems, mass storage is used for a variety of purposes including file systems, virtual memory, and swap space. This article examines the physical structure of HDDs and SSDs, disk scheduling algorithms, RAID configurations, and modern object storage and cloud storage.
1. HDD (Hard Disk Drive) Structure
An HDD is a mechanical storage device that reads and writes data by spinning magnetic disks.
Physical Components
┌─────────────────────────────────────┐
│ HDD Internal Structure │
│ │
│ ┌───────────────────┐ │
│ │ Platter │ ← Magnetic│
│ │ ┌─────────┐ │ coating │
│ │ │ Spindle │ │ ← Rotation │
│ │ └─────────┘ │ axis │
│ └───────────────────┘ │
│ │
│ ─────── Actuator Arm ─────── │
│ ▼ │
│ Read/Write Head │
│ │
│ Track: Concentric data paths │
│ Sector: Subdivision of a track │
│ Cylinder: Set of tracks at same │
│ position across platters│
└─────────────────────────────────────┘
- Platter: A circular disk coated with magnetic material
- Spindle: A motor that spins the platters (5,400 to 15,000 RPM)
- Read/Write Head: A device that reads or writes magnetic patterns on the platter surface
- Actuator Arm: Moves the head to the desired track
Disk Access Time Components
Total Access Time = Seek Time + Rotational Latency + Transfer Time
| Component | Description | Typical Time |
|---|---|---|
| Seek Time | Moving the head to the target track | 3-12 ms |
| Rotational Latency | Waiting for the target sector to rotate | 2-6 ms |
| Transfer Time | Actually reading or writing data | Tens of us |
2. Disk Scheduling Algorithms
When disk I/O requests queue up, the order in which they are processed significantly affects performance. The primary goal is to minimize seek time.
FCFS (First-Come, First-Served)
The simplest approach, processing requests in the order they arrive.
Request queue: 98, 183, 37, 122, 14, 124, 65, 67
Head starting position: 53
Movement order: 53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
Total head movement: 640 cylinders
SCAN (Elevator Algorithm)
The head moves in one direction to the end, servicing requests along the way, then reverses direction.
Request queue: 98, 183, 37, 122, 14, 124, 65, 67
Head start: 53, Direction: increasing
Movement order: 53 → 65 → 67 → 98 → 122 → 124 → 183 → [199] → 37 → 14
Reverses after reaching the end
C-SCAN (Circular SCAN)
Services requests in only one direction, and when it reaches the end, immediately jumps to the opposite end to resume servicing in the same direction. This improves uniformity of wait times.
Request queue: 98, 183, 37, 122, 14, 124, 65, 67
Head start: 53, Direction: increasing
Movement order: 53 → 65 → 67 → 98 → 122 → 124 → 183 → [199] → [0] → 14 → 37
End → jump to beginning
Scheduling Comparison Table
| Algorithm | Advantages | Disadvantages |
|---|---|---|
| FCFS | Simple implementation, fair | High head movement |
| SCAN | Efficient, no starvation | Uneven wait at both ends |
| C-SCAN | Uniform wait times | Services only one direction |
| LOOK | Improved SCAN, eliminates unnecessary movement | Slightly complex implementation |
SCAN Simulation in C
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
void scan(int requests[], int n, int head, int disk_size) {
int total_movement = 0;
int sorted[n + 1];
for (int i = 0; i < n; i++)
sorted[i] = requests[i];
sorted[n] = head;
qsort(sorted, n + 1, sizeof(int), compare);
int head_idx = 0;
for (int i = 0; i <= n; i++) {
if (sorted[i] == head) {
head_idx = i;
break;
}
}
// 오른쪽으로 이동
for (int i = head_idx; i <= n; i++) {
printf("서비스: %d\n", sorted[i]);
total_movement += abs(sorted[i] - head);
head = sorted[i];
}
// 디스크 끝까지 이동
total_movement += abs(disk_size - 1 - head);
head = disk_size - 1;
// 왼쪽으로 이동
for (int i = head_idx - 1; i >= 0; i--) {
printf("서비스: %d\n", sorted[i]);
total_movement += abs(sorted[i] - head);
head = sorted[i];
}
printf("총 헤드 이동: %d\n", total_movement);
}
int main() {
int requests[] = {98, 183, 37, 122, 14, 124, 65, 67};
int n = sizeof(requests) / sizeof(requests[0]);
scan(requests, n, 53, 200);
return 0;
}
3. NVM (Non-Volatile Memory) Devices - SSD
An SSD (Solid State Drive) is a NAND flash memory-based storage device that, unlike HDDs, has no mechanical parts.
SSD Internal Structure
┌──────────────────────────────────────┐
│ SSD Structure │
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ Channel 0│ │ Channel 1│ ... │
│ │ ┌──────┐ │ │ ┌──────┐ │ │
│ │ │Die 0 │ │ │ │Die 0 │ │ │
│ │ │┌────┐│ │ │ │┌────┐│ │ │
│ │ ││Blk ││ │ │ ││Blk ││ │ │
│ │ ││Page││ │ │ ││Page││ │ │
│ │ │└────┘│ │ │ │└────┘│ │ │
│ │ └──────┘ │ │ └──────┘ │ │
│ └──────────┘ └──────────┘ │
│ │
│ FTL (Flash Translation Layer) │
│ - Logical address → Physical │
│ address mapping │
│ - Garbage Collection management │
│ - Wear Leveling │
└──────────────────────────────────────┘
SSD vs HDD Comparison
| Property | HDD | SSD |
|---|---|---|
| Read Speed | ~200 MB/s | ~3,500 MB/s (NVMe) |
| Write Speed | ~150 MB/s | ~3,000 MB/s (NVMe) |
| Random I/O | Hundreds of IOPS | Hundreds of thousands of IOPS |
| Latency | Several ms | Tens of us |
| Durability | Mechanical wear | Write cycle limit (TBW) |
| Price/GB | Low | High |
NAND Flash Characteristics
- Read: Page-level (4-16 KB)
- Write: Page-level (only to empty pages)
- Erase: Block-level (hundreds of pages)
- Write Amplification: More physical writes occur than the actual data written
4. RAID (Redundant Array of Independent Disks)
RAID is a technology that combines multiple disks to improve performance, reliability, or both.
RAID Level Structures
RAID 0 (Striping)
┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐
│ A1 │ │ A2 │ │ A3 │ │ A4 │
│ A5 │ │ A6 │ │ A7 │ │ A8 │
└─────┘ └─────┘ └─────┘ └─────┘
Disk 0 Disk 1 Disk 2 Disk 3
→ Performance improvement, no fault tolerance
RAID 1 (Mirroring)
┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐
│ A1 │ │ A1 │ │ A2 │ │ A2 │
│ A3 │ │ A3 │ │ A4 │ │ A4 │
└─────┘ └─────┘ └─────┘ └─────┘
Disk 0 Disk 1 Disk 2 Disk 3
→ Mirror copy, high fault tolerance
RAID 5 (Distributed Parity)
┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐
│ A1 │ │ A2 │ │ A3 │ │ Ap │
│ B1 │ │ B2 │ │ Bp │ │ B3 │
│ C1 │ │ Cp │ │ C2 │ │ C3 │
│ Dp │ │ D1 │ │ D2 │ │ D3 │
└─────┘ └─────┘ └─────┘ └─────┘
Disk 0 Disk 1 Disk 2 Disk 3
→ Distributed parity, tolerates 1 disk failure
RAID 6 (Double Parity)
→ RAID 5 + additional parity, tolerates 2 disk failures
RAID Level Comparison
| RAID | Min Disks | Capacity Efficiency | Fault Tolerance | Read Perf | Write Perf |
|---|---|---|---|---|---|
| 0 | 2 | 100% | None | Very High | Very High |
| 1 | 2 | 50% | 1 disk failure | High | Moderate |
| 5 | 3 | (N-1)/N | 1 disk failure | High | Moderate |
| 6 | 4 | (N-2)/N | 2 disk failures | High | Low |
| 10 | 4 | 50% | 1 per mirror | Very High | High |
5. Object Storage
Unlike traditional block storage or file systems, object storage manages data in units called objects.
Structure Comparison
Block Storage: File System: Object Storage:
┌────┐ /home/ ┌──────────────────┐
│Blk1│ ├── user/ │ Object ID: abc123│
│Blk2│ │ └── file.txt │ Data: [binary] │
│Blk3│ └── etc/ │ Metadata: │
│Blk4│ └── config │ size: 1024 │
└────┘ │ type: image │
Fixed-size blocks Hierarchical dirs │ created: ... │
└──────────────────┘
Flat namespace
Object Storage Characteristics
- Flat Namespace: Access by unique ID without directory hierarchies
- Rich Metadata: Custom user-defined metadata per object
- HTTP REST API: Access via HTTP methods like GET, PUT, DELETE
- Massive Scalability: Can store petabytes or more of data
- Major Services: Amazon S3, Google Cloud Storage, Azure Blob Storage
6. Cloud Storage
Storage in cloud environments is divided into several types depending on the use case.
Cloud Storage Types
┌─────────────────────────────────────────────┐
│ Cloud Storage Classification │
│ │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Block │ │ File │ │ Object │ │
│ │ Storage │ │ Storage │ │ Storage │ │
│ │ │ │ │ │ │ │
│ │ EBS │ │ EFS │ │ S3 │ │
│ │ High perf │ │ Shared │ │ Large │ │
│ │ Low │ │ access │ │ scale │ │
│ │ latency │ │ NFS │ │ HTTP │ │
│ │ │ │ compatible│ │ access │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │
│ ┌───────────────────────────────────────┐ │
│ │ Storage Tiers: Hot → Warm → Cold │ │
│ │ Cost optimization based on access │ │
│ │ frequency │ │
│ └───────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
7. Summary
Mass storage is a core subsystem of the operating system.
- HDD: A mechanical device where seek time is the performance bottleneck. Optimized with scheduling algorithms (SCAN, C-SCAN, etc.)
- SSD: NAND flash-based with excellent random I/O performance. Requires management such as FTL, Wear Leveling, and TRIM
- RAID: Combines multiple disks for performance and reliability. Trade-offs vary by level
- Object Storage: Suitable for large-scale unstructured data. REST API-based access
- Cloud Storage: On-demand scaling, cost optimization through tiering
Quiz: Disk Scheduling and RAID
Q1. What is the difference between the SCAN algorithm and the C-SCAN algorithm?
A1. SCAN reverses direction when the head reaches one end, servicing requests in both directions. C-SCAN services in only one direction, and when it reaches the end, immediately moves to the opposite end. C-SCAN provides better uniformity of wait times.
Q2. How is data recovered when a disk fails in RAID 5?
A2. RAID 5 uses distributed parity. The data on the failed disk can be recovered by performing XOR operations on the data and parity information from the remaining disks. However, if an additional disk fails during recovery, data will be lost.
Q3. What is Write Amplification in SSDs?
A3. Since SSDs must erase at the block level before writing, valid data must be copied to another block before erasing, resulting in more physical writes than the actual user data. This is called write amplification, and it directly impacts SSD lifespan.