2

Before LBA you simply had the physical mapping of a disk, which originally disk access with the BIOS on an old a IBM-PC compatible machine would look something like this the following:

  • Cylinder Number : (10b)
    • 0-1024 (1024 = 2^10)
  • Head Number: (8b)
    • 0-256 (256 = 2^8)
  • Sector Number : (6b)
    • 0 is reserved typically for the "boot sector" (c-0,h-0,s-0)
    • 1-64 (63 = 2^6 - 1) *0 is reserved

Total CHS address : 24b (10+8+6)


Back in day the average (file|block|sector) size was 512B.

Example from wikipedia:

512(bytes) × 63(sectors) x 256(heads) × 1024(cylinders) = 8064 MiB (yields what is known as 8 GiB limit) 

What I'm confused on is what a head actually means, when referred to as heads-per-cylinder in the LBA formula. It doesn't make sense to me because from what I know a head is head, and unless it removable media each platter has two of them (top,bottom) one for each of the it's surfaces.

enter image description here

In my mind it would make more since to referred to them as heads-per-disk or heads-per-surface, since a cylinder goes through the entire disk (multiple platters).

enter image description here


Logical Block Addressing:

Formula: A = (c ⋅ Nheads + h) ⋅ Nsectors + (s − 1)

  • A - Logical Block Address
  • Nheads - Number of heads on a disk heads-per-disk
  • Nsectors - Numbers of sectors on a track sectors-per-track
  • c,h,s - is the cylinder,head,sector numbers 24-bits total (10+8+6)

Looking at the first example on here:

For geometry 1020 16 63 of a disk with 1028160 sectors CHS 3 2 1 is LBA  3150=(3× 16+2)× 63

Geometry: (this is defined by the manufacturer)

  • Cylinders - 1020
  • Heads- 16
  • Sectors - 63

2 Answers 2

8

Overall you are rather sloppy with terminology, so that is a source of further confusion.

1024 bit addressable number (1024 = 2^10)

The IBM PC/XT used a Western Digital WD1010 disk controller that used (in hardware registers) a 10-bit cylinder number.
The first cylinder has address 0, so there are 1024 cylinder addresses.
"Addressable number" is nonsensical.

-1 for the "boot sector" (c-0,h-0,s-0)
63 bit addressable number (63 = 2^6 - 1)

The first sector (of every track) is address 1, so a 6-bit sector number can address up to 63 sectors (sector numbers 1 through 63) on each track.
There is no sector address zero. It's not reserved. It doesn't exist.
The subtraction of this offset is an arithmetic necessity, and is not related in any way to the boot sector. The use of the first sector (or any sector) of the disk drive for booting (or any function) is irrelevant to need for subtracting the starting offset.

So I get you can get a theoretical maximum address of the following:

512(bytes) × 63(sectors) x 256(heads) × 1024(cylinders) = 8064 MiB

No, that is a maximum capacity.
Disk addresses are for sectors, not bytes.

I understand the head number is an 246 bit addressable number...

Huh??? An "addressable number"???
One of the drive parameters is the number of heads (in a cylinder).
One of the numbers in a CHS address is the head number.
246 bits???

What I'm confused on is what a head actually is when it is referred to as heads-per-track.

Heads-per-track is something you made up, as there is no such parameter for the typical HDD used in a PC (i.e. that number would always be unity).
A specific track would be read and written by only one specific R/W head.
There's one R/W head per surface. (You're not likely to use a dual-port drive.)
The R/W head is mounted on the end of an arm.
All of the R/W heads and arms comprise an assembly that is moved/rotated by an actuator.
(But there have also been fixed-head disk drives, e.g. one head per track, that have zero seek time.)

These terms don't makes any sense to me because from what I know a head is, (the actual arm that does the read/writes) and unless it removable media each platter has two of them (top,bottom) so it really would makes more since to referred to them as heads-per-platter or heads-per-disk... and really it should be sectors-per-track, right?

Then apparently you're confused as to what a head is.
You are also confusing "platter" with "surface".
There's no requirement that both sides of a platter must be used, so each surface is treated as a unit, rather than the platter as a unit.
There is a drive parameter called sectors per track.

Now this term heads-per-track appears when you looks at the conversion from CHS-to-LBA.

Again, something you seemed to have made up. Heads per track is unity.

but how does the geometry 1020,16,63 translate to CHS 3,2,1 can someone please explain it to me?

LBA is a sector address.
CHS is also a sector address.
In order to convert one style of address to the other, you need to specify the drive geometry:

. number of cylinders  
. number of heads (per cylinder)  
. number of sectors per track

You cannot *translate * the geometry to an address; you use the geometry to convert an address.
CHS address3,2,1 is equivalent to LBA address 3150 if the drive geometry is 1020,16,63.


ADDENDUM for the revised Question

In my mind it would make more since to referred to them as heads-per-disk or heads-per-surface, since a cylinder goes through the entire disk (multiple platters).

Of the numerous technical documents (from the disk drive manufacturers) that I have read, the specifications table for a (single-port) drive would list the number of R/W heads and the number of platters. There never was a ratio of heads per disk, heads per surface, or heads per platter.

In my work as a software/firmware engineer developing controller firmware, device drivers for disks, and filesystem handlers, I never was concerned with or had to use the number of platters. The number of platters or that there are two possible surfaces to a platter are mechanical properties that are totally irrelevant to the drive geometry for CHS addressing.

The C in CHS refers to the cylinder address. The disk drive has to (electro-mechanically) seek to the requested cylinder address/location so that the R/W head assembly is positioned correctly.

The H in CHS refers to the R/W head address. The disk controller (electrically) selects the requested R/W head (after the seek is complete) by its address to access the correct track. All other R/W heads are (electrically) disabled.

The S in CHS refers to the sector address. The disk controller (programmatically) scans each sector (after the seek and head selection) as it rotates under the (selected) R/W head, until the requested sector is located (e.g. reads the ID record of the sector, and performs an address comparison).

Also
If you're familiar with Dimensional Analysis, specifying the number of heads of a disk drive as heads per cylinder makes more sense than heads per drive.

I understand the geometry CHS numbers, but where are the (3,2,1) tuple CHS numbers coming from?

That's just an arbitrary CHS address chosen for use in examples of conversions to LBA addresses.

BTW
In end-user jargon, "disk" == disk drive.
In professional HDD jargon, "disk" == disk platter.

15
  • Yes I should of made the CHS numbering clearer at the top... I'll edit it out. Commented Sep 18, 2015 at 2:50
  • If you read what I wrote, I said it doesn't make since that people were listing heads-per-track Commented Sep 18, 2015 at 2:51
  • A platter has two surfaces.... no requirement yes... but if it's not removable media it "typically" has 2 heads 1 for the top and 1 for the bottom, No? en.wikipedia.org/wiki/Cylinder-head-sector Commented Sep 18, 2015 at 2:53
  • Didn't know that there are fixed-head disk drives interesting I'll look it up... but isn't it typically disk now a day an actuator arm that moves the head on a "side" or for your sake "surface" of a platter. Commented Sep 18, 2015 at 2:58
  • There are (2) - heads-per-platter "typically" that do the read/write so why the hell is it the number of heads (per cylinder) this is what I don't get? Commented Sep 18, 2015 at 3:00
0

Here is a convenient quick summary of conversion, historical quirks, and proper terminology implemented in python. Upper case specifies geometry, lower case specifies the (c,h,s) components of a sector address.

The default (C,H,S) geometry gives values typically used for modern large disks at early boot for MBR/BIOS style booting.

def chs(lba,C=1024,H=255,S=63):
  """
  'lba' linearly addresses sector, indexing from zero.
  'C','H','S' specify geometry - fixed for a given disk:
     1 <= C <= 1024 (10 bits)
     1 <= H <= 255  (8 bits) not 256 due to WD1010 quirk
     1 <= S <= 63   (6 Bits) not 64 due to WD1010 quirk
   Returns address as c,h,s tuple:
     0 <= c <= 1023 (10 bits) modulo C
     0 <= h <= 255  (8 bits) modulo H
     1 <= s <= 63   (6 Bits) not 64 due to WD1010 quirk
  """
  if C<1 or H<1 or S<1 or C>1024 or H>255 or S>63:
    raise ValueError, \
      "Invalid (C,H,S) geometry: ({},{},{})". \
        format(C,H,S)
  t,s = divmod(lba,S); s+=1 # tracks, sector offset
  c,h = divmod(t,H)
  if c>=C: raise ValueError, \
    "Unaddressable lba value: {} for ({},{},{}) geometry.". \
      format(lba,C,H,S)
  return (c,h,s)

def lba(c,h,s,C=1024,H=255,S=63):
  """
  'C','H','S' specify geometry as for function 'chs'.
  'c','h','s' address a sector in this geometry.
  """
  if C<1 or H<1 or S<1 or C>1024 or H>255 or S>63:
    raise ValueError, \
      "Invalid (C,H,S) geometry: ({},{},{})". \
         format(C,H,S)
  if c<0 or h<0 or s<1 or c>=C or h>=H or s>S:
    raise ValueError, \
      "Unaddressable (c,h,s) value: ({},{},{}) for ({},{},{}) geometry.". \
         format(c,h,s,C,H,S)
  return (c*H+h)*S+(s-1)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .