- The x86 BIOS: Its Limits and Capabilities
- 16- and 32-Bit Code
- The BIOS as Driver for DOS
- Modern Uses of the BIOS
- What BIOS Do You Have?
- Add-On Card BIOSs
- Video BIOSs
- Boot BIOSs for SCSI and Networking
- Additional BIOSs
- BIOS Updates
- EIDE and SCSI Hard Disk Handling
- Understanding CHS Geometry Limits
- Getting Around the 1024-Cylinder Limit
- Common BIOS Disk Utilities
- The Handoff to the OS
Getting Around the 1024-Cylinder Limit
By 1994, hard drives exceeding 504MB, or even 1GB, were becoming not only desirable, but common. Drives of higher capacity typically reported themselves as having the maximum number of heads and sectors and more than 1024 cylinders. Thus, this problem came to be referred to as the 1024-cylinder limit, and it's still with us today.
The question in 1994 was one of circumventing this limit. Some of the methods I describe later in this chapter were useful in raising the limit, but by 1997 drives exceeding even these raised limits started to become common. Although many modern OSs aren't bothered by the 1024-cylinder limit, and can in fact handle much larger hard disks, portions of the modern BIOS boot code are still plagued by this limit, and this fact has important consequences for OS installation, as discussed in this and the next few chapters.
Ignorance Is Bliss One method of getting around the 1024-cylinder limit is to ignore it. This is a perfectly workable solution for OSs that don't rely on the BIOS for disk access. OS/2 and Linux, for example, even in 1994, could access all of a 1GB or larger disk; these OSs simply use more than 10 bits to represent the number of cylinders on a disk, thus allowing direct access to the disk's full capacity. There are several problems with this solution, however:
To boot an OS, the BIOS must be able to read certain OS files, so those files must fall below the 1024-cylinder limit. Ensuring that this will be the case can be a nuisance.
If you're running a dual-boot system, some OSs might be able to ignore the 1024-cylinder limit and some might not. Those that can't ignore it might become confused by a disk partitioned by the more capable OS or might become confused by the contents of a partition that spans the limits. For this reason, OS/2 won't format a partition that falls even partly past the 1024-cylinder limit for the file allocation table (FAT) filesystem used by DOS, although OS/2 will use its own high-performance filesystem (HPFS) on such partitions.
Even two OSs that can each handle over1024-cylinder drives might have subtle incompatibilities in how they encode partitioning or other data, so they might have problems coexisting on such a system.
Using CHS Geometry Translation One method of handling over1024-cylinder drives was what came to be known as CHS geometry translation or various truncations of that term. Recall that the reason for using only four bits for the head number was that this was a limitation of IDE drives themselves. Internal to the BIOS, an eight-bit field could be used for the head number. CHS geometry translation typically works by taking excess cylinders and turning them into heads. For example, if a drive reports that it has 2000 cylinders and 16 heads, the BIOS can translate this to 1000 cylinders and 32 heads. The total drive capacity remains the same, the BIOS and most software can handle this system, and the total capacity limit is raised to 7.875GB, depending on how vigorously the software translates geometries.
CHS geometry translation was first done using special software BIOS extensions that were stored in the hard disks' boot sectors. Such software programs were frequently designed for DOS and didn't work well with OS/2, Linux, or other OSs. These OSs eventually learned to spot these programs and adjust their own handling of the drive to fit in. Therefore, if you have an old system that uses such software, you can probably continue to use it, even if you're planning to install a new OS. You might want to check the documentation for your new OS to be sure it's safe, though.
Eventually, CHS geometry translation came to be a standard feature in PC BIOSs, so no additional software was required. Similarly, many EIDE add-on controller cards include BIOS extensions that replace or augment the motherboard BIOS's hard disk routines to provide such support. As with software BIOS extensions, though, each OS must be able to play along with this solution. If an OS queries the hard disk directly about its capacity and uses the values returned by the disk itself rather than by the BIOS, the OS will use incorrect values as far as other OSs are concerned.
It's vitally important that all OSs agree on a single CHS geometry for each drive. If two OSs don't agree, they'll write conflicting data in the partition table and can corrupt data structures all over the disk. The end result can be absolutely disastrous. Fortunately, problems like this are rare and are mostly related to old OSs, such as OS/2 2.1, that don't understand modern CHS translation schemes.
Note that CHS geometry translation is a solution applied to IDE and EIDE drives only. Because SCSI drives don't communicate to their host adapters using CHS values, there's little sense in applying such schemes to them. Instead, SCSI host adapters modified their methods of creating CHS values for attached hard drives, as described in the next section.
Using LBA Mode in EIDE and SCSI Drives LBA stands for linear block addressing or logical block addressing, depending on whom you ask. By either name, it refers to a system of hard disk access whereby a single sector number is used instead of a triplet of numbers. The sector number used in EIDE LBA mode is a 28-bit number (from IDE's 16-bit cylinder, 4-bit head number, and 8-bit sector number added together). Therefore, LBA mode supports hard drives of up to 128GB (228 sectors x 512 bytes) in capacity.
SCSI hard drives have always used LBA mode internally and in talking to their host adapters; the SCSI host adapters have been the ones to translate LBA mode into CHS mode. Eventually, EIDE drives began to emulate SCSI drives in this respect. This method of addressing requires that the drive electronics support the change (as is true of most EIDE drives but not the older IDE drives), and it requires support in the BIOS. As with CHS geometry translation, LBA mode results in the capacity to handle hard disks of up to approximately 8GB in size when using old CHS addressing methods (which are still constrained by the BIOS's cylinder, head, and sector number limits), but software that can directly handle LBA mode can use disks of up to 128GB.
In general, LBA mode uses disk space a little more efficiently than does CHS geometry translation because less disk space is lost to rounding errors. Depending on the hardware in use, LBA mode can be slightly faster than CHS geometry translation, as well. Most modern OSs can use LBA mode directly (bypassing the BIOS), but some software, particularly low-level disk utilities, still uses CHS mode.
The plethora of CHS mapping schemes makes it dangerous to move a hard disk from one computer to another. If the original computer used CHS geometry translation and the destination uses LBA mode, the destination computer could easily misinterpret the drive's layout and damage its data. Even if both computers claim to use the same translation scheme, differences in the algorithms used to implement these methods could wreak havoc. For similar reasons, you should never change the translation scheme used on a disk unless you've first deleted all the partitions (thus wiping out all the disk's data). When you've wiped the disk clean and changed the geometry mapping scheme, boot a DOS floppy that contains the DOS FDISK utility and type FDISK /MBR. This undocumented command rewrites low-level disk information to conform to the new disk geometry settings. (DR-DOS's FDISK includes equivalent functionality as a menu item from inside the FDISK utility.) These comments apply to both EIDE and SCSI hard disks.
In recent years, there have been some efforts to get around the 1024-cylinder limit more completely by using LBA mode directly, even in programs that work through the BIOS. That is, instead of using CHS addressing from within programs, use the LBA addressing. This system is known as extended INT13 addressing (INT13 is the name of the BIOS call that's used for CHS disk addressing). The older non-extended INT13 addressing is still used in booting OSs, however, as well as by many older utilities.
The 1024-Cylinder Limit Is Alive and Well Today's hard disks are commonly in excess of 1024 cylinders again, even when CHS geometry translation or LBA mode translations are used, so we must deal with the 1024-cylinder limits all over again. You must ensure that all your bootable partitions fall below the 1024-cylinder limit. To determine what this limit is, start your BIOS setup utility and locate the information on your hard disk. (You must use your SCSI adapter's setup utility if you're booting from a SCSI disk.) Multiply the number of sectors by the number of heads and then divide by 2. That's the location of the 1024-cylinder limit in megabytes.
Fortunately, most OSs today can cope with hard drives with more than 1024 cylinders, or can use extended INT13 addressing. The list of such OSs includes Windows 98. If you have DOS on your system, you should ensure that its partitions fall entirely below the 1024-cylinder limit, just as do your bootable partitions. Microsoft has introduced new partition types for partitions that fall partly or wholly above the 1024th cylinder, but not all OSs understand these partition types, so if you use them, you might not be able to access these partitions from all your OSs.