From: Al on
Hi Folks,

I am hoping some kind people on this NG could help me better
understand HDD Geometry. Dont get me wrong I have done some googling,
and read some wiki's - but some parts are still very blurry. I have
also used the man command since most of what I am doing is in linux.

Most of my questions have been brought about by various LInux tools I
have been experimenting with, such as testdisk, mount, and fdisk.

I will outline what I understand so far, if any of these statements
are wrong please let me know.

I understand so far:
That hard disks have physical geometry CHS, but modern hard disk CHS
bears no direct relationship to the physical geometry of the disk. I
think the modern CHS is sometimes called Psuedo CHS.

C and H numbering starts at 0, but S starts at 1.

The the definition of a sector (on the physical disk anyway) is a
strip extending from the center of the platter to the edge. And a
block is the intersection of a cylinder and a sector. Sometimes use
the terms block and sector to mean the same thing (block).

Block usually 512 bytes.

With read hard disk geometry C*H*S = number of blocks
Thus number of blocks * 512 = disk size?

Is there a relationship mathmatically, size wise, between a block and
a sector? ie 4 blocks = 1 sector or whatever?

Now to involve some real world data:

al(a)al-ubuntu:~$ sudo fdisk -l
[sudo] password for al:

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xaf010487

Device Boot Start End Blocks Id System
/dev/sda1 * 1 121601 976760001 83 Linux

I know that start and end are cylinder values and I assume that blocks
is the size of the partition in blocks. Assuming I was correct before
when I stated that blocks are 512 bytes in size, then:

976760001 * 512 bytes = disk size in bytes - but it doesnt, it equals
500101120512 bytes which is way off 1000204886016 bytes from the
header in fdisk. Why?

From fdisk headerline "255 heads, 63 sectors/track, 121601 cylinders"
- now using C*H*S = number of blocks

121601 * 255 * 63 = 1953520065 blocks
and because 512 bytes to a block:
512 * 1953520065 = 1000202273280 bytes (which should be the same as
the disk size given in the fdisk header line "1000204886016 bytes" but
it isnt. Why?)

The same disk:

TestDisk 6.10, Data Recovery Utility, July 2008
Christophe GRENIER <grenier(a)cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63
Current partition structure:
Partition Start End Size in sectors

1 * Linux 0 1 1 121600 254 63 1953520002

Now start and end are full CHS values and we can also see the size of
the partition in sectors. I have been told that:

(255 * 63 * 121601) - (63 * 1) = 1953520002

Which is the size in sectors. But I dont quite understand the
calculations.

In its simplest form the End CHS size - Start CHS size = size of
partition (True/False?)

Because of numbering starting at 0 start end CHS values in calculation
are:
121601,255,63 (True/False?)

Start CHS values, by the same reasoning should be:
0,2,2 (Clearly this is not whats used in the calculation - why?)

Well this has been a long post, and I suspect the answer will raise
more questions.

Thanks in advance for any replies.

-Al











From: Grant on
On Wed, 18 Nov 2009 10:52:53 -0800 (PST), Al <bigal.nz(a)gmail.com> wrote:

>Hi Folks,
>
>I am hoping some kind people on this NG could help me better
>understand HDD Geometry. Dont get me wrong I have done some googling,
>and read some wiki's - but some parts are still very blurry. I have
>also used the man command since most of what I am doing is in linux.
>
>Most of my questions have been brought about by various LInux tools I
>have been experimenting with, such as testdisk, mount, and fdisk.
>
>I will outline what I understand so far, if any of these statements
>are wrong please let me know.
>
>I understand so far:
>That hard disks have physical geometry CHS, but modern hard disk CHS
>bears no direct relationship to the physical geometry of the disk. I
>think the modern CHS is sometimes called Psuedo CHS.

Er, LBA -- Logical Block Addressing?
>
>C and H numbering starts at 0, but S starts at 1.
>
>The the definition of a sector (on the physical disk anyway) is a
>strip extending from the center of the platter to the edge. And a
>block is the intersection of a cylinder and a sector. Sometimes use
>the terms block and sector to mean the same thing (block).
>
>Block usually 512 bytes.

