1.\" $OpenBSD: boot_i386.8,v 1.2 2001/06/10 19:02:19 mickey Exp $ 2.\" 3.\" Copyright (c) 1997 Tobias Weingartner 4.\" 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by Michael Shalayeff. 18.\" 4. The name of the author may not be used to endorse or promote products 19.\" derived from this software without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33 34.Dd September 4, 1997 35.Dt BOOT_I386 8 i386 36.Os 37.Sh NAME 38.Nm boot 39.Nd 40system bootstrapping procedures 41.Sh DESCRIPTION 42.Ss Power fail and crash recovery 43Normally, the system will reboot itself at power-up or after crashes. 44An automatic consistency check of the file systems will be performed, 45and unless this fails, the system will resume multi-user operations. 46.Pp 47.Ss Cold starts 48The 49.Tn "PC AT" 50clones will perform a POST (Power On Self Test) upon being booted cold. 51This test will find and initialize memory, keyboard, and other devices. 52It will search for and initialize any extension ROMs that are present, 53and then attempt to boot the operating system from an available boot 54drive. 55Failing this, older IBM systems came up in ROM BASIC. 56.Pp 57The newer 58.Tn "PC AT" 59clones attempt to boot off the drive specified in the BIOS setup, or 60if it is an older BIOS, it will start with checking for a disk in floppy 61drive A (otherwise known as drive 0) first, and failing that, attempt to 62boot the hard disk C (otherwise known as hard disk controller 1, drive 0). 63.Pp 64.Ss Warm starts 65The BIOS loads the first block (at physical location: track 0, head 0, 66sector 1) off the boot device into memory, and if the last two bytes in the 67block match the signature 0x55AA, the BIOS considers the block a valid 68bootable drive. 69The BIOS then proceeds to call the machine code program in this block. 70If the BIOS is current, it will also pass the boot drive 71to the boot block in register %dl. 72.Pp 73There are two different types of boot blocks on devices. 74There is the 75MBR (master boot record) and the PBR (partition boot record). 76A digression 77into a little piece of history will quickly give light as to why this is so. 78In the beginning, the PC 79.Dq architecture 80came with a single or dual floppy 81drives, and no hard drives. 82The only type of bootable sectors on any device were the PBRs. 83They were responsible for loading the rest of the operating 84system from the correct device. 85When hard disks came out, it was felt that 86such a huge space should be able to be partitioned into separate drives, 87and this is when the MBR was invented. 88.Pp 89The MBR relocates itself upon being loaded and invoked by the BIOS. 90Embeded within the MBR is a partition table, with four partition table 91entries. 92The MBR code traverses this table (which was loaded with the 93MBR by the BIOS), looking for an active entry, and then loads the MBR or 94PBR from the disk location specified by the partition table entry. 95So in reality, the MBR is nothing more than a fancy chaining PBR. 96.Pp 97Note: The MBR could load another MBR, which is the case when you are booting 98off an extended partition. 99In other words, the first block of an extended 100partition is really an MBR, which will then load the corresponding MBR or PBR 101out of its extended partition's partition table. 102.Sh GEOMETRY TRANSLATION 103.Em WARNING : 104This portion of the 105.Dq PC BIOS Architecture 106is a mess, and a compatibility nightmare. 107.Pp 108The PC BIOS has an API to manipulate any disk that the BIOS happens to 109support. 110This interface uses 10 bits to address the cylinder, 8 bits to 111address the head, and 6 bits to address the sector of a drive. 112This restricts any application using the BIOS to being able to address only 1131024 cylinders, 256 heads, and 63 (since the sectors are 1 based) sectors 114on a disk. 115These limitations proved to be fine for roughly 3 years after 116the debut of hard disks on PC computers. 117.Pp 118Many (if not all) newer drives have many more cylinders than the BIOS API 119can support, and likely more sectors per track as well. 120To allow the BIOS the ability of accessing these large drives, the BIOS would 121.Dq re-map 122the 123cylinder/head/sector of the real drive geometry into something that would 124allow the applications using the BIOS to access a larger portion of the 125drive, still using the restricted BIOS API. 126.Pp 127The reason this has become a problem is that any modern OS will use its own 128drivers to access the disk drive, bypassing the BIOS completely. 129However, 130the MBR, PBR, and partition tables are all still written using the original 131BIOS access methods. 132This is for backwards compatibility to the original IBM PC! 133.Pp 134So the gist of it is, the MBR, PBR, and partition table need to have BIOS 135geometry offsets and cylinder/head/sector values for them to be able to 136load any type of operating system. 137This geometry can, and likely will, 138change whenever you move a disk from machine to machine, or from controller 139to controller. 140.Em They are controller and machine specific . 141.Sh FILES 142.Bl -tag -width /usr/mdec/biosboot -compact 143.It Pa /bsd 144system code 145.It Pa /usr/mdec/mbr 146system MBR image 147.It Pa /usr/mdec/biosboot 148system primary stage bootstrap (PBR) 149.It Pa /boot 150system second stage bootstrap 151.El 152.Sh SEE ALSO 153.Xr boot 8 , 154.Xr halt 8 , 155.Xr installboot 8 , 156.Xr reboot 8 , 157.Xr shutdown 8 158.Sh BUGS 159The 160.Dq PC BIOS Architecture 161makes this process very prone to weird and 162wonderful interactions between different operating systems. 163There is no published standard to the MBR and PBR, 164which makes coding these a nightmare. 165Somebody *please* write me a decent BIOS, and make them (the masses) use it! 166