From: Al on
On Nov 19, 11:41 am, "Rod Speed" <rod.speed....(a)gmail.com> wrote:
> Al wrote:
> > Hi Folks,

> > 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.
>
> Nope, that is completely wrong. A sector is part of
> a track and tracks are concentric circles on the platter.

Not in this picture it isnt sunshine : http://en.wikipedia.org/wiki/Cylinder-head-sector
its a pie shaped slice from the center.


>
> > Block usually 512 bytes.
>
> Not with Linux file systems.

So why does the header from fdisk say "Units = cylinders of 16065 *
512 = 8225280 bytes" - note the 512 value.

>
> > With read hard disk geometry C*H*S = number of blocks
> > Thus number of blocks * 512 = disk size?
>
> Yes.
>
> > Is there a relationship mathmatically, size wise, between
> > a block and a sector? ie 4 blocks = 1 sector or whatever?
>
> A block is just one sector at the physical drive level.

So a block and a sector are the same thing?

>
> > 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?
>
> You should have mulitiplied by 1024 instead of 512.

976760001 * 1024 = 1000202241024 which is still not equal to
1000204886016.

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

C*H*S according to the wiki gives the size in blocks :
http://en.wikipedia.org/wiki/Cylinder-head-sector#CHS_Addressing - I
guess thats another area where the wiki disagrees with you?

>
> > 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?)
>
> Because the linux block is 1024

Again even if I use 1024 * 1953520065 = 1000202273280 which is still
not equal to fdisk header line "1000204886016 bytes" - can you
explain that?

>
> > The same disk:
> > TestDisk 6.10, Data Recovery Utility, July 2008
> > Christophe GRENIER <gren...(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.
>
> Its 255 instead of 254 because the cylinder numbering starts at 0
>
> > In its simplest form the End CHS size - Start CHS size = size of partition (True/False?)
>
> Falso.

Why?

>
> > Because of numbering starting at 0 start end CHS values in calculation
> > are:
> > 121601,255,63 (True/False?)
>
> True with the 255, but its more complicated than that.
>
> > Start CHS values, by the same reasoning should be:
> > 0,2,2
>
> Nope, those dont start at 0, they start at 1.
>

Al

From: Franc Zabkar on
On Wed, 18 Nov 2009 10:52:53 -0800 (PST), Al <bigal.nz(a)gmail.com> put
finger to keyboard and composed:

>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.

In the early 1990s, drives already began to support address
translation where you could specify any logical CHS combination that
didn't exceed a drive's capacity. The drive would then perform its own
internal conversion to physical CHS values.

>The the definition of a sector (on the physical disk anyway) is a
>strip extending from the center of the platter to the edge.

Nowadays drives use Zone Bit Recording. Each zone has a constant
number of sectors/track, with the outermost zone having the most, and
the innermost zone the least. This equalises the bit densities across
the surface of the platter.

See http://en.wikipedia.org/wiki/Zone_bit_recording

Here is an excellent, in-depth technical article on modern hard
drives:





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
>
>
>
>
>
>
>
>
>
>

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
From: Rod Speed on
Al wrote
> Rod Speed <rod.speed....(a)gmail.com> wrote
>> Al wrote

>>> The the definition of a sector (on the physical disk anyway)
>>> is a strip extending from the center of the platter to the edge.

>> Nope, that is completely wrong. A sector is part of
>> a track and tracks are concentric circles on the platter.

> Not in this picture it isnt sunshine :

You're misinterpretting that, moonshine.

> http://en.wikipedia.org/wiki/Cylinder-head-sector
> its a pie shaped slice from the center.

Thats a different sort of sector, not the 512 byte sector you referred to elsewhere.

There is no way that that pie shaped sector could be just 512 bytes.

http://en.wikipedia.org/wiki/Disk_sector makes it much clearer and
http://en.wikipedia.org/wiki/File:Disk-structure2.svg
makes it much clearer, the 512 bytes sectors are C in that diagram.

>>> Block usually 512 bytes.

>> Not with Linux file systems.

> So why does the header from fdisk say "Units = cylinders of 16065 *
> 512 = 8225280 bytes" - note the 512 value.

That uses the word units.

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

>> Yes.

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

>> A block is just one sector at the physical drive level.

> So a block and a sector are the same thing?

At the physical drive level, yes. But not necessarily at the file system level.

>>> 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?

>> You should have mulitiplied by 1024 instead of 512.

> 976760001 * 1024 = 1000202241024 which is still not equal to 1000204886016.

Sure, the difference is with the first track which isnt part of
the partition and the last cylinder which is usually reserved etc.

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

>>> 121601 * 255 * 63 = 1953520065 blocks

>> Nope, sectors.

> C*H*S according to the wiki gives the size in blocks :
> http://en.wikipedia.org/wiki/Cylinder-head-sector#CHS_Addressing - I
> guess thats another area where the wiki disagrees with you?

Nope, blocks and sectors are the same, as otherwise discussed.

>>> 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?)