1024 bytes for modern linux fdisk.
>
>With read hard disk geometry C*H*S = number of blocks
>Thus number of blocks * 512 = disk size?
>
>Is there a relationship mathmatically, size wise, between a block and
>a sector? ie 4 blocks = 1 sector or whatever?

There's different block sizes, depending on usage. Filesystem may
allocate space in 1k or 4k (or larger?) blocks depending on partition
size.
>
>Now to involve some real world data:
>
>al(a)al-ubuntu:~$ sudo fdisk -l
>[sudo] password for al:
>
>Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
>255 heads, 63 sectors/track, 121601 cylinders
>Units = cylinders of 16065 * 512 = 8225280 bytes
>Disk identifier: 0xaf010487
>
> Device Boot Start End Blocks Id System
>/dev/sda1 * 1 121601 976760001 83 Linux
>
>I know that start and end are cylinder values and I assume that blocks
>is the size of the partition in blocks. Assuming I was correct before
>when I stated that blocks are 512 bytes in size, then:
>
>976760001 * 512 bytes = disk size in bytes - but it doesnt, it equals
>500101120512 bytes which is way off 1000204886016 bytes from the
>header in fdisk. Why?

Forget CHS -- the important number for large disks is the 8225280
bytes per cylinder.

Look at fdisk's 'x' mode display? It shows the uninterpreted sizes:

Command (m for help): p

Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x45e0afb2

Device Boot Start End Blocks Id System
/dev/sda1 1 1024 8225248+ 83 Linux
/dev/sda2 1025 2048 8225280 83 Linux
/dev/sda3 * 2049 3072 8225280 83 Linux
/dev/sda4 3073 9728 53464320 5 Extended
/dev/sda5 3073 3200 1028128+ 82 Linux swap
/dev/sda6 3201 3968 6168928+ 83 Linux
/dev/sda7 3969 4736 6168928+ 83 Linux
/dev/sda8 4737 9728 40098208+ 83 Linux

Command (m for help): x

Expert command (m for help): p

Disk /dev/sda: 255 heads, 63 sectors, 9729 cylinders

Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID
1 00 1 1 0 254 63 1023 63 16450497 83
2 00 254 63 1023 254 63 1023 16450560 16450560 83
3 80 254 63 1023 254 63 1023 32901120 16450560 83
4 00 254 63 1023 254 63 1023 49351680 106928640 05
5 00 254 63 1023 254 63 1023 63 2056257 82
6 00 254 63 1023 254 63 1023 63 12337857 83
7 00 254 63 1023 254 63 1023 63 12337857 83
8 00 254 63 1023 254 63 1023 63 80196417 83

Grant.
--
http://bugsplatter.id.au
From: Al on
On Nov 19, 9:29 am, Grant <g_r_a_n...(a)bugsplatter.id.au> wrote:
> Forget CHS -- the important number for large disks is the 8225280
> bytes per cylinder.

Can you use the 8225280 bytes per cylinder with total number of
cylinders to calculate disk size?

>
> Look at fdisk's 'x' mode display?  It shows the uninterpreted sizes:
>
> Command (m for help): p
>
> Disk /dev/sda: 80.0 GB, 80025280000 bytes
> 255 heads, 63 sectors/track, 9729 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
> Disk identifier: 0x45e0afb2

ie: Why does the 8225280 * 9729 <not equal> 8002528000 bytes???

After all its the cylinder size * number of cylinders???

-Al
From: Al on
> >a sector? ie 4 blocks = 1 sector or whatever?
>
> There's different block sizes, depending on usage.  Filesystem may
> allocate space in 1k or 4k (or larger?) blocks depending on partition
> size.
>

So are you saying block size is a function of File System?

-Al



From: Rod Speed on
Al wrote:
>>> a sector? ie 4 blocks = 1 sector or whatever?
>>
>> There's different block sizes, depending on usage. Filesystem may
>> allocate space in 1k or 4k (or larger?) blocks depending on partition
>> size.
>>
>
> So are you saying block size is a function of File System?

Yep.