Diff for /wikisrc/how_netbsd_boots_on_x86.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/21 03:22:58 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 **Contents**  **Contents**
   
 [[!toc]]  [[!toc]]
   
 ##  Stage 0: Master Boot Record  ##  Stage 0: Master Boot Record
   
   * MBR source: `sys/arch/i386/stand/mbr/mbr.S`    * MBR source: `sys/arch/i386/stand/mbr/mbr.S`
   * MBR binaries: `/usr/mdec/mbr_*`    * MBR binaries: `/usr/mdec/mbr_*`
   * Error messages:    * Error messages: 
   
     * "Error x"      * "Error x" 
     * "No active partition" - self-explanatory      * "No active partition" - self-explanatory 
     * "Disk read error"      * "Disk read error" 
     * "No operating system" - PBR magic number was wrong      * "No operating system" - PBR magic number was wrong 
     * "Invalid CHS read" - CHS vs LBA check selected LBA reads, but BIOS does not support them      * "Invalid CHS read" - CHS vs LBA check selected LBA reads, but BIOS does not support them 
   
 MBR is read by the BIOS and then validated (checked for magic number 0xaa55 at  MBR is read by the BIOS and then validated (checked for magic number 0xaa55 at
 the end). If validation fails, BIOS may print evil error message and/or try  the end). If validation fails, BIOS may print evil error message and/or try
 next boot device; otherwise, BIOS passes control to MBR.  next boot device; otherwise, BIOS passes control to MBR.
   
 Unless it was compiled with `NO_BANNER`, MBR displays its banner: "NetBSD MBR  Unless it was compiled with `NO_BANNER`, MBR displays its banner: "NetBSD MBR
 Boot". Next, it checks if CHS or LBA addressing must be used in further BIOS  Boot". Next, it checks if CHS or LBA addressing must be used in further BIOS
 I/O calls. Since partition table entry stores both linear and CHS address,  I/O calls. Since partition table entry stores both linear and CHS address,
 linear address is computed from CHS address, and if it matches stored linear  linear address is computed from CHS address, and if it matches stored linear
 address - MBR will use CHS addressing. LBA addressing will be tried otherwise,  address - MBR will use CHS addressing. LBA addressing will be tried otherwise,
 even if it is not supported by BIOS.  even if it is not supported by BIOS.
   
 PBR is then loaded from 1st sector of active partition (or, if boot selector  PBR is then loaded from 1st sector of active partition (or, if boot selector
 was compiled into this MBR, it may be loaded from another partition or disk).  was compiled into this MBR, it may be loaded from another partition or disk).
   
 ##  Stage 1: Partition Boot Record, bootxx  ##  Stage 1: Partition Boot Record, bootxx
   
   * PBR source: `sys/arch/i386/stand/bootxx/pbr.S`    * PBR source: `sys/arch/i386/stand/bootxx/pbr.S`
   * bootxx source: `sys/arch/i386/stand/bootxx/bootxx.S`    * bootxx source: `sys/arch/i386/stand/bootxx/bootxx.S`
   * combined PBR+bootxx binaries: `/usr/mdec/bootxx_*`    * combined PBR+bootxx binaries: `/usr/mdec/bootxx_*`
   * Error messages:    * Error messages: 
   
     * '2' or "Disk read"      * '2' or "Disk read" 
     * 'B' or "Not a bootxx image" - phase 1 bootstrap's magic number was wrong      * 'B' or "Not a bootxx image" - phase 1 bootstrap's magic number was wrong 
     * 'P' or "No NetBSD partition"      * 'P' or "No NetBSD partition" 
     * 'L' or "Invalid CHS read" - see above      * 'L' or "Invalid CHS read" - see above 
   
 PBR loads phase 1 bootstrap (bootxx) from next 15 sectors on disk, validates  PBR loads phase 1 bootstrap (bootxx) from next 15 sectors on disk, validates
 and runs it.  and runs it.
   
 bootxx displays its banner: `NetBSD/(machine) (filesystem) Primary Bootstrap`  bootxx displays its banner: `NetBSD/(machine) (filesystem) Primary Bootstrap`
 and tries to load phase 2 bootstrap (boot2) from several locations:  and tries to load phase 2 bootstrap (boot2) from several locations:
   
   * start of MBR partition; or    * start of MBR partition; or 
   * start of MBR partition + RAIDframe offset; or    * start of MBR partition + RAIDframe offset; or 
   * start of partition 'a' in disklabel.    * start of partition 'a' in disklabel. 
   
   * bootxx error messages:    * bootxx error messages: 
   
     * "Boot failed (errno <...>): <...>"      * "Boot failed (errno <...>): <...>" 
     * All further messages are printed by boot2. For example, a single "0" and no other messages on PC console means that boot2 has autodetected and is using serial console.      * All further messages are printed by boot2. For example, a single "0" and no other messages on PC console means that boot2 has autodetected and is using serial console. 
   
 ##  Stage 2  ##  Stage 2
   
   * boot2 source: `sys/arch/i386/stand/boot/`    * boot2 source: `sys/arch/i386/stand/boot/`
   * boot2 binary: `/boot`    * boot2 binary: `/boot`
   
 ##  Glossary  ##  Glossary
   
 BIOS  BIOS
   
      Basic Input-Output System       Basic Input-Output System 
 MBR  MBR
   
      Main Boot Record, stored at LBA 0       Main Boot Record, stored at LBA 0 
 PBR  PBR
   
      Partition Boot Record, stored in first sector of bootable partition       Partition Boot Record, stored in first sector of bootable partition 
 CHS  CHS
   
      Cylinder, Head, Sector addressing       Cylinder, Head, Sector addressing 
 LBA  LBA
   
      Linear Block Address[ing]       Linear Block Address[ing] 
   
 ##  See also  ##  See also
   
   * [Making NetBSD Multiboot-Compatible](http://onlamp.com/pub/a/bsd/2007/03/01/inside-multiboot.html)    * [Making NetBSD Multiboot-Compatible](http://onlamp.com/pub/a/bsd/2007/03/01/inside-multiboot.html)
   
 ##  References  ##  References
   
   * [boot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?boot+8+NetBSD-current)    * [boot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?boot+8+NetBSD-current)
   * [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)    * [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)
   * [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-current)    * [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-current)
   * [mbr(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mbr+8+NetBSD-current)    * [mbr(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mbr+8+NetBSD-current)
   

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb