On Sat, Jul 07, 2007 at 04:31:21AM -0400, Matthew Szudzik wrote:
> > Disk: sd0   geometry: 3935/64/32 [8060926 Sectors]
> > Offset: 0   Signature: 0xAA55
> >          Starting       Ending       LBA Info:
> >  #: id    C   H  S -    C   H  S [       start:      size   ]
> > ------------------------------------------------------------------------
> >  0: 0B    0   1 32 - 3935  63 17 [          63:     8060850 ] Win95 FAT-32
> >  1: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
> >  2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
> >  3: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
> 
> Ah, I now understand.  Windows is assuming that each track has 63 sectors, 
> and apparently requires that each partition fills an integer number of 
> tracks.  The ending CHS values are chosen so that the maximum number of 
> 63-sector tracks are filled.
> 
> So, to create the appropriate MBR partition for a drive, type the 
> following (I assume that the drive is device sd0):
> 
> 
>  # fdisk -i -e sd0
>  fdisk: sysctl(machdep.bios.diskinfo): Device not configured
>  
>       -----------------------------------------------------
>       ------ ATTENTION - UPDATING MASTER BOOT RECORD ------
>       -----------------------------------------------------
>  
>  Do you wish to write new MBR and partition table? [n] y
>  Enter 'help' for information
>  fdisk: 1> print
>  Disk: sd0    geometry: 3935/64/32 [8060926 Sectors]
>  Offset: 0    Signature: 0xAA55
>           Starting       Ending       LBA Info:
>   #: id    C   H  S -    C   H  S [       start:      size   ]
>  ------------------------------------------------------------------------
>   0: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>   1: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>   2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>  *3: A6    0   1  1 - 3934  63 32 [          32:     8058848 ] OpenBSD     
> 
> 
> Take careful note of the total number of sectors (8060926 in this case).  
> Let NUM be the number of sectors divided by 63, rounded down to the 
> nearest integer.  Then, let SIZE be 
>  63*(NUM - 1)
> In this example, NUM is 127951 and SIZE is 8060850.  Continue as follows:
> 
> 
>  fdisk: 1> edit 3
>           Starting       Ending       LBA Info:
>   #: id    C   H  S -    C   H  S [       start:      size   ]
>  ------------------------------------------------------------------------
>  *3: A6    0   1  1 - 3934  63 32 [          32:     8058848 ] OpenBSD     
>  Partition id ('0' to disable)  [0 - FF]: [A6] (? for help) 0
>  Partition 3 is disabled.
>  fdisk:*1> edit 0
>           Starting       Ending       LBA Info:
>   #: id    C   H  S -    C   H  S [       start:      size   ]
>  ------------------------------------------------------------------------
>   0: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>  Partition id ('0' to disable)  [0 - FF]: [0] (? for help) 0B
>  Do you wish to edit in CHS mode? [n] n
>  offset: [0] 63
> 
> 
> At the next prompt, enter the number SIZE that we had previously 
> calculated.
> 
> 
>  size: [0] 8060850
>  fdisk:*1> print
>  Disk: sd0    geometry: 3935/64/32 [8060926 Sectors]
>  Offset: 0    Signature: 0xAA55
>           Starting       Ending       LBA Info:
>   #: id    C   H  S -    C   H  S [       start:      size   ]
>  ------------------------------------------------------------------------
>   0: 0B    0   1 32 - 3935  63 17 [          63:     8060850 ] Win95 FAT-32
>   1: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>   2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>   3: 00    0   0  0 -    0   0  0 [           0:           0 ] unused      
>  fdisk:*1> quit
>  Writing current MBR to disk.
> 
> 
> And notice that the 3935 that I could not explain is immediately accounted 
> for.  The problem is solved!

Nice work!

Notice that the 8060926 sectors the disk has in LBA mode is more than
3935 * 64 * 32 = 8058880, so there are 2046 more sectors in LBA
mode than in CHS mode.

Assuming 63 sectors per track instead and ignoring cylinder and head
count gives a spill of 13 sectors. I would have guessed Windows
used the classical fake geometry of 16383/16/63, and maybe it is:
if it also does not need to place partitions on cylinder
boundaries it all adds up.

Maybe you can use the 'e' command in disklabel to set drive parameters
to 63 sectors/track, 16 tracks/cylinder, 1008 sectors/cylinder,
7997 cylinders and 8060926 sectors. That would make the last disk
sector have CHS address 7996/15/13, 7996/15/14-63 being nonexistent,
and the last sector of the last whole track would be CHS 7996/14/63.
Partition in 7997/16/63 geometry:
          Starting       Ending       LBA Info:
  #: id    C   H  S -    C   H  S [       start:      size   ]
 ------------------------------------------------------------------------
  0: 0B    0   1  1 - 7996  14 63 [          63:     8060850 ] Win95 FAT-32
 
That was a lot of guessing from me. Does it make sense?

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply via email to