# Counting disk capacity using cylinder-head-sector model

Posted on

QUESTION :

Let’s look at `fdisk -l /dev/sdc` output.

``````# fdisk -l /dev/sdc
Disk /dev/sdc: 786 MB, 786432000 bytes
255 heads, 63 sectors/track, 95 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
``````

I counted capacity for this virtual disk. Check it on image. I got 781401600 bytes instead of 786432000 bytes in upper listing. I have no ideas why it is so. How to get 786432000 bytes(I lost 5030400 bytes)?

See this answer where it’s all authoritatively explained:

In brief, CHS numbers do not have much value these days and are actually reverse-calculated from the actual capacity in bytes. That is, your disk capacity is actually 786432000 bytes. Let’s calculate the number of cylinders for your case:

``````bytes       b/S   H     S    C
786432000 / 512 / 255 / 63 = 95.61157796451914
``````

Now you must somehow get rid of a poor `.6` of a cylinder and so you get:

``````C / H / S = 95 / 255 / 63
``````

Obviously, the rounding error yields the wrong result going back to byte count. Your missing bytes riddle:

``````C                  S    H     b/S
0.61157796451914 * 63 * 255 * 512 = 5030399.999999992 ~ 5030400
``````

In short – forget about CHS. Even more if you have a SSD. Unless you have a hydra SSD, you’ll have a hard time counting how many heads it has anyway…