Subject: Changing NetBSD's partition ID from 0xa5 (was: NetBSD and FreeBSD co-existing)
To: None <port-i386@NetBSD.ORG>
From: Duncan McEwan <duncan@MCS.VUW.AC.NZ>
List: port-i386
Date: 06/26/1997 17:47:54
This thread seems to have pretty much died down, and though I don't want to
prolong it past it's use-by date, since I started it off, I figured I'd report
where I'm at now (thanks to a number of helpful suggestions!).

By temporarily changing the ID of my FreeBSD partition before installing
NetBSD I managed to get the two systems installed, with FreeBSD in the first
partition and NetBSD in the 2nd.  But I could only get NetBSD to boot if I
altered the partition type of the FreeBSD partition to something other than
165.  As others subsequently pointed out in this thread, NetBSD won't boot
properly if it isn't the *first* ID 165 partition on a disk.

Then I redid both my NetBSD and FreeBSD installations, reversing the order
(ie, putting NetBSD at the start of the disk) to see if FreeBSD coped any
better with being in the 2nd type 165 partition on a disk.  The answer seems
to be "No" ... :-( (both experimentally, and from a quick look at the code in
"src/sys/i386/boot/biosboot").  (This is true of a FreeBSD current from around
mid-march this year - I don't know if it's different now).

[Sidenote: my first attempt installing NetBSD in the first partition failed
because I made the offset of that partition 0.  This caused the NetBSD install
to figure it was being installed on the whole disk, and so it installed it's
primary bootstrap block in sector 0, thereby overwriting my existing DOS
partition table with it's own fake one.  When I defined NetBSD's partition to
start at sector 63 of the disk the install left the MBR untouched.]

So, it seems that it doesn't matter which OS is first on the disk -- the other
will not boot if both have partition ID's of 165.

So I started looking at what was necessary to change NetBSD's partition ID
from 165 (0xa5).  I changed the code in sys/arch/i386/stand/lib/biosdisk.c to
check first for 167 then 165.  I also changed arch/i386/i386/disksubr.c to
check for both, and in "sys/arch/i386/stand/lib/crt/bootsect/start_bootsect.S"
changed BSDPART from 0xA5 to 0xA7 (I wasn't confident enough in my i386
assembly to make it check for both).

With the resulting biosboot.sym and kernel installed, the boot blocks loaded
but then couldn't find the file "netbsd".  When I used the boot program's "ls
wd0a:" command, I found I was looking at my FreeBSD root partition!  So I
assume that there is still an 0xa5 reference lurking somewhere that's causing
the boot process to find the FreeBSD partition rather than the NetBSD one
(with id 167/0xa7).

If anyone who knows the boot process a little better can tell me what else I
might have to change, I'll give it a go...!

Duncan