[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Help in HDD partitioning...



On Wed, Dec 13, 2000 at 01:20:30PM +0530, Anil Pillai typed:
> 
> 
> On Tue, 12 Dec 2000, Arun Sharma wrote:
> 
> > On Wed, Dec 13, 2000 at 11:21:59AM +0530, Anil Pillai wrote:
> > > >From the data type it is char with a max of 255. How does this fit into
> > > the big picture. Is it offset, or what ???
> > > Looking forward to your help in any way
> > > 	and thanking you in anticipation,
> > 
> > The cylinder, head, sector together (commonly referred to as CHS)
> > uniquely identify the location of the begining of the partition.
> -------> I DOUBT <-------------------
> > 
> > Therefore you can have 255 * 255 * 255 ~ 2^24 sectors on any disk.
>                     -----???????????????????????-----
> 
> Thanks for this but it seems quite evident that 255*255*255=2^24 and
> nothing more than this. Correct me if I am wrong.

Slightly off - 256*256*256 is 2^24 :):):)

> Number of sectors as far as I know = heads * sectors per track * cylinders
> or you can get the number of sectors from /proc/ide/hda/capacity

You're right about that.

> What I am looking for is the significance of the structure members that I
> had pointed out to in my original query.

Well as Arun said, the 3 members head,cylinder,sector indicate the start 
(and the end if you take the 3 end fields) of the partition on the hard
disk. (Logical - need not be physical)

They are defined as "char" because each of these fields occupy only 1
byte each on the partition table on disk. So if you read the sector
containing the partition table into memory, and want to cast the
appropriate memory area into a structure, their definition in the
structure needs to be sized accordingly.

Slight inaccuracy in Arun's reply regarding the actual interpretations
of these though :

The Cylinder field is actually 10 bit : The LSB 8 bits taken from the
cyl field in the structure and bits 8 & 9 have to be brought in from bits
6 & 7 (the most significant 2 bits) of the Sectors field. So the range
of the cylinders can be from 0 to 1023.

The sector number is the least significant 6 bits in the "sector" field
of the structure. Valid values for these are 1 to 63. (A sector number
of 0 is considered illegal for some vague reason.

The heads are 1 byte long and can actually use values from 0 to 255
(both inclusive) - which means there can be upto 256 heads on a disk.
However disk manufacturers seem to use a max of 255 heads again for
reasons that I am not clear about.

So theoretically the number of sectors that can be present on a disk
that uses the CHS system of numbering is 1024 * 63 * 256  - slightly off
from 255*255*255.

One caveat though. On a lot of partitions you may find all these CHS
numbers to be 0.  If the starting sector number & Ending sector number
fields in that structure are non-zero, you're supposed to use those
fields. Each of these are 32 bits long and can therefore cater to disks
with upto 2^31 sectors. 

Kala