right|thumb|Cylinder, head, and sector of a hard drive
Cylinder-head-sector (CHS) is an early method for giving addresses to each physical block of data on a hard disk drive.
It is a 3D-coordinate system made out of a vertical coordinate head, a horizontal (or radial) coordinate cylinder, and an angular coordinate sector. Head selects a circular surface: a platter in the disk (and one of its two sides). Cylinder is a cylindrical intersection through the stack of platters in a disk, centered around the disk's spindle. Combined, cylinder and head intersect to a circular line, or more precisely: a circular strip of physical data blocks called track. Sector finally selects which data block in this track is to be addressed, as the track is subdivided into several equally-sized portions, each of which is an arc of (360/n) degrees, where n is the number of sectors in the track.
CHS addresses were exposed, instead of simple linear addresses (going from 0 to the total block count on disk - 1), because early hard drives didn't come with an embedded disk controller, that would hide the physical layout. A separate generic controller card was used, so that the operating system had to know the exact physical "geometry" of the specific drive attached to the controller, to correctly address data blocks. The traditional limits were 512 bytes/sector × 63 sectors/track × 255 heads (tracks/cylinder) × 1024 cylinders, resulting in a limit of 8032.5 MiB for the total capacity of a disk.
As the geometry became more complicated (for example, with the introduction of zone bit recording) and drive sizes grew over time, the CHS addressing method became restrictive. Since the late 1980s, hard drives began shipping with an embedded disk controller that had good knowledge of the physical geometry; they would however report a false geometry to the computer, e.g., a larger number of heads than actually present, to gain more addressable space. These logical CHS values would be translated by the controller, thus CHS addressing no longer corresponded to any physical attributes of the drive.
By the mid-1990s, hard drive interfaces replaced the CHS scheme with logical block addressing (LBA), but many tools for manipulating the master boot record (MBR) partition table still aligned partitions to cylinder boundaries; thus, artifacts of CHS addressing were still seen in partitioning software by the late 2000s.
The most common physical sector size for hard disks today is 512 bytes, but there have been hard disks with 520 bytes per sector as well for non-IBM compatible machines. In 2005 some Seagate custom hard disks used sector sizes of 1024 bytes per sector.
Advanced Format hard disks use 4096 bytes per physical sector (4Kn) since 2010, but will also be able to emulate 512 byte sectors (512e) for a transitional period.
Magneto-optical drives use sector sizes of 512 and 1024 bytes on 5.25-inch drives and 512 and 2048 bytes on 3.5-inch drives.<!-- TBD: Will have to recheck if these are actually emulated on this low level: Emulated physical sector sizes of 128, 256, 512 are also seen on some computers with bootable RAM or flash disks, e.g., the Atari Portfolio. -->
In CHS addressing the sector numbers always start at 1; there is no sector 0.
For physical disk geometries the maximal sector number is determined by the low level format of the disk. However, for disk access with the BIOS of IBM PC compatible machines, the sector number was encoded in six bits, resulting in a maximal number of 111111 (63) sectors per track. This maximum is still in use for virtual CHS geometries.
Tracks
The tracks are the thin concentric circular strips of sectors. At least one head is required to read a single track. With respect to disk geometries the terms track and cylinder are closely related. For a single or double sided floppy disk track is the common term; and for more than two heads cylinder is the common term. Strictly speaking a track is a given <code><abbr title="Cylinder">C</abbr><abbr title="Head">H</abbr></code> combination consisting of<code><abbr title="Sectors Per Track">SPT</abbr></code> sectors, while a cylinder consists of<code>SPT×<abbr title="Heads">H</abbr></code> sectors.
Cylinders
A cylinder is a division of data in a disk drive, as used in the CHS addressing mode of a fixed-block architecture (FBA) disk or the cylinder–head–record (CCHHR) addressing mode of a CKD disk.
The concept is concentric, hollow, cylindrical slices through the physical disks (platters), collecting the respective circular tracks aligned through the stack of platters. The number of cylinders of a disk drive exactly equals the number of tracks on a single surface in the drive. It comprises the same track number on each platter, spanning all such tracks across each platter surface that is able to store data (without regard to whether or not the track is "bad"). Cylinders are vertically formed by tracks. In other words, track 12 on platter 0 plus track 12 on platter 1 etc. is cylinder 12.
Other forms of Direct Access Storage Device (DASD), such as drum memory devices or the IBM 2321 Data Cell, might give blocks addresses that include a cylinder address, although the cylinder address doesn't select a (geometric) cylindrical slice of the device.
Heads
A device called a head reads and writes data in a hard drive by manipulating the magnetic medium that composes the surface of an associated disk platter. Naturally, a platter has 2 sides and thus 2 surfaces on which data can be manipulated; usually there are 2 heads per platter, one per side. (Sometimes the term side is substituted for head, since platters might be separated from their head assemblies, as with the removable media of a floppy drive.)
The <code><abbr title="Cylinder">C</abbr><abbr title="Head">H</abbr><abbr title="Sector">S</abbr></code> addressing supported in IBM-PC compatible BIOSes code used eight bits for a maximum of 256 heads counted as head 0 up to 255 (<code>FFh</code>). However, a bug in all versions of MS-DOS / IBM PC DOS up to and including 7.10 will cause these operating systems to crash on boot when encountering volumes with 256 heads. Therefore, all compatible BIOSes will use mappings with up to 255 heads (<code>00h..FEh</code>) only, including in virtual <code>255×63</code> geometries. This historical oddity can affect the maximum disk size:
<code>(512 bytes/sector)×(63 sectors/track)×(255 heads (tracks/cylinder))×(1024 cylinders)=8032.5</code> MiB, but actually <code>512×63×256×1024=8064</code> MiB yields what is known as 8 GB limit.
CHS addressing starts at <code>0/0/1</code> with a maximal value <code>1023/255/63</code> for <code>24=10+8+6</code> bits, or <code>1023/254/63</code> for 24 bits limited to 255 heads. CHS values used to specify the geometry of a disk have to count cylinder 0 and head 0 resulting in
a maximum (<code>1024/256/63</code> or) <code>1024/255/63</code> for 24 bits with (256 or) 255 heads. In CHS tuples specifying a geometry S actually means sectors per track, and where the (virtual) geometry still matches the capacity the disk contains <code>C×H×S</code> sectors. As larger hard disks have come into use, a cylinder has become also a logical disk structure, standardised at 16 065 sectors (<code>16065=255×63</code>).
CHS addressing with 28 bits (EIDE and ATA-2) permits eight bits for sectors still starting at 1, i.e., sectors 1...255, four bits for heads 0...15, and sixteen bits for cylinders 0...65535. This results in a roughly 128 GB limit; actually <code>65536×16×255=267386880</code> sectors corresponding to 130560 MiB for a sector size of 512 bytes. The <code>28=16+4+8</code> bits in the ATA-2 specification are also covered by Ralf Brown's Interrupt List, and an old working draft of this now expired standard was published.
With an old BIOS limit of 1024 cylinders and the ATA limit of 16 heads the combined effect was <code>1024×16×63=1032192</code> sectors, i.e., a 504 MiB limit for sector size 512. BIOS translation schemes known as <abbr title="Extended CHS">ECHS</abbr> and revised ECHS mitigated this limitation by using 128 or 240 instead of 16 heads, simultaneously reducing the numbers of cylinders and sectors to fit into <code>1024/128/63</code> (ECHS limit: 4032 MiB) or <code>1024/240/63</code> (revised ECHS limit: 7560 MiB) for the given total number of sectors on a disk. displayed partition sizes using 1024-byte blocks.
Clusters are allocation units for data on various file systems (FAT, NTFS, etc.), where data mainly consists of files. Clusters are not directly affected by the physical or virtual geometry of the disk, i.e., a cluster can begin at a sector near the end of a given <code><abbr title="Cylinder">C</abbr><abbr title="Head">H</abbr></code> track, and end in a sector on the physically or logically next <code><abbr title="Cylinder">C</abbr><abbr title="Head">H</abbr></code> track.
CHS to LBA mapping
In 2002 the ATA-6 specification introduced an optional 48 bits Logical Block Addressing and declared CHS addressing as obsolete, but still allowed to implement the ATA-5 translations. Unsurprisingly the CHS to LBA translation formula given below also matches the last ATA-5 CHS translation. In the ATA-5 specification CHS support was mandatory for up to 16 514 064 sectors and optional for larger disks. The ATA-5 limit corresponds to CHS <code>16383 16 63</code> or equivalent disk capacities , and requires ().
CHS tuples can be mapped onto LBA addresses using the following formula:
<math display=block>A = (c \times N_\mathrm{heads} + h) \times N_\mathrm{sectors} + (s-1),</math>
where is the LBA address, is the number of heads on the disk, is the maximum number of sectors per track, and is the CHS address.
A Logical Sector Number formula in the ECMA-107 (superseding ISO 9293:1987) standards for FAT file systems matches exactly the LBA formula given above: Logical Block Address and Logical Sector Number (LSN) are synonyms.
See also
- CD-ROM format
- Block (data storage)
- Disk storage
- Disk formatting
- File Allocation Table
- Disk partitioning
References
Notes
:1.This rule is true at least for all formats where the physical sectors are named 1 upwards. However, there are a few odd floppy formats (e.g., the 640 KB format used by BBC Master 512 with DOS Plus 2.1), where the first sector in a track is named "0" not "1".<!-- So, is this rule above really universal or does it only apply to the former type of formats starting with sector "1"? -->
:2.While computers begin counting at 0, DOS would begin counting at 1. In order to do this, DOS would add a 1 to the head count before displaying it on the screen. However, instead of converting the 8-bit unsigned integer to a larger size (such as a 16-bit integer) first, DOS just added the 1. This would overflow a head count of 255 (<code>0xFF</code>) into 0 (<code>0x100 & 0xFF = 0x00</code>) instead of the 256 that would be expected. This was fixed with DOS 8<!-- or 7.11 if there was one -->, but by then, it had become a de facto standard to not use a head value of 255.
