t***@polynum.com
2012-01-07 18:29:08 UTC
Hello,
Since I'm playing with the installation, I have been hit once again
with disk/fdisk corrupting the MBR and rendering other systems
unbootable.
The explanation is arithmetic truncation. disk/fdisk.c does this:
p->start = lba/sec2cyl;
and, if modifications are done (for example creating a Plan9 partition,
of marking a primary partition active), when written back, the entries
are "restored" by:
*endlba = (vlong)p->start*sec2cyl;
Of course, if the values were not integer multiples of sec2cyl, the
entry point for the PBS is corrupt. (For example, on *BSD, the principle
is the same as for Plan9: a "primary" partition is a sequence of
adjacent bytes, furthermore subdivided; but one special subdivision
[a] is at the same offset (at start) and holds the bootcode and a
disklabel describing the subdivision; if the MBR is corrupt, neither
boot nor disklabel so user can conclude: everything lost). And the first
travel in the flying saucer will also be the last...
And since the values in the MBR have almost no relation today with the
physical access of data; and furthermore, since partitions created by
other systems for other systems should be left alone (that's the main
purpose of the MBR: establish borders to tell others: this is my realm!
go away!)...
I will submit patches later, if no one does the job before, since there
are saved values (p->ctlstart = lba; etc.) that are here and not used,
so I have to review the code closely.
Until then: if you wish to dual boot, create the Plan9 partition before
with another system present on disk (and do print the layout of the MBR)
in order to skip this step in installation.
Since I'm playing with the installation, I have been hit once again
with disk/fdisk corrupting the MBR and rendering other systems
unbootable.
The explanation is arithmetic truncation. disk/fdisk.c does this:
p->start = lba/sec2cyl;
and, if modifications are done (for example creating a Plan9 partition,
of marking a primary partition active), when written back, the entries
are "restored" by:
*endlba = (vlong)p->start*sec2cyl;
Of course, if the values were not integer multiples of sec2cyl, the
entry point for the PBS is corrupt. (For example, on *BSD, the principle
is the same as for Plan9: a "primary" partition is a sequence of
adjacent bytes, furthermore subdivided; but one special subdivision
[a] is at the same offset (at start) and holds the bootcode and a
disklabel describing the subdivision; if the MBR is corrupt, neither
boot nor disklabel so user can conclude: everything lost). And the first
travel in the flying saucer will also be the last...
And since the values in the MBR have almost no relation today with the
physical access of data; and furthermore, since partitions created by
other systems for other systems should be left alone (that's the main
purpose of the MBR: establish borders to tell others: this is my realm!
go away!)...
I will submit patches later, if no one does the job before, since there
are saved values (p->ctlstart = lba; etc.) that are here and not used,
so I have to review the code closely.
Until then: if you wish to dual boot, create the Plan9 partition before
with another system present on disk (and do print the layout of the MBR)
in order to skip this step in installation.
--
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C