CHS To LBA Mapping
CHS tuples can be mapped onto LBA (Logical Block Addressing) addresses using the following formula:
Where is the LBA address, is the number of heads on the disk, is the number of sectors per track, and is the CHS address.
A Logical Sector Number formula in the ECMA-107 and ISO/IEC 9293:1994 (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. The formula does not use the number of cylinders, but requires the number of heads and the number of sectors per track in the disk geometry, because the same CHS tuple addresses different logical sector numbers depending on the geometry. Examples:
- For geometry
1020 16 63
of a disk with 1028160 sectors CHS3 2 1
is LBA 3150=(3* 16+2)* 63 - For geometry
1008 4 255
of a disk with 1028160 sectors CHS3 2 1
is LBA 3570=(3* 4+2)*255 - For geometry
64 255 63
of a disk with 1028160 sectors CHS3 2 1
is LBA 48321=(3*255+2)* 63 - For geometry
2142 15 32
of a disk with 1028160 sectors CHS3 2 1
is LBA 1504=(3* 15+2)* 32
To help visualize the sequencing of sectors into a linear LBA model, note that;
- The first LBA sector is sector # zero, the same sector in a CHS model is called sector # one.
- All the sectors of each head/track get counted before incrementing to the next head/track.
- All the heads/tracks of the same cylinder get counted before incrementing to the next cylinder.
- The outside half of a whole Hard Drive would be the first half of the drive.
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 above 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 16383 16 63
or equivalent disk capacities (16514064=16383×16×63=1032×254×63), and requires 24=14+4+6 bits (16383+1=214).
Read more about this topic: Cylinder-head-sector