Subject: Re: help installing dual-boot system with NetBSD 1.2 and Windows 95
To: None <smw@alcor.concordia.ca>
From: Zdenek Salvet <salvet@horn.ics.muni.cz>
List: port-i386
Date: 09/09/1997 12:57:53
> The goal of the exercise was to help a colleague install Windows 95 and
> NetBSD on a Pentium with a Quantum Fireball SCSI disk and Adaptec 2940
> SCSI controller.
> 
> For reference, NetBSD reports this disk as having
> 
>     6810 cylinders
>        5 heads
>      184 sectors/track
>     3067 Mb total capacity
> 
> Initially we used DOS fdisk to create two equally-sized partitions on
> the brand new disk, with each one containing 3405 cylinders.  For some

Hm, I don't think DOS fdisk allows to use cylinder counts, it knows
only MB or percents.

> reason I don't understand, these were reported by DOS fdisk as having
> 1537 and 1530 Mb capacity, respectively.

It uses translated geometry (see below): 196 cylinders + 195 cylinders.

> We began by installing NetBSD onto the second partition, which seemed
> to work perfectly well...
> 
> ...except that the installation process overwrote the disk's master boot
> record, leaving no trace of the original first partition.

You have not marked the second partition as NetBSD partition (type 165).
AFAIK, pfdisk is best for that.

> At this point, we do indeed have both systems installed, and by using
> BSL's restore function, we can restore either the NetBSD MBR or the
> Windows version, but nothing I've been able to think of has succeeded
> in writing a single MBR that supports both systems.
> 
> I've tried versions of fdisk from DOS, NetBSD and Linux, along with
> pfdisk from ftp.netbsd.com:/pub/NetBSD/NetBSD-1.2/i386/utils/, but so
> far without being able to discern the magic combination of parameters
> needed to make things work.
> 
> The symptoms are quite strange indeed:
> 
>   First of all, Linux fdisk and pfdisk both translate the disk geometry
>   to 391 cylinders, 255 heads and 63 sectors/track, but I believe that's
>   a red herring.

It is used by BIOS, you can use it anywhere - NetBSD can cope with it.
This sort of translation is useful for DOS and booting from partitions
above physical cylinder 1023 . 
There is no need to change the geometry used by pfdisk.

>   Both Linux fdisk and pfdisk report that the Windows 95 partition
>   begins at sector 63, and occupies 3,148,677 sectors.  When given the
>   "real" disk geometry, pfdisk reports that the cylinder range for the
>   Windows 95 partition is 0 - 3422 inclusive...  All of these numbers
>   seem larger than they should be, and I don't understand why.
> 
>   Under the NetBSD MBR, NetBSD fdisk reports as follows (incidentally,
>   these are *exactly* the same numbers reported by fdisk on a different
>   NetBSD system with the identical drive and SCSI adapter, where NetBSD
>   occupies the entire disk!):
> 
>         # fdisk /dev/rsd0a
>         ******* Working on device /dev/rsd0a *******
>         parameters extracted from in-core disklabel are:
>         cylinders=6810 heads=5 sectors/track=184 (920 sectors/cylinder)
>         
>         Figures below won't work with BIOS for partitions not in cylinder 1
>         parameters to be used for BIOS calculations are:
>         cylinders=6810 heads=5 sectors/track=184 (920 sectors/cylinder)
>         
>         Warning: BIOS sector numbering starts with sector 1
>         Information from DOS bootblock is:
>         The data for partition 0 is:
>         <UNUSED>
>         The data for partition 1 is:
>         <UNUSED>
>         The data for partition 2 is:
>         <UNUSED>
>         The data for partition 3 is:
>         sysid 165 (NetBSD or 386BSD)
>             start 0, size 50000 (24 MB), flag 80
>                 beg: cylinder    0, head   0, sector  1
>                 end: cylinder 1023, head 255, sector 63
>
>   Incidentally, both Linux fdisk and pfdisk agree with these ridiculous-
>   seeming numbers.  How can a 1.5 Gb partition fit into 24 Mb?  Is most
>   of it stored in hyperspace? :-)

This is not valid partition table since you have not created NetBSD
partition correctly during install. NetBSD has thus placed its disklabel
at the start of the disk. This is similar to NetBSD-only disk where 
partition table is not needed at all.

>   (For the record, 24 Mb isn't even the size of NetBSD's root file
>   system on this particular machine -- we set that up to be 32 Mb.  I
>   have no idea where the "24 Mb" figure is coming from!)
> 
>   NetBSD disklabel reports partitions c: and d: as follows:
> 
>     #        size  offset  fstype  [fsize bsize  cpg]
>       c:  3132600 3132600  unused       0     0       # (Cyl. 3405 - 6809)
>       d:  6265200       0  unused       0     0       # (Cyl.    0 - 6809)
> 
> By switching back and forth between MBRs, we can boot either OS at will;
> thus I'm confident that neither one has overwritten any actual data from
> the other, and thus it should be possible to write an appropriate MBR
> that would support both, merely by changing the active partition...
> 
> ...but I seem to be completely out of my depth as to *how* to do that.
> Can anyone help?

1. restore your NetBSD MBR
2. boot NetBSD from install diskettes and break to shell
3. save output of "disklabel sd0"
4. execute "halt", so disklabel file is synced to the diskette
5. restore Windows MBR
6. correct partition info with pfdisk (don't change geometry) 
   - the sector info for NetBSD partition should be offset=3132600,size=3132600
   - the partition id for NetBSD partition should be 165
          (you should probably enter "2 165 196 390" )
   - DONT FORGET TO WRITE PART. TABLE TO DISK ("w")
7. install OS-BS ( or other quality boot selector )   
8. boot NetBSD from install diskettes and break to shell
9. restore disklabel with "disklabel -R sd0 file_saved_in_step_3"
10. reboot from HD

-- 
Zdenek Salvet                                              salvet@ics.muni.cz 
----------------------------------------------------------------------------
           If God had meant for us to be in the Army,
         we would have been born with green, baggy skin.