Subject: Re: Bootability eludes me once again
To: Anne Bennett <anne@alcor.concordia.ca>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-i386
Date: 05/01/2002 14:49:25
On Tue, Apr 30, 2002 at 05:18:14PM -0400, Anne Bennett wrote:
> 
> [Apologies for the long post; I've been at this for hours so I have a
>  lot of test and reading results to report.]
> 
> I swear I'm not stupid.  Really.  What's crazy is that back in November,
> I went through something like this, Wolfgang Solfrank explained to me
> how the i386 boot sequence works, and I was quite sure I understood.
> Certainly, I was able to fix the system last time.
> 
> Now I have another system that won't boot properly, and I'm *sure* I
> did everything right!  Well, obviously not???
> 
> My understanding
> ----------------
> 
> (Boot process for the case where the NetBSD partition is *not* the entire
> disk, and does *not* line up on sector zero of the disk:)
> 
>   - The boot ROM of the hardware reads sector zero of the disk, and
>     jumps to it.  This sector should contain "master boot code",
>     placed there by "fdisk", as well as the "DOS partition table".
>     This code can be the regular boot code or the bootselect code.
>     I'll call is the "part zero" boot code.
> 
>   - The above part zero bootcode reads the DOS partition table, finds the
>     active partition (in this case, the NetBSD partition) (or, if
>     bootselect, it may allow the user to select an alternative partition
>     using one of the function keys), then reads the first sector of that
>     and jumps to it.  This first sector of the NetBSD part of the disk
>     should contain part 1 of the NetBSD boot code (the "countdown");
>     the next sector contains the NetBSD disk label (including the NetBSD
>     partition table).
> 
>   - Finally, the "countdown" code reads the NetBSD disk label, based
>     on which it finds the rest (part 2) of the NetBSD boot code, which
>     in turn starts the kernel.
> 
> Parts 1 and 2 of the NetBSD boot code are written by "installboot".
> Part 1 by definition goes into the first sector of the NetBSD part of the
> disk, or so we hope: "installboot" seems to place it in the first sector
> of the partition specified on the command line, so we must make sure
> that the partition we specify to "installboot" starts at the beginning
> of the NetBSD part of the disk as per the MBR partition table.  Part 2
> of the boot code is placed in the filesystem on the given partition.
> 
> The list of part 2 block locations appears to be hard-coded into part
> 1, which suggests that part 1 does *not* read the filesystem to find
> the "/boot" file, but rather knows where the "rest of itself" is.  On
> the other hand, I can use a part 2 on sd0a from a part1 obtained from
> fd0a, which suggests that part 1 *can* read the filesystem (it can
> read it enough to do "ls", anyway!).  Confusion still reigns. :-(

You're wrong on one thing here: the "countdown" code (with the small
command line interpreter) is in the part 2 of the boot code. So really,
the part 1 (in the first sector of the partition) only knows to load
a list of sectors. It has no filesystem or even disklabel knowledge.
When you type "boot hd1a:" from floppy, you're already in the boot 2 code.

> 
> 
> Symptom
> -------
> 
> When coming up from a "reset", this Pentium III with IDE and SCSI
> controllers reports its devices like so:
> 
> |  Auto-Detecting Pri Master.. IDE Hard Disk
> |  Auto-Detecting Sec Master.. ATAPI CDROM
> |  
> |  Pri Master: AR1.0400 MAXTOR 6L040J2
> |              Ultra DMA Mode-4, S.M.A.R.T. Capable but Disabled
> |  Sec Master: 1.09 Compaq CRD-8320B
> |  
> |  Adaptec AHA-2940 Ultra/Ultra W BIOS v1.23
> |  (c) 1996 Adaptec, Inc. All Rights Reserved
> |  
> |  <<< Press <Ctrl><A> for SCSISelect (TM) Utility! >>>
> |  
> |    SCSI ID:LUN NUMBER #:# 0:0 - SGI      SEAGATE ST51080N - Drive D: (81h)
> |    SCSI ID:LUN NUMBER #:# 1:0 - QUANTUM  FIREBALL ST3.2S - Drive 82h
> |    SCSI ID:LUN NUMBER #:# 2:0 - QUANTUM  FIREBALL ST4.3S - Drive 83h
> |    SCSI ID:LUN NUMBER #:# 4:0 - TANDBERG TDC 3800
> |    SCSI ID:LUN NUMBER #:# 6:0 - HP       C1790A
> |  
> |  BIOS Installed Successfully!

Hum, there's a problem here. If you want to boot from scsi, I guess
the first SCSI disk should appear as C: (80h) not D:.
It appears as D: because the BIOS already assigned C: to the IDE drive.

Reading though the rest of your message I guess what's the problem
is here is that the bios gets the disk numbers wrong: when set to boot from
SCSI it will load the boot sector of D:, but then claim to the boot sector
that it was loaded from C:
If your IDE disk isn't used for anything else but storing data in NetBSD
you can disable C: in BIOS (just claim there is no C: drive, don't disable 
the IDE controller). Then the SCSI BIOS should assign C: to the first SCSI
disk and the boot should work.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
--