Sunday, September 4, 2011

Hard Disk

Hard Disk Details

Technical Details:
This section attempts to give you enough basic information about your hard disks and the disk booting process so that you can troubleshoot most problems you might encounter when getting set up to boot several operating systems. It starts in pretty basic terms, so you may want to skim down in this section until it begins to look unfamiliar and then start reading.


Disk Primer

Three fundamental terms are used to describe the location of data on your hard disk: Cylinders, Heads, and Sectors. It is not particularly important to know what these terms relate to except to know that, together, they identify where data is physically on your disk.
Your disk has a particular number of cylinders, number of heads, and number of sectors per cylinder-head (a cylinder-head also known now as a track). Collectively this information defines the “physical disk geometry” for your hard disk. There are typically 512 bytes per sector, and 63 sectors per track, with the number of cylinders and heads varying widely from disk to disk. Thus you can figure the number of bytes of data that will fit on your own disk by calculating:
(# of cylinders) × (# heads) × (63 sectors/track) × (512 bytes/sect)
For example, on my 1.6 Gig Western Digital AC31600 EIDE hard disk, that is:
(3148 cyl) × (16 heads) × (63 sectors/track) × (512 bytes/sect)
which is 1,624,670,208 bytes, or around 1.6 Gig.

The Booting Process

On the first sector of your disk (Cyl 0, Head 0, Sector 1) lives the Master Boot Record (MBR). It contains a map of your disk. It identifies up to 4 partitions, each of which is a contiguous chunk of that disk. FreeBSD calls partitions slices to avoid confusion with its own partitions, but we will not do that here. Each partition can contain its own operating system.

Table 1. Partition IDs
ID (hex) Description
01 Primary DOS12 (12-bit FAT)
04 Primary DOS16 (16-bit FAT)
05 Extended DOS
06 Primary big DOS (> 32MB)
0A OS/2®
83 Linux (EXT2FS)
A5 FreeBSD, NetBSD, 386BSD (UFS)

The dreaded 1024 cylinder limit and how BIOS LBA helps

The first part of the booting process is all done through the BIOS, (if that is a new term to you, the BIOS is a software chip on your system motherboard which provides startup code for your computer). As such, this first part of the process is subject to the limitations of the BIOS interface.
The BIOS interface used to read the hard disk during this period (INT 13H, Subfunction 2) allocates 10 bits to the Cylinder Number, 8 bits to the Head Number, and 6 bits to the Sector Number. This restricts users of this interface (i.e. boot managers hooked into your disk's MBR as well as OS loaders hooked into the Boot Sectors) to the following limits:
  • 1024 cylinders, max
  • 256 heads, max
  • 64 sectors/track, max (actually 63, 0 is not available)
Now big hard disks have lots of cylinders but not a lot of heads, so invariably with big hard disks the number of cylinders is greater than 1024. Given this and the BIOS interface as is, you can not boot off just anywhere on your hard disk. The boot code (the boot manager and the OS loader hooked into all bootable partitions' Boot Sectors) has to reside below cylinder 1024. In fact, if your hard disk is typical and has 16 heads, this equates to:
1024 cyl/disk × 16 heads/disk × 63 sect/(cyl-head) × 512 bytes/sector
which is around the often-mentioned 528MB limit.
This is where BIOS LBA (Logical Block Addressing) comes in. BIOS LBA gives the user of the BIOS API calls access to physical cylinders above 1024 though the BIOS interfaces by redefining a cylinder. That is, it remaps your cylinders and heads, making it appear through the BIOS as though the disk has fewer cylinders and more heads than it actually does. In other words, it takes advantage of the fact that hard disks have relatively few heads and lots of cylinders by shifting the balance between number of cylinders and number of heads so that both numbers lie below the above-mentioned limits (1024 cylinders, 256 heads).
With BIOS LBA, the hard disk size limitation is virtually removed (well, pushed up to 8 Gigabytes anyway). If you have an LBA BIOS, you can put FreeBSD or any OS anywhere you want and not hit the 1024 cylinder limit.
To use my 1.6 Gig Western Digital as an example again, its physical geometry is:
(3148 cyl, 16 heads, 63 sectors/track, 512 bytes/sector)
However, my BIOS LBA remaps this to:
(787 cyl, 64 heads, 63 sectors/track, 512 bytes/sector)
giving the same effective size disk, but with cylinder and head counts within the BIOS API's range (Incidentally, I have both Linux and FreeBSD existing on one of my hard disks above the 1024th physical cylinder, and both operating systems boot fine, thanks to BIOS LBA).

No comments:

Post a Comment