Cylinder-head-sector disk addressing: addressable range, direct use, compatibility issues and conversion between coordinate systems.
Cylinder-head-sector (CHS) addressing was commonly used for hard disks on the IBM PC compatible platform, until it was gradually displaced by logical block addressing throughout the late 1990s and 2000s. CHS uses three coordinates to identify sectors: zero-based cylinder number, zero-based head number and one-based sector number, which together originally referred to the position of the sector on the rotating drive platters; over time, it became a mostly symbolic and customary assignment. The alternative, logical block addressing (LBA, also called linear addressing), uses just one, contiguous, zero-based coordinate, whose mapping to a physical position on the disk is considered an internal implementation detail.
Originally, sectors on PC hard drives were addressed using CHS coordinates, both at the disk controller level and at the BIOS level. However, the two interfaces set different limits as to the maximum values those coordinates could attain:
- ATA set the limits at 65536 cylinders, 16 heads and 255 sectors per track;
- The BIOS interrupt 0x13 interface set the limits at 1024 cylinders, 256 heads and 63 sectors per track. (In practice, the number of heads had to be limited at 255, since 256 heads tended to trigger overflow bugs in some operating systems.)
As disks grew in size, those limits were rapidly approached, especially the latter ones. In order to keep software written against the BIOS interface running, it was necessary to translate sector coordinates communicated to the disk controller into CHS coordinates used by interrupt 0x13 services. The latter are called logical CHS (LCHS), while the former kind of CHS coordinates is conventionally referred to as physical CHS (although this has become something of a misnomer anyway, as it doesn’t necessarily correspond to actual layout of sectors on disk platters either). Translation to and from logical CHS was also necessary for SCSI drives, which have only ever used linear addressing at the controller level and did not expose internal geometry to the host at all. The use of different coordinate systems made them easy to confuse, especially that the system in use was rarely explicitly labelled.
A number of schemes for CHS translation were devised, giving rise to different addressability limits:
- Without any translation, the BIOS can only address sectors within the intersection of both limits, which is 1024 cylinders × 16 heads × 63 sectors per track = 16450560 sectors = 504 MiB.
- In the scheme known as ‘Extended CHS’ (‘ECHS’) or ‘LARGE’, the number of cylinders is repeatedly halved, while the number of heads is simultaneously doubled, until either the number of cylinders fits or the number of heads is at least 128. The maximum addressable size in this scheme is 1024 cylinders × 128 heads × 63 sectors per track = 8257536 sectors = 4032 MiB.
- In the scheme known as ‘Revised Extended CHS’ (‘RECHS’), the number of heads is fixed at 15 and the number of cylinders is recomputed to match. Then simultaneous doubling-and-halving is performed like in ECHS. This scheme was mostly used by Compaq systems. The maximum size addressable in this scheme is 1024 cylinders × 240 heads × 63 sectors per track = 15482880 sectors = 7560 MiB.
- In the scheme known as ‘LBA-assisted’ or simply ‘LBA’, the number of sectors per track is fixed at 63, while the number of heads is fixed at 255. The number of cylinders is then computed to match. This scheme was typically used for SCSI drives, and gradually became the most popular one for ATA drives during the 2000s. The maximum addressable size with this translation scheme is 1024 cylinders × 255 heads × 63 sectors per track = 8032.5 MiB.
Users stuck with BIOSes that do not support for LBA disk access or CHS translation had to resort to installing dynamic drive overlay (also disk overlay, DDO) programs: those drivers were set up to load before the boot loader proper and intercepted 0x13 service calls in order to service them from their own code, to provide CHS translation and extended (LBA-based) interrupt 0x13 calls.
Though no longer common in modern systems, BIOS interrupt call 0x13 and CHS addressing are often used by bootloaders to access disks in the course of performing their task on pre-UEFI systems; the boot loader of Windows as late as XP can make use of the CHS-based BIOS calls. Interrupt 0x13 is also the native, built-in back-end of file system calls of MS-DOS and its clones like FreeDOS.
The OS/2 Museum article ‘Geometry problems’ covers some of the history of CHS addressing, including the compatibility problems it caused.