# Hard Drive Geometry 101

A

#### Al

Al said:
and test data:

thus start LBA:

LBA = (0 x 255 x 63) + (1 x 63) + (1 - 1)
= 0 + 63 + 0
= 63

and end LBA:

LBA = (121600 x 255 x 63) + (254 x 63) + (63 - 1)
= 1953504000 + 16002 + 62
= 1953520064

I also noitce that LBAe-LBAs (1953520064-63) = 1953520001 which is one
number off the correct size in sectors for the partition. Why one
number wrong?

-Al

R

#### Rod Speed

Al said:
I also noitce that LBAe-LBAs (1953520064-63) = 1953520001 which is one
number off the correct size in sectors for the partition. Why one number wrong?

Usual maths, its always end-start+1

R

#### Rod Speed

Al wrote
and test data:
thus start LBA:
LBA = (0 x 255 x 63) + (1 x 63) + (1 - 1)
= 0 + 63 + 0
= 63
and end LBA:
LBA = (121600 x 255 x 63) + (254 x 63) + (63 - 1)
= 1953504000 + 16002 + 62
= 1953520064
1) Are the units of LBA blocks?

Nope, sectors.
And if so, does (LBAe - LBAs) * 512 = partition size?

Yes. But thats sectors, not blocks.
2) Should the C and H values in the calculation be 64 and 121601
(because the numbering starts at 0?)

It doesnt with heads and cylinders, only with sectors.

F

#### Franc Zabkar

1) Are the units of LBA blocks? And if so, does (LBAe - LBAs) * 512 =
partition size?

LBA = Logical Block Address

For a typical hard drive, 1 LBA = 1 sector = 512 bytes.

Partion size = (LBAe - LBAs + 1) * 512

For example, a partition consisting of two sectors, LBA 10 and LBA 11,
has a size of (11 - 10 + 1) * 512.
2) Should the C and H values in the calculation be 64 and 121601
(because the numbering starts at 0?)

Each cylinder has 255 heads (aka tracks), and each track has 63
sectors.

The very first sector is LBA 0 or CHS 0/0/1. We haven't completed a
full cylinder, nor a full track, so C=0 and H=0.

LBAs are assigned sequentially. Start at the first sector of the first
track under the first head, and then go around the track. This gives
you 63 sectors. Switch to the first track under the second head and
count the next 63 sectors. Then repeat this process until you go
around the first track under the 255th head. Now you have completed
one full cylinder. Return to the first head and go around the second
track. Keep switching heads until you complete the second cylinder and
then begin on the third cylinder. Etc, etc ...
One of the commands I am dealing with is MOUNT and with the offset
switch.

Plenty of sites tell you to multiply the start (Cylinders) by 512 to
get the offset value. Therefore what unit is the offset value in?

Sorry, that makes no sense to me. Perhaps a Linux user could help you?

- Franc Zabkar

A

#### Al

LBA = Logical Block Address

For a typical hard drive, 1 LBA = 1 sector = 512 bytes.

Partion size = (LBAe - LBAs + 1) * 512

Ok that makes good sense.
Does it follow that 1 LBA = 1 block = 512 bytes?
For example, a partition consisting of two sectors, LBA 10 and LBA 11,
has a size of (11 - 10 + 1) * 512.

I think I confused myself there - S numbering starts at 1. (and CH at
0). The 63 is a S.
Each cylinder has 255 heads (aka tracks), and each track has 63
sectors.

The very first sector is LBA 0 or CHS 0/0/1. We haven't completed a
full cylinder, nor a full track, so C=0 and H=0.

LBAs are assigned sequentially. Start at the first sector of the first
track under the first head, and then go around the track. This gives
you 63 sectors. Switch to the first track under the second head and
count the next 63 sectors. Then repeat this process until you go
around the first track under the 255th head. Now you have completed
one full cylinder. Return to the first head and go around the second
track. Keep switching heads until you complete the second cylinder and
then begin on the third cylinder. Etc, etc ...

Sorry, that makes no sense to me. Perhaps a Linux user could help you?

FWIW This guy shows how simple it is. He multiples the C start by 512
to get the offset value.

http://darkdust.net/writings/diskimagesminihowto#Mountingthediskimage

I am picking that you can multiple the C * 512 to get the offset in
bytes?

-Al

R

F

#### Franc Zabkar

Ok that makes good sense.
Does it follow that 1 LBA = 1 block = 512 bytes?

All the hard drives you are likely to encounter have block sizes equal
to the sector size, ie 512 bytes (= 256 words).

However, the ATA-8 specification allows for other sizes.

See words 106 and 117-118 of the Identify Device data block, as
described in the following document.

Working Draft AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS):
FWIW This guy shows how simple it is. He multiples the C start by 512
to get the offset value.

http://darkdust.net/writings/diskimagesminihowto#Mountingthediskimage

I am picking that you can multiple the C * 512 to get the offset in
bytes?

-Al

The author of that tutorial is multiplying the start LBA by 512 to get
the offset in bytes into the disc image.

- Franc Zabkar

B

R

#### Rod Speed

Some gutless ****wit brown chav child that cant even manage its
own lines, or anything else at all either, desperately cowering behind
Bilky Brown wrote just the puerile shit that you'd expect from a
desperately cowering gutless ****wit brown chav child.