>> Because the linux block is 1024

> Again even if I use 1024 * 1953520065 = 1000202273280 which is still not
> equal to fdisk header line "1000204886016 bytes" - can you explain that?

See above.

>>> The same disk:
>>> TestDisk 6.10, Data Recovery Utility, July 2008
>>> Christophe GRENIER <gren...(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.

>> Its 255 instead of 254 because the cylinder numbering starts at 0

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

>> False.

> Why?

Sorry, I should proof read complicated stuff like this, I meant True.

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

>> True with the 255, but its more complicated than that.

>>> Start CHS values, by the same reasoning should be:
>>> 0,2,2

>> Nope, those dont start at 0, they start at 1.


From: Franc Zabkar on
On Wed, 18 Nov 2009 10:52:53 -0800 (PST), Al <bigal.nz(a)gmail.com> put
finger to keyboard and composed:

>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.

In the early 1990s, drives already began to support address
translation where you could specify any logical CHS combination that
didn't exceed a drive's capacity. The drive would then perform its own
internal conversion to physical CHS values.

>The the definition of a sector (on the physical disk anyway) is a
>strip extending from the center of the platter to the edge.

Nowadays drives use Zone Bit Recording. Each zone has a constant
number of sectors/track, with the outermost zone having the most, and
the innermost zone the least. This equalises the bit densities across
the surface of the platter.

See http://en.wikipedia.org/wiki/Zone_bit_recording

Here is an excellent, in-depth technical article on modern hard
drives:

http://hddscan.com/doc/HDD_Tracks_and_Zones.html

I think of a block as a logical construct rather than a physical one,
although you can think of it in physical terms as well. It depends on
the context ...

>Now to involve some real world data:

>TestDisk 6.10, Data Recovery Utility, July 2008
>
>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.

Historically, the maximum number of sectors per track is 63, and the
maximum number of heads (aka tracks per cylinder) is 255. AIUI, this
is because the original disc controller's registers allocated 6 bits
for S and 8 bits for H.

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

LBA = (C x 255 x 63) + (H x 63) + (S - 1)

Partition size (in sectors) = End LBA - Start LBA + 1

= (Ce - Cs) x 255 x 63 + (He - Hs) x 63 + (Se - Ss) + 1

where e/s are the end/start values of CHS.

Historically, the first partition usually starts at LBA 63 because the
first track (LBA 0 - LBA 62) contains the MBR, partition table, and
sometimes additional boot code, eg disc overlays, or a boot manager to
allow booting from one of several partitions.

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
From: Arno on
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.

Correct.

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

I think so.

> 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).

Wrong. Historically it was so, but that was never the definition.
A sector is the part of a track (curcular for HDDs, but a spiral for
CDROM, e.g.) needed to store the smallest unit that can be read or
writen by one access.

> Block usually 512 bytes.

Avoid the term "block". Use sector for pysical blocks and "cluster"
for logical blocks managed by the OS.

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

Yes.

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

See above. "Block" has no fixed meaning in this context.
Clusters are comprised of one or several sectors, typically
starting by 4 sectors/cluster, but it is a formatting
time option (i.e. mkfs option).

> 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?

You have a third meaning of "block" here, a historic one. That
is "unit of 1024 bytes of space". I think this comes from SunOS.

> 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?)

Because teh C/H/S numbers are an approcimation. There usually is some
extra space at the end that does not quite fit into the C/H/S masure.
Linux has been using LBA (one number per sector) for a long time,
fsisk is just from before that time and the C/H/S methaphor works
relatively well, so it was never changed. But you can look at cfdisk,
sfdisk and parted. They use direct sizes, and, let me tell you, they
can be a pain if you want to create a partition exactly the same size
as an existing one.

> 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?)

No. That is the ideal case. It is possible to create partitions that
do not start/end on a cylinder boundary.

> 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?)

We have 121601 cylinders, that is 0....121600. But they have
254 heads, instead of the true (ans stated a line earlier) 255.
Seems to me they have the number of the first head wrong, which
should be 0. Possibly a simple programming error.

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

> Thanks in advance for any replies.

No problem.

Arno












--
Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: arno(a)wagner.name
GnuPG: ID: 1E25338F FP: 0C30 5782 9D93 F785 E79C 0296 797F 6B50 1E25 338F
----
Cuddly UI's are the manifestation of wishful thinking. -- Dylan Evans