Tags:
create new tag
, view all tags
Starting out as a "scratch sheet" to do some calculations on hard drives, and maybe eventually confirming that blocks and clusters are the same thing (or maybe that depends on the file system).

Some of the formulae are from http://en.tldp.org/HOWTO/mini/Partition/recovering.html.

See:

## Notes

Given:

• disk /dev/sda: 16 heads, 63 sectors, 23361 cylinders
• A sector is always 512 bytes??

Formulae:

• (unit (disk) size) = (number of cylinders) * (number of heads) * (number of sectors/cylinder) * (number of bytes/sector)

• (number of needed cylinders) = (number of blocks) / (block size)
• (block size) = (unit size) / 1024

Unit (disk) size = (number of cylinders) * (number of heads) * (number of sectors/cylinder) * (number of bytes/sector)

= 23361 * 16 * 63 * 512

= 12,056,518,656 bytes or 12056 MB or 12 GB (??) (with kilo = 1000 not 1024)

Darn, the calculation in the HOWTO is not correct / consistent -- either the formula is wrong or his calulation is wrong -- in his calculation he does not multiply by the 512 bytes per sector, so comes up with a unit size of 516096 -- if I divide by 512 I still get a different result than he gets -- 23,547,888. Oh, I see, he didn't multiply by the number of cylinders, and if I divide my original number by 23361, I do match his numbers. But the question is why didn't he multiply by the number of cylinders since the formula does include that. And this is from "Revision 3.310 July 2001" where the change notice says "Corrected Section 6, calculation of cylinder numbers".

I better quit -- maybe write to the author -- all I'm going to do is get a headache from this.

Ok, restart -- turns out the document at the tldp is not the latest, and the latest (at http://surfer.nmr.mgh.harvard.edu/partition/partition-6.html) seems to have corrected the discrepancy. So, I'll try again (maybe a little later) and think about writing to the tldp.

OK, another restart -- let's think about this: The objective in the given example in the HOWTO is to determine the number of cylinders to specify to get a partition of a given block size.

It looks like the calculation assumes a block is always 1024 bytes. (If that is true, a block is not equal to a cluster, or at least not always.)

The HOWTO found the size of the partition in blocks by a trial and error process, first making a partition that was assumed to be bigger than the original, then confirming that by making a larger partition and running `dumpe2fs /dev/sda1 | grep "Block count:"` until the result was stable.

Let me go try that on one or two of my machines (substituting hda1 and so forth). Oops that doesn't work for me -- I get "Bad magic number in super-block while trying to open /dev/hda2" (for example -- maybe because the partition is not ext2. Ok, found some ext2 partitions, ran dumpe2fs and df on them -- got a block count -- df also specified the space used in 1k blocks which reinforces the idea that blocks are 1024 bytes, at least in these cases. (Maybe that's what I always have to do to confirm the block size.)

Anyway, now:

• I have a number of blocks that I want to size a partition to
• I know that a block (at least in this case) is 1024 bytes
• disk /dev/sda: 16 heads, 63 sectors, 23361 cylinders
• A sector is (always?) 512 bytes

So now I want to calculate, for example, how many blocks per cylinder (or, how many cylinders it takes to obtain at least x blocks).

so

(blocks per cylinder) = (heads) * (sectors per cylinder) * (bytes per sector) / (bytes per block) ??

Try the math:

(blocks per cylinder) = 16 * 63 * 512 / 1024 = 504

If I want 1500 blocks I need 3 cylinders.

OK, I think I got it. May wait for any feedback from Tony Harris, then rewrite this page.

If I was really doing this calculation, I'd have to look back at the HOWTO to see what it said about the first cylinder (partition) being smaller than the others (or something like that).

<Currently, no significant content below this line.>

## Contributors

• () RandyKramer - 25 Feb 2003