The problem
Suppose you have a disk with more than 1024 cylinders. Suppose moreover thatyou have an operating system that uses the BIOS. Then you have a problem,because the usual INT13 BIOS interface to disk I/O uses a 10-bit field for thecylinder on which the I/O is done, so that cylinders 1024 and past areinaccessible. Fortunately, Linux does not use the BIOS, so there is no problem.
Well, except for two things:(1) When you boot your system, Linux isn’t running yet and cannot save you fromBIOS problems.This has some consequences for LILO and similar boot loaders. It is necessary for all operating systems that use one disk to agree onwhere the partitions are.In other words, if you use both Linux and, say, DOS onone disk, then both must interpret the partition table in the same way.This hassome consequences for the Linux kernel and for fdisk. Below a rather detailed description of all relevant details.Note that I usedkernel version 2.0.8 source as a reference. Other versions may differ a bit.
Booting
When the system is booted, the BIOS reads sector 0 (known as the MBR – theMaster Boot Record) from the first disk (or from floppy), and jumps to the codefound there – usually some bootstrap loader.These small bootstrap programs foundthere typically have no own disk drivers and use BIOS services.This means that aLinux kernel can only be booted when it is entirely located within the first1024 cylinders.
This problem is very easily solved: make sure that the kernel (and perhaps otherfiles used during bootup, such as LILO map files) are located on a partitionthat is entirely contained in the first 1024 cylinders of a disk that the BIOScan access – probably this means the first or second disk. Another point is that the boot loader and the BIOS must agree as to the diskgeometry.It may help to give LILO the `linear’ option. More details below. Disk geometry and partitionsIf you have several operating systems on your disks, then each uses one or moredisk partitions.A disagreement on where these partitions are may havecatastrophic consequences.
Thus, this information is redundant: the location of a partition is given bothby the 24-bit begin and end fields, and by the 32-bit start and length fields. Linux only uses the start and length fields, and can therefore handle partitionsof not more than 2^32 sectors, that is, partitions of at most 2 TB.That is twohundred times larger than the disks available today, so maybe it will be enoughfor the next ten years or so.
Unfortunately, the BIOS INT13 call uses CHS coded in three bytes, with 10 bitsfor the cylinder number, 8 bits for the head number, and 6 bits for the tracksector number.Possible cylinder numbers are 0-1023, possible head numbers are 0-255, and possible track sector numbers are 1-63 (yes, sectors on a track arecounted from 1, not 0). With these 24 bits one can address 8455716864 bytes(7.875 GB), two hundred times larger than the disks available in 1983.
Even more unfortunately, the standard IDE interface allows 256 sectors/track,65536 cylinders and 16 heads.This in itself allows access to 2^37 = 137438953472bytes (128 GB), but combined with the BIOS restriction to 63 sectors and 1024cylinders only 528482304 bytes (504 MB) remain addressable. This is not enough for present-day disks, and people resort to all kinds oftrickery, both in hardware and in software. Translation and Disk ManagersNobody is interested in what the `real’ geometry of a disk is. Indeed, thenumber of sectors per track often is variable – there are more sectors per trackclose to the outer rim of the disk – so there is no `real’ number of sectors pertrack.
For the user it is best to regard a disk as just a linear array of sectorsnumbered 0, 1, …, and leave it to the controller to find out where a givensector lives on the disk. This linear numbering is known as LBA.The linear address belonging to (c,h,s)for a disk with geometry (C,H,S) is c*H*S + h*S + (s-1). All SCSI controllersspeak LBA, and some IDE controllers do. If the BIOS converts the 24-bit (c,h,s) to LBA and feeds that to a controllerthat understands LBA, then again 7.875 GB is addressable. Not enough for alldisks, but still an improvement.Note that here CHS, as used by the BIOS, nolonger has any relation to `reality’.