Disk geometry salad...
strick at covad.net
Tue Jun 1 07:23:42 PDT 2004
On Tue, 01 Jun 2004 13:37:49 +0200, roman wrote:
> I have two Western Digital hard drives, (1) WD400BB (40GB) and (2)
> WD300BB (30GB) and an Asus CUS-L2C motherboard (Intel 815EP chipset).
> The manufacturer website doesn't provide the CHS geometry for the
> drives, but lists the number of LBA sectors for each drive. For (1) it's
> 78,165,360 sectors * 512 bytes resulting in about 40.02 GB. For (2) it's
> 58,633,344 sectors * 512 bytes resulting in about 30.02 GB.
> On the first drive I currently have Windows XP, the second drive is empty.
> Western Digital's diagnostic utility for Windows detects the CHS
> geometry of the drives as (1) 4865/255/63 and (2) 3649/255/63 and
> confirms that the number of LBA sectors is identical to the manufacturer
> FreeBSD 5.2.1 detects the CHS geometry (When it boots, there's a listing
> of the hard drives and the CHS geometry, but no LBA sectors) as (1)
> 77545/16/63 and (2) 58168/16/63.
> I have several questions regarding this.
> 1) What is the difference between a geometry of 58168/16/63 and
> 3649/255/63, why did the diagnostic utility detect the latter form,
> while FreeBSD detected the former (Also, Linux 2.4 detects the geometry
> as 3649/255/63)?
The c/h/s data format used to pass a disk sector address to an ATA disk
drive permits at most 65536 cylinders, 16 heads and 255 sectors per track.
The data format used by an ATA disk to report its c/h/s geometry permits
at most 65535 cylinders. It also reports its sector capacity and maximum
addressable LBA block number in 32 bit fields. This geometry is usually
somewhat artificial and may be changed by the host system.
The c/h/s data format used to pass a disk sector address to a BIOS disk
service routine permits at most 1024 cylinders, 255 heads and 63 sectors
per track. In order to maximize the number of disk sectors that can be
addressed using the BIOS interface, a BIOS often reports a disk geometry
different than what the disk reports to the BIOS and uses that "BIOS"
geometry when interpreting disk addresses specified in BIOS function
calls. A BIOS geometry usually has 255 heads and 63 sectors per track
because that produces the largest addressable disk size.
>From the information you have provided I cannot be certain how the
numbers you report were generated, but I can speculate. The ATA disk
might report a default geometry with 16 heads and 63 sectors per track
because those numbers can be used with both ATA and BIOS geometries.
The ATA disk cannot report more than 65535 cylinders, but it can report
the actual disk capacity in sectors. If FreeBSD were to divide the ATA
disk capacity by the cylinder size (#heads * #sectors), it might
conclude that the 40GB drive has 77545 cylinders. Since such a large
cylinder number cannot be specified in c/h/s format, the driver must
be using LBA format when issuing read/write commands.
If you divide the 40 GB drive capacity by the typical BIOS cylinder size,
you get 4865 cylinders. That is probably where the disk geometry
"4865/255/63" comes from. Since cylinder numbers above 1023 cannot
be passed to BIOS function calls, the "extended" BIOS functions which
use 28 bit LBA addressing must be used to access the entire drive.
The common FreeBSD bootstrap program uses the BIOS disk functions with
c/h/s addressing by default and therefore cannot access more than
1024*255*63 sectors, a little under 8 GB, unless it is reconfigured
with the "boot0cfg" command to use the extended BIOS disk functions.
It is often hard to tell exactly what a particular BIOS and bootstrap
configuration are doing. You may be able to avoid confusing bootstrap
problems by keeping all disk partitions used for booting inside the
first 1024*255*63 sectors.
> 2) When installing FreeBSD, sysinstall warns that a geometry of the
> first drive (1) as it detects it (77545/16/63) is incorrect and can't be
> used. It automatically replaces the values with 4865/255/63. The problem
> is that after replacing the geometry with 4865/255/63 the number of LBA
> sectors (as listed in the Disk Slice editor) becomes lower than the
> manufacturer spec (78,156,225 instead of 78,165,360). What does this mean?
Sysinstall, which probably uses BIOS geometry, apparently knows that a
geometry with so many cylinders cannot be correct. It apparently guessed
255 heads and 63 sectors per track and computed the largest number of
cylinders that would produce a disk capacity that did not exceed the
capacity specified by the original geometry. Since you can't have a
fraction of a cylinder, you often lose access to a few sectors when you
convert the disk geometry. This beats getting an I/O error because you
rounded the number of cylinders up instead of down. I don't know why
sysinstall seems to tolerate 4865 (more than 1024) cylinders.
(Note: a BIOS usually uses a geometry with 255 heads and 63 sectors per
track but could choose to use a smaller number of heads or sectors.
It is possible to ask the BIOS what geometry it is using, but this may
not be easily done after FreeBSD boots. I suspect the sysinstall
program is just guessing the BIOS geometry.)
> 3) I tried installing FreeBSD on the second drive. Sysinstall didn't
> complain about the geometry of 58168/16/63 and I was able to install.
> The interesting thing is that when I started the installation program of
> Fedora Core Linux (Had to check something, and it was FC1 which means
> 2.4 kernel) it complained about an incorrect partition table that was
> generated by a tool that didn't have the right BIOS geometry. When I
> reinstalled FreeBSD on the same drive, but changed the geometry from
> 58168/16/63 to 3649/255/63, and launched the Fedora Core setup again -
> it didn't complain! Why is that?
I pass on this question. BIOS geometry confusion is hard to resolve.
More information about the freebsd-questions