Subject: help installing dual-boot system with NetBSD 1.2 and Windows 95
To: None <port-i386@NetBSD.ORG>
From: Steven Winikoff <smw@alcor.concordia.ca>
List: port-i386
Date: 09/08/1997 13:05:47
Famous last words:  I thought I knew what I was doing, but... :-)

Now I think I need help.

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
reason I don't understand, these were reported by DOS fdisk as having
1537 and 1530 Mb capacity, respectively.

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.

When the time came to install Windows 95, a couple of weeks later, we
had to begin by using DOS fdisk again.  Strangely, the NetBSD partition
was reported as using only 24 Mb, but I dismissed that at the time as
being preposterous and surely due to a bug in the DOS program.

We were forced to delete the NetBSD partition, since DOS fdisk claimed
that it overlapped the new partition we were trying to create.  "No
problem", I figured, since after all the data wasn't being overwritten,
just the record of the partition in the MBR's table...  and besides, in
the meantime we'd obtained a copy of "BSL", and used that to make a copy
of the original NetBSD-only MBR.

We went ahead and installed Windows 95, using the first 3405 cylinders
of the disk.  Of course, Windows also rewrote the MBR, happily believing
it was the only OS on the machine. :-)

Being healthily paranoid^H^H^H^H^H^H^H^Hcareful :-), we made a backup of
the Windows-only MBR.

That's when the trouble started. :-(

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.

  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? :-)

  (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?

Thanks in advance,

     - Steven


P.S.

  We do have a full backup of the NetBSD side, although not of the
  Windows 95 installation.  I'm quite prepared to wipe NetBSD and
  start over if necessary, although I don't believe it should *be*
  necessary -- but even if we go ahead and do that, how can we prevent
  it from overwriting the MBR at that point and starting the whole
  cycle over again?
________________________________________________________________________
Steven Winikoff      |       smw@         | "I don't want to run the
Sr. Systems Manager  | alcor.concordia.ca | world; I merely want to own
Computing Services   |                    | a substantial portion of the
Concordia University | (514) 848-7619     | preferred stock" - Alan Dean
Montreal, QC, Canada | (10:00-18:00 EST)  | Foster,  Cat-A-Lyst