From: Tejun Heo on
Hello, James.

On 03/16/2010 10:24 PM, James Bottomley wrote:
> For msdos labels, it's embedded in the label ... for all other labels,
> it's made up on the spot.

Where in the label?

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: James Bottomley on
On Tue, 2010-03-16 at 22:56 +0900, Tejun Heo wrote:
> Hello, James.
>
> On 03/16/2010 10:24 PM, James Bottomley wrote:
> > For msdos labels, it's embedded in the label ... for all other labels,
> > it's made up on the spot.
>
> Where in the label?

No idea ... I only know you can use fdisk expert mode to change the
C/H/S layout and the change is preserved across reboots.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnd Bergmann on
On Tuesday 16 March 2010, James Bottomley wrote:
> On Tue, 2010-03-16 at 22:56 +0900, Tejun Heo wrote:
> > Hello, James.
> >
> > On 03/16/2010 10:24 PM, James Bottomley wrote:
> > > For msdos labels, it's embedded in the label ... for all other labels,
> > > it's made up on the spot.
> >
> > Where in the label?
>
> No idea ... I only know you can use fdisk expert mode to change the
> C/H/S layout and the change is preserved across reboots.

IIRC, the layout is guessed from the partition end locations, in the
assumption that each partition is aligned to full cylinders. That
gives you the heads/sectors number, while the cylinder number can be
calculated from the total number of sectors using these numbers.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Denys Vlasenko on
On Tuesday 16 March 2010 14:56, Tejun Heo wrote:
> Hello, James.
>
> On 03/16/2010 10:24 PM, James Bottomley wrote:
> > For msdos labels, it's embedded in the label ... for all other labels,
> > it's made up on the spot.
>
> Where in the label?

The "end of partition" is expected to be at the last head and sector.
Of course this heuristic fails if there are more than one primary
partition and they have differing last head and sector.

But on most "sanely" partitioned disks they are the same:

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

Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID
1 00 1 1 0 254 63 850 63 13671252 0b
2 80 0 1 851 254 63 1023 13671315 572395950 05
3 00 0 0 0 0 0 0 0 0 00
4 00 0 0 0 0 0 0 0 0 00
5 00 1 1 851 254 63 972 63 1959867 83
6 00 1 1 973 254 63 1023 63 31246362 83
7 00 254 63 1023 254 63 1023 63 195318207 83
8 00 254 63 1023 254 63 1023 63 343871262 83
^^^ ^^

Which suggests another idea how to align a partition:
since there is no requirement on the partition *start*,
we don't have to start at head1,sector1 or head0,sector1

In the example above, 1st partition might be modified to start
at head1,sector2, IOW, LBA 64, thus making it 32k aligned.

As long as partition *ends* adhere to the convention
of being exactly at last_head,last_sector, nothing should break.
--
vda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Tejun Heo on
Hello,

On 03/16/2010 11:21 PM, James Bottomley wrote:
>>> For msdos labels, it's embedded in the label ... for all other labels,
>>> it's made up on the spot.
>>
>> Where in the label?
>
> No idea ... I only know you can use fdisk expert mode to change the
> C/H/S layout and the change is preserved across reboots.

The CHS addresses are stored alongside with the LBA addresses. The
problem is that the geometry parameters (sectors/track and heads/cyl)
are not stored anywhere and CHS addresses don't make any sense without
the two parameters. The only way to figure out the geometry
parameters is to solve two equations involving CHS addresses and LBA
addresses.

e.g. If the first partition begins at CHS 0/32/33 and ends at
12/233/19 and the corresponding LBA addresses are 2048 and 206848, you
can solve the equation and determine that the parameters gotta be 63
secs/trk and 255 heads/cyl to make those two pairs of addresses match
each other and in fact some BIOSs try to do this depending on
configuration (and sometimes falls into infinite loop or causes other
boot related problems if the parameters are too uncommon).

This method can't work reliably even at theoretical level because it
requires at least two pairs of CHS/LBA addresses to match (two unknown
parameters to solve for) and there is only single pair available if
the first partition goes over the CHS limit which at maximum is 8GiB.

So, CHS *values* are preserved if it falls below the CHS limit of the
geometry used during partitioning but the geometry information is lost
making the CHS values completely meaningless, so the only sane thing
to do is to stick to whatever geometry parameters provided by the BIOS
which usually is 255/63 these days. Otherwise, the results are...

* If the first partition ends before the CHS limit and BIOS is
configured to calculate back the parameters, BIOS may be able to
report the geometry correctly.

* If the first partition goes over the CHS limit,

* BIOS can use 255/63 or whatever default parameters and CHS and LBA
addresses won't match each other which won't be a problem for
modern OSes as they don't look at the CHS addresses at all but
older operating systems which consider both CHS and LBA addresses
may get confused.

* BIOS can set up arbitrary parameters such that the CHS and LBA for
the start of the first partition match and maybe also try to
cylinder align further LBA addresses but there is no guarantee
these parameters match the original parameters used during
partitioning and this seems to cause more compatibility problems
than it solves.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/