Disk access is done in units called sectors. In order to read or write something from or to the disk, we have to specify the position on the disk, for example by giving the sector number. If the disk is a SCSI disk, then this sector number goes directly into the SCSI command and is understood by the disk. If the disk is an IDE disk using LBA, then precisely the same holds. But if the disk is old, RLL or MFM or IDE from before the LBA times, then the disk hardware expects a triple (cylinder,head,sector) to designate the desired spot on the disk.
A disk has sectors numbered 0, 1, 2, ... This is called LBA addressing.
In ancient times, before the advent of IDE disks, disks had a geometry described by three constants C, H, S: the number of cylinders, the number of heads, the number of sectors per track. The address of a sector was given by three numbers: c, h, s: the cylinder number (between 0 and C-1), the head number (between 0 and H-1), and the sector number within the track (between 1 and S), where for some mysterious reason c and h count from 0, but s counts from 1. This is called CHS addressing.
No disk manufactured less than ten years ago has a geometry, but this ancient 3D sector addressing is still used by the INT13 BIOS interface (with fantasy numbers C, H, S unrelated to any physical reality).
The correspondence between the linear numbering and this 3D notation
is as follows: for a disk with C cylinders, H heads and S sectors/track
position (c,h,s) in 3D or CHS notation
is the same as position
c*
H*
S + h*
S + (s-1)
in linear or LBA notation.
Consequently, in order to access a very old non-SCSI disk, we need to know its geometry, that is, the values of C, H and S. (And if you don't know, there is a lot of good information on www.thetechpage.com.)
In the present text a sector has 512 bytes. This is almost always
true, but for example certain MO disks use a sectorsize of 2048 bytes,
and all capacities given below must be multiplied by four.
(When using fdisk
on such disks, make sure you have version
2.9i or later, and give the `-b 2048' option.)
A disk with C cylinders, H heads and S sectors per track
has C*
H*
S sectors in all, and can store
C*
H*
S*
512 bytes.
For example, if the disk label says C/H/S=4092/16/63
then the disk has 4092*
16*
63=4124736 sectors, and can hold
4124736*
512=2111864832 bytes (2.11 GB).
There is an industry convention to give C/H/S=16383/16/63
for disks larger than 8.4 GB, and the disk size can no longer
be read off from the C/H/S values reported by the disk.
The old INT13 BIOS interface to disk I/O uses 24 bits to address a sector: 10 bits for the cylinder, 8 bits for the head, and 6 bits for the sector number within the track (counting from 1). This means that this interface cannot address more than 1024*256*63 sectors, which is 8.5 GB (with 512-byte sectors). And if the (fantasy) geometry specified for the disk has fewer than 1024 cylinders, or 256 heads, or 63 sectors per track, then this limit will be less.
(More precisely: with INT 13, AH selects the function to perform,
CH is the low 8 bits of the cylinder number, CL
has in bits 7-6 the high two bits of the cylinder number
and in bits 5-0 the sector number, DH
is the head number,
and DL is the drive number (80h or 81h).
This explains part of the layout of the partition table.)
This state of affairs was rectified when the so-called Extended INT13 functions were introduced. A modern BIOS has no problems accessing large disks.
(More precisely: DS:SI points at a 16-byte Disk Address Packet that contains an 8-byte starting absolute block number.)
Linux does not use the BIOS, so does (and did) not have this problem.
However, this geometry stuff plays a role in the interpretation of partition tables, so if Linux shares a disk with for example DOS, then it needs to know what geometry DOS will think the disk has. It also plays a role at boot time, where the BIOS has to load a boot loader, and the boot loader has to load the operating system.
The old ATA standard describes how to address a sector on an IDE disk using 28 bits (8 bits for the sector, 4 for the head, 16 for the cylinder). This means that an IDE disk can have at most 2^28 addressable sectors With 512-byte sectors this is 2^37 bytes, that is, 137.4 GB.
The ATA-6 standard includes a specification how to address past this 2^28 sector boundary. The new standard allows addressing of 2^48 sectors. There is support in recent Linux kernels that have incorporated Andre Hedrick's IDE patch, for example 2.4.18-pre7-ac3 and 2.5.3.
Maxtor sells 160 GB IDE disks since Fall 2001. An old kernel will treat such disks as 137.4 GB disks.