1.\" $OpenBSD: boot_i386.8,v 1.6 2002/01/04 21:56:04 kjell 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 40.Tn i386-specific 41system bootstrapping procedures 42.Sh DESCRIPTION 43.Ss Power fail and crash recovery 44Normally, the system will reboot itself at power-up or after crashes. 45An automatic consistency check of the file systems will be performed, 46and unless this fails, the system will resume multi-user operations. 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.Ss Warm starts 64The BIOS loads the first block (at physical location: track 0, head 0, 65sector 1) off the boot device into memory, and if the last two bytes in the 66block match the signature 0xAA55, the BIOS considers the block a valid 67bootable drive. 68The BIOS then proceeds to call the machine code program in this block. 69If the BIOS is current, it will also pass the boot drive 70to the boot block in register %dl. 71.Pp 72There are two different types of boot blocks on devices. 73There is the 74MBR (master boot record) and the PBR (partition boot record). 75A digression 76into a little piece of history will quickly give light as to why this is so. 77In the beginning, the PC 78.Dq architecture 79came with a single or dual floppy 80drives, and no hard drives. 81The only type of bootable sectors on any device were the PBRs. 82They were responsible for loading the rest of the operating 83system from the correct device. 84When hard disks came out, it was felt that 85such a huge space should be able to be partitioned into separate drives, 86and this is when the MBR was invented. 87.Pp 88The MBR relocates itself upon being loaded and invoked by the BIOS. 89Embedded within the MBR is a partition table, with four partition table 90entries. 91The MBR code traverses this table (which was loaded with the 92MBR by the BIOS), looking for an active entry, and then loads the MBR or 93PBR from the disk location specified by the partition table entry. 94So in reality, the MBR is nothing more than a fancy chaining PBR. 95.Pp 96Note: The MBR could load another MBR, which is the case when you are booting 97off an extended partition. 98In other words, the first block of an extended 99partition is really an MBR, which will then load the corresponding MBR or PBR 100out of its extended partition's partition table. 101.Sh GEOMETRY TRANSLATION 102.Em WARNING : 103This portion of the 104.Dq PC BIOS Architecture 105is a mess, and a compatibility nightmare. 106.Pp 107The PC BIOS has an API to manipulate any disk that the BIOS happens to 108support. 109This interface uses 10 bits to address the cylinder, 8 bits to 110address the head, and 6 bits to address the sector of a drive. 111This restricts any application using the BIOS to being able to address only 1121024 cylinders, 256 heads, and 63 (since the sectors are 1 based) sectors 113on a disk. 114These limitations proved to be fine for roughly 3 years after 115the debut of hard disks on PC computers. 116.Pp 117Many (if not all) newer drives have many more cylinders than the BIOS API 118can support, and likely more sectors per track as well. 119To allow the BIOS the ability of accessing these large drives, the BIOS would 120.Dq re-map 121the 122cylinder/head/sector of the real drive geometry into something that would 123allow the applications using the BIOS to access a larger portion of the 124drive, still using the restricted BIOS API. 125.Pp 126The reason this has become a problem is that any modern OS will use its own 127drivers to access the disk drive, bypassing the BIOS completely. 128However, 129the MBR, PBR, and partition tables are all still written using the original 130BIOS access methods. 131This is for backwards compatibility to the original IBM PC! 132.Pp 133So the gist of it is, the MBR, PBR, and partition table need to have BIOS 134geometry offsets and cylinder/head/sector values for them to be able to 135load any type of operating system. 136This geometry can, and likely will, 137change whenever you move a disk from machine to machine, or from controller 138to controller. 139.Em They are controller and machine specific . 140.Sh FILES 141.Bl -tag -width /usr/mdec/biosboot -compact 142.It Pa /bsd 143system code 144.It Pa /usr/mdec/mbr 145system MBR image 146.It Pa /usr/mdec/biosboot 147system primary stage bootstrap (PBR) 148.It Pa /boot 149system second stage bootstrap 150.El 151.Sh SEE ALSO 152.Xr boot 8 , 153.Xr halt 8 , 154.Xr installboot 8 , 155.Xr reboot 8 , 156.Xr shutdown 8 157.Sh BUGS 158The 159.Dq PC BIOS Architecture 160makes this process very prone to weird and 161wonderful interactions between different operating systems. 162There is no published standard to the MBR and PBR, 163which makes coding these a nightmare. 164Somebody *please* write me a decent BIOS, and make them (the masses) use it! 165