CHS to LBA mapping - (Disk Storage)

10,473

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.

Share:
10,473

Related videos on Youtube

Jordan Davis
Author by

Jordan Davis

If you rely on frameworks don't state you know how to code, because if you did, you wouldn't be using one.

Updated on September 18, 2022

Comments

  • Jordan Davis
    Jordan Davis over 1 year

    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
  • Jordan Davis
    Jordan Davis over 8 years
    Yes I should of made the CHS numbering clearer at the top... I'll edit it out.
  • Jordan Davis
    Jordan Davis over 8 years
    If you read what I wrote, I said it doesn't make since that people were listing heads-per-track
  • Jordan Davis
    Jordan Davis over 8 years
    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
  • Jordan Davis
    Jordan Davis over 8 years
    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.
  • Jordan Davis
    Jordan Davis over 8 years
    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?
  • Jordan Davis
    Jordan Davis over 8 years
    Typically the "fist sector" of a disk is reserved for a "boot record" en.wikipedia.org/wiki/Master_boot_record
  • sawdust
    sawdust over 8 years
    FYI I developed disk controller firmware for a few years, and developed projects with 14", 8", 5.25" and 3.5" disk drives. Never have I heard any professional utter "heads per platter"; it's nonsensical. There's a head per surface, but not every surface is used. The only time "heads per surface" would make sense is in a multi-port drive.
  • Jordan Davis
    Jordan Davis over 8 years
    so basically your saying heads-per-surface relating to the surfaces of the a platter.... and although you might not use the head on every surface, there is "typically" 2-heads per "platter"? or are you saying wikipedia is way off in declaring that non-removable media has 2-heads per surface.
  • Jordan Davis
    Jordan Davis over 8 years
    another reference to the first sector being related to the "boot sector" win.tue.nl/~aeb/linux/fs/fat/fat-1.html
  • Jordan Davis
    Jordan Davis over 8 years
    A disk has a platter(s) and each platter has 2-surfaces (top,bottom) with each surface contain a head to read/write, a cylinder runs through the entire disk going through every platter...
  • sawdust
    sawdust over 8 years
    "are you saying wikipedia is way off in declaring that non-removable media has 2-heads per surface." -- If (and only if) you have quoted Wikipedia accurately (2 heads per surface), then it is wrong. FWIW I have worked on (SMD) drives that had 12 platters and 19 R/W heads (2 platters are not used at all and 1 surface is for servo). Some models of modern HDDs are known to have unused surface(s). A platter may have one surface with too many defects but the other side is good; so these platters are salvaged and installed in a drive with an odd number of heads..
  • Jordan Davis
    Jordan Davis over 8 years
    I think I've figure my problem, the sector sizes our defined by the manufacturer, correct? As in if the manufacture says 512B you can't change it, but logically you associate sectors together to say 4KB for instance? Yea your right if drives ship with 12 platts and 19R/W should def be referring to surface like you said.
  • Jordan Davis
    Jordan Davis over 8 years
    Nvm I still don't get it... In the example geometry I declare 1024, 16, 63. So drive for that example has 1024 cylinders or more, and 16 heads or more, and 63 sectors?
  • Jordan Davis
    Jordan Davis over 8 years
    CHS 3,2,1 where does this come from? Don't I already have the address 1024,16,63 to the sector?
  • Jordan Davis
    Jordan Davis over 8 years