The University of Massachusetts Amherst
Categories
Hardware Operating System

Hard Drives: How Do They Work?

What’s a HDD?

A Hard Disk Drive (HDD for short) is a type of storage commonly used as the primary storage system both laptop and desktop computers. It functions like any other type of digital storage device by writing bits of data and then recalling them later. It stands to mention that an HDD is what’s referred to as “non-volatile”, which simply means that it can save data without a source of power. This feature, coupled with their large storage capacity and their relatively low cost are the reasons why HDDs are used so frequently in home computers. While HDDs have come a long way from when they were first invented, the basic way that they operate has stayed the same.

How does a HDD physically store info?

Inside the casing there are a series of disk-like objects referred to as “platters”.

The CPU and motherboard use software to tell what’s called the “Read/Write Head” where to move on the platter and where it then provides an electrical charge to a “sector” on the platter. Each sector is an isolated part of the disk containing thousands of subdivisions all capable of accepting a magnetic charge. Newer HDDs have a sector size of 4096 bytes or 32768 bits; Each bit’s magnetic charge translates to a binary 1 or 0 of data. Repeat this stage and eventually you have a string of bits which when read back can give the CPU instructions, whether it be updating your operating system, or opening your saved document in Microsoft Word.

As HDDs have been developed, one key factor that has changed is the orientation of the sectors on the platter. Hard Drives were first designed for “Longitudinal Recording” – meaning the longer side of the platter is oriented horizontally – and since then have utilized a different method called “Perpendicular Recording” where the sectors are stacked on end. This change was made as hard drive manufacturers were hitting a limit on how small they could make each sector due to the “Superparamagnetic Effect.” Essentially, the superparamagnetic effect means that hard drive sectors smaller than a certain size will flip magnetic charge randomly based on temperature. This phenomenon would result in inaccurate data storage, especially given the heat that an operating hard drive emits.

One downside to Perpendicular Recording is increased sensitivity to magnetic fields and read error, creating a necessity for more accurate Read/Write arms.

How software affects how info is stored on disk:

Now that we’ve discussed the physical operation of a Hard Drive, we can look at the differences in how operating systems such as Windows, MacOS, or Linux utilize the drive. However, beforehand, it’s important we mention a common data storage issue that occurs to some degree in all of the operating systems mentioned above.

Disk Fragmentation

Disk Fragmentation occurs after a period of data being stored and updated on a disk. For example, unless an update is stored directly after a base program, there’s a good chance that something else has been stored on the disk. Therefore the update for the program will have to be placed in a different sector farther away from the core program files. Due to the physical time it takes the read/write arm to move around, fragmentation can eventually slow down your system significantly, as the arm will need to reference more and more separate parts on your disk. Most operating systems will come with a built in program designed to “Defragment” the disk, which simply rearranges the data so that all the files for one program are in once place. The process takes longer based on how fragmented the disk has become. Now we can discuss different storage protocols and how they affect fragmentation.

Windows:

Windows uses a base computer language called MS-DOS (Microsoft Disk Operating System) and a file management system called NTFS, or New Technology File System, which has been the standard for the company since 1993. When given a write instruction, an NT file system will place the information as close as possible to the beginning of the disk/platter. While this methodology is functional, it only leaves a small buffer zone in between different files, eventually causing fragmentation to occur. Due to the small size of this buffer zone, Windows tends to be the most susceptible to fragmentation.

Mac OSX:

OSX and Linux are both Unix based operating systems. However their file system are different; Mac uses the HFS+ (Hierarchical File System Plus) protocol, which replaced the hold HFS method. HFS+ differs in that it can handle a larger amount of data at a given time, being 32bit and not 16bit. Mac OSX doesn’t need a dedicated tool for defragmentation like Windows does OSX avoids the issue by not using space on the HDD that has recently been freed up – by deleting a file for example – and instead searches the disk for larger free sectors to store new data. Doing so increases the space older files will have closer to them for updates. HFS+ also has a built in tool called HFC, or Hot File adaptive Clustering, which relocates frequently accessed data to specials sectors on the disk called a “Hot Zone” in order to speed up performance. This process, however, can only take place if the drive is less than 90% full, otherwise issues in reallocation occur.  These processes coupled together make fragmentation a non-issue for Mac users.

Linux:

Linus is an open-source operating system which means that there are many different versions of it, called distributions, for different applications. The most common distributions, such as Ubuntu, use the ext4 file system. Linux has the best solution to fragmentation as it spreads out files all over the disk, giving them all plenty of room to increase in size without interfering with each other. In the event that a file needs more space, the operating system will automatically try to move files around it give it more room. Especially given the capacity of most modern hard drives, this methodology is not wasteful, and results in no fragmentation in Linux until the disk is above roughly 85% capacity.

What’s an SSD? How is it Different to a HDD?

In recent years, a new technology has become available on the consumer market which replaces HDDs and the problems they come with. Solid State Drives (SSDs) are another kind of non-volatile memory that simply store a positive charge or no charge in a tiny capacitor. As a result, SSDs are much faster than HDDs as there are no moving parts, and therefore no time to move the read/write arm around. Additionally, no moving parts increases reliability immensely. Solid state drives do have a few downsides, however. Unlike with hard drives, it is difficult to tell when a solid state is failing. Hard drives will slow down over time, or in extreme cases make audible clicking signifying the arm is hitting the platter (in which case your data is most likely gone) while solid states will simply fail without any noticeable warning. Therefore, we must rely on software such as “Samsung Magician” which ships with Samsung’s solid states. The tool works by writing and reading back a piece of data to the drive and checking how fast it is able to do this. If the time it takes to write that data falls below a certain threshold, the software will warn the user that their solid state drive is beginning to fail.

Do Solid States Fragment Too?

While the process of having data pile on top of itself, and needing to put files for one program in different place is still present, it doesn’t matter with solid states as there is no delay caused by the read/write arm of a hard drive moving back and forth between the different sectors. Fragmentation does not decrease performance the way it does with hard drives, but it does affect the life of the drive. Solid states that have scattered data can have a reduced lifespan. The way that solid states work cause the extra write cycles caused by defragmenting to decrease the overall lifespan of the drive, and is therefore avoided for the most part given its small impact. That being said a file system can still reach a point on a solid state where defragmentation is necessary. It would be logical for a  hard drive to be defragmented automatically every day or week, while a solid state might require only a few defragmentations, if any, throughout its lifetime.