Sub topic 4
How a magnetic disk is organized
This chapter assumes you know the basics of binary sizes (KB, MB, GB as powers of two) and what a kernel does when a process asks for I/O. Later chapters compute access time and head movement. Both depend on the vocabulary and geometry defined here.
Physical components
A hard disk drive stores data magnetically on one or more circular platters. All platters are mounted on a single spindle and rotate together at a constant speed, measured in revolutions per minute (RPM). Common speeds are 5400, 7200 and 15000 RPM.
Each platter has two surfaces, a top and a bottom. Each surface has its own read/write head, a tiny electromagnet that floats a few nanometres above the surface. All heads are attached to a single actuator arm assembly. They move in and out together and cannot move independently.
- Only one head transfers data at a time, even though there are many heads.
- Moving the heads across the platters is called a seek.
- Waiting for the right spot to rotate under the head is rotational latency.
The next chapter turns both delays into numbers.
Logical hierarchy
Each surface is divided into concentric rings called tracks. Each track is divided into arc-shaped pieces called sectors. The sector is the smallest unit the disk can read or write. Traditionally it holds 512 bytes of data, and modern drives often use 4096 bytes.
A cylinder is the set of tracks at the same distance from the center, one on every surface. If the arm sits at cylinder 40, the heads are over track 40 of every surface at once.
| Term | Meaning | Why it matters |
|---|---|---|
| Platter | Circular disk coated with magnetic material | Capacity grows with more platters |
| Surface | One side of a platter, with its own head | Number of heads = number of surfaces |
| Track | One ring on one surface | Reading within a track needs no seek |
| Sector | Fixed-size arc of a track | Smallest unit of transfer |
| Cylinder | Tracks at the same radius on all surfaces | Reading within a cylinder needs no seek |
Why cylinders matter
Switching from one head to another is electronic and takes almost no time. Moving the arm to a different cylinder is mechanical and slow. So data that is likely to be read together should sit in the same cylinder, or in neighboring ones. File systems use this idea when they choose where to place blocks.
Disk scheduling algorithms in later chapters work on cylinder numbers. A request such as "cylinder 98" tells the scheduler how far the arm must travel. Head movement is measured in cylinders crossed.
Capacity from geometry
For a simple disk with a constant number of sectors per track:
capacity = surfaces × cylinders × sectors per track × sector size
The number of tracks per surface equals the number of cylinders. The number of surfaces is twice the number of platters, provided both sides are used.
Real drives use zoned bit recording. Outer tracks are longer than inner ones, so they hold more sectors. A GATE question that does not mention zones assumes a constant sectors-per-track count. If a question gives different counts per zone, sum the capacity zone by zone.
Addressing: CHS and LBA
Older systems named a sector by its cylinder, head, sector triple (CHS). Modern drives expose logical block addressing (LBA), where sectors are numbered 0, 1, 2, ... in a single sequence. The drive's controller maps the number to a physical location.
The usual mapping fills a track first, then the next surface in the same cylinder, then moves to the next cylinder. This keeps consecutive LBAs close together and avoids arm movement. Sectors in CHS are numbered from 1, while cylinders and heads start at 0.
def capacity_bytes(surfaces, cylinders, sectors_per_track, sector_size):
return surfaces * cylinders * sectors_per_track * sector_size
def chs_to_lba(c, h, s, heads, sectors_per_track):
# s is 1-based, as in classic CHS addressing
return (c * heads + h) * sectors_per_track + (s - 1)
def lba_to_chs(lba, heads, sectors_per_track):
sectors_per_cylinder = heads * sectors_per_track
c = lba // sectors_per_cylinder
rem = lba % sectors_per_cylinder
h = rem // sectors_per_track
s = rem % sectors_per_track + 1
return c, h, s
# 4 platters = 8 surfaces, 10000 cylinders, 500 sectors/track, 512-byte sectors
cap = capacity_bytes(8, 10000, 500, 512)
print(cap) # 20480000000
print(round(cap / 2**30, 2)) # 19.07 (GiB)
lba = chs_to_lba(2, 3, 10, heads=8, sectors_per_track=500)
print(lba) # 9509
print(lba_to_chs(lba, 8, 500)) # (2, 3, 10)The disk holds 20,480,000,000 bytes. A vendor would call this 20.48 GB (powers of ten), while an exam answer in powers of two would be about 19.07 GiB. Check which unit the question wants.
Common errors
- Counting platters as surfaces. A disk with 5 platters has 10 surfaces if both sides are used. Read the question for "single-sided" or "double-sided".
- Mixing CHS and LBA bases. Sectors in CHS start at 1, but LBA starts at 0. Forgetting the
- 1shifts every answer by one. - Treating a cylinder as a single track. A cylinder contains one track per surface, so its capacity is surfaces × sectors per track × sector size.
- Ignoring units. KB, KiB, MB and MiB differ. GATE usually uses powers of two unless it says otherwise.
Summary of the model
A disk is a stack of rotating surfaces with one head each, and the heads move as one. Position is described by cylinder, head and sector, or by a single logical block number. Moving between cylinders is slow, and everything else is comparatively cheap. That asymmetry is the reason scheduling algorithms exist and the reason file systems try to keep related blocks close together.
Exercise
A disk has 6 platters, and both sides of every platter are used. There are 2000 cylinders and 100 sectors per track, and each sector holds 1 KB. (a) What is the capacity in bytes? (b) What is the capacity of one cylinder? (c) With the usual fill order (track, then surface, then cylinder) and heads and cylinders numbered from 0, which cylinder, head and 0-based sector hold logical block 5000?
Show answer
(a) Surfaces = 6 × 2 = 12. Capacity = 12 × 2000 × 100 × 1024 = 2,457,600,000 bytes. (b) A cylinder has 12 tracks of 100 sectors, so 12 × 100 × 1 KB = 1200 KB. (c) Sectors per cylinder = 12 × 100 = 1200. Cylinder = 5000 // 1200 = 4. Remainder = 200, so head = 200 // 100 = 2 and sector offset = 200 % 100 = 0 (sector 1 in 1-based CHS). Block 5000 is at cylinder 4, head 2, first sector.
Exercise
Why does a file system prefer to place the consecutive blocks of a file in the same cylinder instead of spreading them across many cylinders?
Show answer
Switching between heads within a cylinder is electronic and nearly free, while moving the arm to another cylinder is a slow mechanical seek. Keeping related blocks in one cylinder, or in adjacent cylinders, reduces the number and length of seeks.