LBA and CHS format, LBA mapping
LBA is the abbreviation for Logical Block Address. This simply means the sectors of a disk
are sequentially numbered starting with LBA number 0. Every sector is
identified by its unambigious LBA number. The LBA format is supported by
BIOS (as of 1995) and by UEFI.
The CHS format is the initial BIOS schema for identifying a disk sector.
The CHS format is not used by UEFI.
In the CHS format a sector is identified by its Cylinder/Head/Sector number.
In the beginning these values meant the physical location of the sector on the disk,
later these values became only logical numbers. The (logical) number of cylinders,
heads and sectors per track can be determined by the func. 08h respectively 48h of the
BIOS interrupt 13h. The CHS format is supported
by all the BIOS but it is limited to a disk size of 8 GB (see below).
The CHS format has the following restrictions:
| ||cylinder number|| ||0 - 1023|| ||(10 Bit)
| ||head number|| ||0 - 254|| ||(8 Bit)
| ||sector number|| ||1 - 63|| ||(6 Bit)
Due to a problem in the DOS operating system a maximum head number 255 leads
to a crash although the BIOS would allow this number. Therefore a maximum head
number 255 is not used in general.
Max. disk size:
For the CHS format in the partition table and for calling BIOS funtions
there are in general only 24 bits available. With 24 bits and a sector size
of 512 bytes it is possible to address all sectors of a disk up to a
maximum disk size of 8 GB. For the LBA addressing scheme there are 32 bits
reserved in the partition table. At the same sector size of 512 bytes all
sectors of a disk up to a maximum size of 2048 GB (2 TB) can be addressed.
The extended INT 13h even uses 64 bits for storing the LBA number. Due to
its simpler concept and also the possibility to support larger disks
the LBA format is used internally by all modern operating systems for
the direct disk access.
Conversion between CHS and LBA:
It is possible to covert the LBA format to CHS and vice versa.
Conceptually both forms are equivalent. A sector C/H/S in the CHS
format has the following LBA number:
LBA = C x Num_Head x Num_Sec + H x Num_Sec + (S - 1)
Here Num_Sec means the (logical) number of sectors per
track and Num_Head the (logical) number of heads. Only these
two (logical) geometry parameters of the disk are relevant for the
conversion. The number of cylinders in unimportant for the conversion.
The two conversion parameters Num_Head
and Num_Sec are summarized as LBA mapping.
The LBA mapping determines the conversion between CHS and LBA numbers of a sector.
These two parameters are obtained from the function AH=08h of the standard BIOS
interrupt 13h. Even if the extended interrupt 13h is supported, the LBA mapping
is obtained from the standard INT 13h. The disk parameters which are returned
from the extended INT 13h are useful only to compute the total disk size.
The total disk size is simply the product of the total number
of sectors (number of cylinders x number
of heads x number of sectors/track)
with 512 (the sector size).