[haiku-bugs] Re: [Haiku] #6301: DriveSetup writes MBR inconsistent with anyboot image.

  • From: "starsseed" <trac@xxxxxxxxxxxx>
  • Date: Fri, 23 Jul 2010 23:11:36 -0000

#6301: DriveSetup writes MBR inconsistent with anyboot image.
--------------------------------------+-------------------------------------
  Reporter:  preroll                  |         Owner:  stippi           
      Type:  bug                      |        Status:  new              
  Priority:  normal                   |     Milestone:  R1               
 Component:  Applications/DriveSetup  |       Version:  R1/alpha2        
Resolution:                           |      Keywords:  MBR boot CHS bits
Blocked By:                           |   Has a Patch:  1                
  Platform:  x86                      |      Blocking:                   
--------------------------------------+-------------------------------------

Comment (by starsseed):

 Replying to [comment:7 bonefish]:
 > Replying to [comment:5 starsseed]:
 > > @Bonefish[[BR]]
 > > Note that:
 > > - FF FF FF implies a disks with UUID partition table (EFI) then EF FF
 FF would be better
 >
 > Where have you got this information from? I've never heard of this.
 >
 http://en.wikipedia.org/wiki/Master_boot_record#cite_note-8

 > > - since DriveSetup creates the first partition at sector CHS={01 02
 00} (i.e. Cylinder=0/Head=1
 > /sector=2 or LBA=40) it seems it does not take care about the disk
 geometry. I think it's not correct : the 1st partition should be aligned
 on the 1st sector (2nd,3rd,4th partition should be aligned on head*sector
 - 1st sector/Head 0).
 >
 > I believe we don't even know the actual disk geometry at this point, let
 alone that it probably cannot be represented with the limited CHS scheme
 anyway. Does anyone even care about these alignments still?
 However, it greatly affects performances.

 CHS Calculation
 ||=Variables in CHS calculation =||=Description =||
 ||totalSectors||Total data sectors present in the disk image||
 ||cylinders||Number of cylinders present on the disk||
 ||heads||Number of heads present on the disk||
 ||sectorsPerTrack||Sectors per track on the disk||
 ||cylinderTimesHead||Cylinders x heads||

 {{{
                     C      H     S
 if (totalSectors > 65535 * 16 * 255)
 {
    totalSectors = 65535 * 16 * 255;
 }

 if (totalSectors >= 65535 * 16 * 63)
 {
    sectorsPerTrack = 255;
    heads = 16;
    cylinderTimesHeads = totalSectors / sectorsPerTrack;
 }
 else
 {
    sectorsPerTrack = 17;
    cylinderTimesHeads = totalSectors / sectorsPerTrack;

    heads = (cylinderTimesHeads + 1023) / 1024;

    if (heads < 4)
    {
       heads = 4;
    }
    if (cylinderTimesHeads >= (heads * 1024) || heads > 16)
    {
       sectorsPerTrack = 31;
       heads = 16;
       cylinderTimesHeads = totalSectors / sectorsPerTrack;
    }
    if (cylinderTimesHeads >= (heads * 1024))
    {
       sectorsPerTrack = 63;
       heads = 16;
       cylinderTimesHead = totalSectors / sectorsPerTrack;
    }
 }
 cylinders = cylinderTimesHead / heads;
 }}}

 here are the rules used by some partitionning tools.
 1. If the first sector of the cylinder is a partition table sector, then
 the rest of the track is unused, and the partition starts with the the
 next track. This applies to sector 0 (the MBR) and the partition table
 sectors preceding logical partitions.
 2. Otherwise, the partition starts at the first sector of the cylinder.
 Also the extended partition starts at a cylinder boundary

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6301#comment:8>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: