What Is a difference between HDD and SSD
Tags: hdd, ssd, storage
Published: 2020-08-16 08:37:12

Permanent storage is one of the most essential part in the modern computer. All data in the computer disappears when the power turns off without permanent storage. 
We often use HDD or SSD and SSD is more useful and expensive one. Why does SSD perform better? Let's take a close look at them.

## The System of HDD
HDD is just a computer by itself because it has control units, a power socket and memory. There are 4 main parts in HDD.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wy68bb8edlx70oce7orr.png)

### 1.Platter
Platter is a magnetic disk, which is covered with a lot of tiny magnetized metal grains. Magnet generates "magnetic field" which has the power towards one direction. This direction represents a bit like upward means '0' and downward means '1'. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/orl3efw4i0y507gs5mms.png)

We can determine the data's physical position with cylinder, sector and track.
- Cylinder

This denotes which plate and side will be used.
- Sector

This denotes which part of plate on the surface will be used. Platter is divided every 512 (B) in some HDD, and 4 (KB) in others. There are non-recording areas among sectors. So smaller sector is not good because it generates many non-recording areas.
- Track

This denotes how long the distance from center is.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dorps4z5k9u9s08v4ln0.png)

### 2.Spindle
Spindle spins the platter to set the sector position of requested data. RPM means the number of rotations in one minute. Major HDD is 5400(RPM) or 7400(RPM) and we can access data in shorter time when RPM gets larger.

### 3.Head
Head reads and writes data on the platter. It has a strong magnet and can change the direction of magnetic field. This means it has an ability to write data. Also it can know the direction of magnetic field and convert it to bit. 

Head is flying nano meters above the platter not to rub the platter.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mawvfq0a1cxmb0pgabdb.PNG)

### 4.Actuator
Actuator is main part that moves the head. When HDD is not working, head should be placed on other than the platter. HDD is divided two types by the palce head is on when HDD is not working.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0df4xquhowf7p3l99ae1.png)

Lamp load type requires another part but it has stronger resistance to shock.

## The System of SSD
SSD has a control unit and a cache memory as well but it doesn't have platters and a head. When SSD reads or writes data, it doesn't need to move physical parts. This is one reason that SSD performs better. Also the way of recording data is completely different from HDD. This makes the physical size of SSD smaller. Here is the architecture.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k3nqhtd19ogph16e55cq.gif)

### 1.Flash Memory
Flash memory records data using floating gate transistors. Floating gate with electronic means 0 and one without electronic means 1. This is called SLC(Single Level Cell). We can represent 4 types of value, which means 2 bits, to change the amount of electronic like none, small, medium and large. This is called MLC(Multi Level Cell). It helps SSD to have more storage capacity. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rg3guqlnue3mx5ah66p1.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vvokwdcg59swqq4m4lgc.png)

### 2.DRAM
This works as a cache and helps user with efficient access to data.

### 3.Controller
Controller has two important roles. 
The first one is wear leveling. Each flash memory cell has lifetime and it is not good to read or write data in the same cell. So, Controller memorizes the number of use in each cell and control the access from user to increase the lifetime of memory.
The second is error correction. The older the cell is, the more it generates error. Controller attaches some data to correct error when it writes some data in the cell. 

Enjoy hacking!