title: CHS to LBA mapping - (Disk Storage)
body: <p>Before LBA you simply had the physical mapping of a disk, which on originally on an old a IBM-PC compatible machine would look something like this the following:</p>
  
  <ul>
  <li><strong><em>Cylinder Number :</em></strong> (10-bits)
  
  <ul>
  <li>0-1024 (1024 = 2^10)</li>
  </ul></li>
  <li><strong><em>Head Number :</em></strong>    (8-bits)
  
  <ul>
  <li>0-256 (256 = 2^8)</li>
  </ul></li>
  <li><strong><em>Sector Number</em> :</strong>  (6-bits) 
  
  <ul>
  <li>0 is reserved typically for the "<em><a href="https://en.wikipedia.org/wiki/Boot_sector" rel="nofollow noreferrer">boot sector</a></em>" (<strong><em>c</em></strong>-0,<strong><em>h</em></strong>-0,<strong><em>s</em></strong>-0) </li>
  <li>1-64 (63 = 2^6 - 1) *0 is reserved</li>
  </ul></li>
  </ul>
  
  <p><strong><em>Total CHS address bits :</em></strong> 24-Bits </p>
  
  <hr>
  
  <p>Back in day the average (file|block|sector) size was 512B. </p>
  
  <p>Example from <a href="https://en.wikipedia.org/wiki/Cylinder-head-sector" rel="nofollow noreferrer">wikipedia</a>:</p>
  
  <pre><code>512(bytes) × 63(sectors) x 256(heads) × 1024(cylinders) = 8064 MiB (yields what is known as 8 GiB limit) 
  </code></pre>
  
  <p>What I'm confused on is what a <em>head</em> actually means, when referred to as  <code>heads-per-cylinder</code> in the LBA formula. It doesn't make sense to me because from what I know a head is <em><a href="https://en.wikipedia.org/wiki/Disk_read-and-write_head" rel="nofollow noreferrer">head</a></em>, and unless it removable media each <em>platter</em> has two of them (top,bottom) for each of the it's  surfaces. </p>
  
  <p><a href="https://i.stack.imgur.com/TMPaY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMPaY.jpg" alt="enter image description here"></a></p>
  
  <p>In my mind it would make more since to referred to them as <code>heads-per-disk</code> or <code>heads-per-surface</code>, since a cylinder goes through the entire disk (multiple platters).</p>
  
  <p><a href="https://i.stack.imgur.com/2plwL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2plwL.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p><strong>Logical Block Addressing:</strong></p>
  
  <p>Formula: <code>A = (c ⋅ Nheads + h) ⋅ Nsectors + (s − 1)</code></p>
  
  <ul>
  <li><code>A</code> - Logical Block Address</li>
  <li><code>Nheads</code> - Number of heads on a disk <code>heads-per-disk</code></li>
  <li><code>Nsectors</code> - Numbers of sectors on a track <code>sectors-per-track</code></li>
  <li><code>c,h,s</code> - is the cylinder,head,sector numbers <code>24-bits total (10+8+6)</code></li>
  </ul>
  
  <p>Looking at the first example on <a href="https://en.wikipedia.org/wiki/Cylinder-head-sector" rel="nofollow noreferrer"><strong>here</strong></a>: </p>
  
  <pre><code>For geometry 1020 16 63 of a disk with 1028160 sectors CHS 3 2 1 is LBA  3150=(3× 16+2)× 63
  </code></pre>
  
  <p><strong><em>Geometry:</em></strong></p>
  
  <ul>
  <li>Cylinder Number - 1020 (0-1024) </li>
  <li>Head Number - 16 (0-256)</li>
  <li>Sector Number - 63 (1-64)</li>
  </ul>
  
  <p>How are these <strong><em>geometry</em></strong> CHS number mapping in to the CHS tuple (3,2,1) to be used in this formula?</p>