Secondary Storage: Magnetic Disks and SSDs
Secondary storage provides non-volatile, long-term data retention. While the CPU and RAM handle active processing, secondary storage holds the OS, applications, and user files. The two most common technologies are Magnetic Disks (HDD) and Solid State Drives (SSD).
1. Magnetic Disk Architecture (HDD)
HDDs use rotating magnetic platters and a moving read/write head. Data is organized into circular **Tracks**, which are further divided into **Sectors**.
- **Seek Time:** The time taken for the read/write head to move to the correct track.
- **Rotational Latency:** The time taken for the correct sector to rotate under the head.
- **Transfer Rate:** The actual speed at which data is read from the disk to the memory.
2. Solid State Drives (SSD)
SSDs have no moving parts. They use NAND-based flash memory to store data. Because there is no mechanical movement, they are significantly faster and more durable than HDDs.
- **Flash Translation Layer (FTL):** Maps logical block addresses to physical flash locations.
- **Wear Leveling:** A technique to ensure data is written evenly across chips to prevent premature failure.
- **Zero Latency:** Since there are no moving parts, seek time is virtually non-existent.
Comparison Table
| Feature | Magnetic Disk (HDD) | Solid State Drive (SSD) |
|---|---|---|
| Mechanism | Mechanical (Moving parts) | Electronic (Flash memory) |
| Access Speed | Slow (Milliseconds) | Very Fast (Microseconds) |
| Durability | Sensitive to physical shock | Highly resistant to shock |
| Cost per GB | Lower (Cheaper for bulk) | Higher |
| Lifespan | Based on mechanical wear | Based on write cycles (P/E cycles) |
Disk Scheduling Algorithms
To improve HDD performance, the Operating System uses algorithms to decide the order in which to handle I/O requests:
- **FCFS (First-Come, First-Served):** Simplest, but results in high head movement.
- **SSTF (Shortest Seek Time First):** Moves the head to the closest request; can cause starvation.
- **SCAN (Elevator Algorithm):** The head moves from one end of the disk to the other, servicing requests along the way.
Common Mistakes to Avoid
- Thinking SSDs last forever (they have a finite number of 'program/erase' cycles).
- Assuming disk fragmentation affects SSDs the same as HDDs (defragmenting an SSD is unnecessary and harmful).
- Confusing the SATA interface with the storage type (both HDDs and SSDs can use SATA).
- Underestimating the importance of the SSD Controller in performance.
Advanced Concepts
- NVMe (Non-Volatile Memory Express) Protocol
- RAID Configurations (0, 1, 5, 10)
- TRIM Command for SSDs
- Hybrid Drives (SSHD)
- Storage Area Networks (SAN)
Practice Exercises
- Calculate the total disk access time given seek time, RPM, and transfer rate.
- Why is Random I/O performance much higher on an SSD than an HDD?
- Explain the 'Elevator Algorithm' with a seek distance example.
- Research the difference between SLC, MLC, and TLC NAND flash.
Conclusion
While HDDs remain cost-effective for massive data archiving, SSDs have become the standard for system drives due to their superior speed and reliability. Understanding the mechanical vs. electronic nature of these devices is key to diagnosing system bottlenecks.
Codecrown