How a hard disk works
Video 045 of 140 in Virtualization Foundations, in the unit “Storage devices, buses and network cards”. 3:43, with English and Hindi audio.
Every server needs somewhere to keep its files, even when the power goes off. The hard disk drive is one of the most common answers. Its design explains why some disk work is quick and some is slow. This article looks at the parts inside a hard disk, follows one read from start to finish, and shows how to tell from Linux whether a disk has moving parts.
What you will learn
- A hard disk keeps bits on spinning magnetic platters, and a head on an arm reads them.
- A random read needs a seek and then a wait, so it is the slow case.
- Reading neighbouring sectors in order is much quicker, because the head barely moves.
- Hard disks are cheap per terabyte, which suits backups and archives.
- Watch for long waits and a rising count of bad sectors in SMART.
What is inside a hard disk
A hard disk keeps its data on one or more round discs called platters. Each platter has a thin magnetic coating, and every bit is a tiny magnetic spot on that coating.
A small arm carries a head, which reads and writes those spots. The head floats on a thin cushion of air, so it normally does not touch the surface.
The platters spin at a steady speed, often 7,200 turns a minute. Spinning fast means the right spot passes under the head sooner.
How one read reaches the computer
Suppose the computer asks for one small block of data. First, the arm swings the head to the right track. A track is a ring of data on the platter, and the move to it is called a seek.
The head then has to wait. The platter must keep turning until the right sector comes under the head. A sector is a small, fixed piece of a track that holds one block of data.
Only then can the head read the bits, and the data travels back to the computer. Every step takes time, and the moving parts set the pace.
Why random reads are the slow case
A random read jumps to a far-off place on the disk. It needs a seek and then a wait, so each random read adds delay before any data arrives.
Reading neighbouring sectors in order is much quicker, because the head hardly has to move. This is why hard disks suit backups and archives, where reads mostly run in order. They are also cheap per terabyte.
Check from Linux whether a disk spins
Linux can tell you whether each disk has moving parts. Run the command below. The ROTA column answers the question.
lsblk -d -o NAME,ROTA,SIZE,MODEL- A 1 in the ROTA column means the disk spins.
- A 0 means it has no moving parts, which is the case for solid-state drives.
- The MODEL column shows the make and model printed by the drive.
Signs that a disk is wearing out
Slow random reads are often the first sign. A busy database that waits on its disk shows long response times, even when the processor is idle.
The drive also keeps a built-in health record called SMART. When its count of bad sectors keeps rising, the disk surface is wearing out.
Note: A drive that starts throwing read errors may be failing. Copy its data somewhere safe before it dies.
Terms
- Platter
- A round, magnetically coated disc inside a hard disk, where the bits are stored.
- Head
- A tiny reader on an arm that reads and writes the magnetic spots on a platter.
- Seek
- The movement of the arm that places the head over the right track.
- Sector
- A small, fixed piece of a track that holds one block of data.
- SMART
- A health record built into a drive that counts things such as bad sectors.
Check yourself
Why is a random read slower than reading sectors in order?
A random read needs a seek to a far-off track and then a wait for the right sector. Reading in order keeps the head almost in place.
What does a 0 in the ROTA column mean?
The disk has no moving parts, which is the case for solid-state drives.
Which sign suggests that a disk is wearing out?
A count of bad sectors in SMART that keeps rising, especially together with read errors.
Previous: NUMA: memory that is near and far. Next: How an SSD works: flash, wear and TRIM.