Subject: Re: NetBSD and FreeBSD co-existing
To: None <jonathan@DSG.Stanford.EDU>
From: Arne Henrik Juul <arnej@stud.math.ntnu.no>
List: port-i386
Date: 06/23/1997 09:08:08
Jonathan Stone <jonathan@DSG.Stanford.EDU> wrote:
> I saved the files from one of the Linux partitions, changed its MBR
> partitiontype to BSD386 using the Linux fdisk, and start the NetBSD
> install.  The MBR got blown away.
> 
> Andrew Brown has reported similar problems installing onto systems
> with LILO in the MBR.  I don't think it's entirely due to pilot error
> in either case.  (And even if it *were*, IMHO disklabel and the
> install tools should do better checks, and give better warnings about
> what they think they're doing. Because it looks like they're doing
> _something_ wrong.)

Well, the problem is that disklabel is very very picky in what it
requires to avoid overwriting the MBR.  I remember trying my very
hardest to avoid this when I had to have dos/netbsd coexistence,
and still failing after 4-5 tries (this was with NetBSD 0.9 or so).

After the question was added one is safe as long as one always answer
"no" to "Erase the previous contents of the disk?", but then one might
despair of ever getting NetBSD installed instead :-(

The 1.2 disklabel, at least, has this code in it:

	if (dosdp && dosdp->dp_typ == DOSPTYP_386BSD && pp->p_size &&
		dosdp->dp_start == pp->p_offset) {
		sectoffset = pp->p_offset * lp->d_secsize;

"dosdp" is the first type 165 partition if there is one.
pp is &lp->d_partitions[2], meaning in effect, the "c" partition of
the disklabel you're trying to install.  This means that:

1) you have to have a valid partition table in the MBR.
2) you have to have a type 165 partition there, which will be used
   for NetBSD.
3) you have to make a "c" partition in the disklabel when you edit it.
4) the "c" partition has to have a non-zero size.
5) the start of the "c" DL partition has to match the start of the
   NetBSD (first type 165) MBR partition.  To obtain this also:
5a) the geometry used when editing the disklabel has to match the
   geometry used by the bios and thus the MBR partition table.

I *think* that making sure you do all of the above, it should
be possible to install NetBSD without overwriting the start
of the disk.  It helps to have fdisk on the install floppy.
Happily I have been able to use my entire disk for
NetBSD, so I haven't actually tried this lately.

Getting FreeBSD and NetBSD to coexist should be possible if you
make two type 165 MBR partitions and convince FreeBSD to use
the second one.  Actually I think I would install FreeBSD first
and use their sysinstall tool to fix the MBR and both disklabels.

  -  Arne H. J.