xref: /openbsd/share/man/man8/man8.i386/boot_i386.8 (revision 75643a34)
1.\"	$OpenBSD: boot_i386.8,v 1.7 2002/10/17 23:18:51 miod 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.Dd September 4, 1997
34.Dt BOOT_I386 8 i386
35.Os
36.Sh NAME
37.Nm boot_i386
38.Nd i386 system bootstrapping procedures
39.Sh DESCRIPTION
40.Ss Cold starts
41The
42.Tn "PC AT"
43clones will perform a POST (Power On Self Test) upon being booted cold.
44This test will find and initialize memory, keyboard, and other devices.
45It will search for and initialize any extension ROMs that are present,
46and then attempt to boot the operating system from an available boot
47drive.
48Failing this, older IBM systems came up in ROM BASIC.
49.Pp
50The newer
51.Tn "PC AT"
52clones attempt to boot off the drive specified in the BIOS setup, or
53if it is an older BIOS, it will start with checking for a disk in floppy
54drive A (otherwise known as drive 0) first, and failing that, attempt to
55boot the hard disk C (otherwise known as hard disk controller 1, drive 0).
56.Ss Warm starts
57The BIOS loads the first block (at physical location: track 0, head 0,
58sector 1) off the boot device into memory, and if the last two bytes in the
59block match the signature 0xAA55, the BIOS considers the block a valid
60bootable drive.
61The BIOS then proceeds to call the machine code program in this block.
62If the BIOS is current, it will also pass the boot drive
63to the boot block in register %dl.
64.Pp
65There are two different types of boot blocks on devices.
66There is the
67MBR (master boot record) and the PBR (partition boot record).
68A digression
69into a little piece of history will quickly give light as to why this is so.
70In the beginning, the PC
71.Dq architecture
72came with a single or dual floppy
73drives, and no hard drives.
74The only type of bootable sectors on any device were the PBRs.
75They were responsible for loading the rest of the operating
76system from the correct device.
77When hard disks came out, it was felt that
78such a huge space should be able to be partitioned into separate drives,
79and this is when the MBR was invented.
80.Pp
81The MBR relocates itself upon being loaded and invoked by the BIOS.
82Embedded within the MBR is a partition table, with four partition table
83entries.
84The MBR code traverses this table (which was loaded with the
85MBR by the BIOS), looking for an active entry, and then loads the MBR or
86PBR from the disk location specified by the partition table entry.
87So in reality, the MBR is nothing more than a fancy chaining PBR.
88.Pp
89Note: The MBR could load another MBR, which is the case when you are booting
90off an extended partition.
91In other words, the first block of an extended
92partition is really an MBR, which will then load the corresponding MBR or PBR
93out of its extended partition's partition table.
94.Ss Geometry translation
95.Em WARNING :
96This portion of the
97.Dq PC BIOS Architecture
98is a mess, and a compatibility nightmare.
99.Pp
100The PC BIOS has an API to manipulate any disk that the BIOS happens to
101support.
102This interface uses 10 bits to address the cylinder, 8 bits to
103address the head, and 6 bits to address the sector of a drive.
104This restricts any application using the BIOS to being able to address only
1051024 cylinders, 256 heads, and 63 (since the sectors are 1 based) sectors
106on a disk.
107These limitations proved to be fine for roughly 3 years after
108the debut of hard disks on PC computers.
109.Pp
110Many (if not all) newer drives have many more cylinders than the BIOS API
111can support, and likely more sectors per track as well.
112To allow the BIOS the ability of accessing these large drives, the BIOS would
113.Dq re-map
114the
115cylinder/head/sector of the real drive geometry into something that would
116allow the applications using the BIOS to access a larger portion of the
117drive, still using the restricted BIOS API.
118.Pp
119The reason this has become a problem is that any modern OS will use its own
120drivers to access the disk drive, bypassing the BIOS completely.
121However,
122the MBR, PBR, and partition tables are all still written using the original
123BIOS access methods.
124This is for backwards compatibility to the original IBM PC!
125.Pp
126So the gist of it is, the MBR, PBR, and partition table need to have BIOS
127geometry offsets and cylinder/head/sector values for them to be able to
128load any type of operating system.
129This geometry can, and likely will,
130change whenever you move a disk from machine to machine, or from controller
131to controller.
132.Em They are controller and machine specific .
133.Ss Boot process options
134On most
135.Ox
136systems, booting
137.Ox
138from the BIOS will eventually load the
139.Ox -specific
140i386 bootstrapping code.
141This versatile program is described in a separate document,
142.Xr boot 8 .
143Other bootstrapping software may be used, and can chain-load the
144.Ox
145bootstrapping code, or directly load the kernel.
146In the latter case, refer to your bootloader documentation to know which
147options are available.
148.Ss Abnormal system termination
149In case of system crashes, the kernel will usually enter the kernel
150debugger,
151.Xr ddb 4 ,
152unless it is not present in the kernel, or it is disabled via the
153.Em ddb.panic
154sysctl.
155Upon leaving ddb, or if ddb was not entered, the kernel will halt the system
156if it was still in device configuration phase, or attempt a dump to the
157configured dump device, if possible.
158The crash dump will then be recovered by
159.Xr savecore 8
160during the next multi-user boot cycle.
161It is also possible to force other behaviours from ddb.
162.Sh FILES
163.Bl -tag -width /usr/mdec/biosboot -compact
164.It Pa /bsd
165default system kernel
166.It Pa /usr/mdec/mbr
167system MBR image
168.It Pa /usr/mdec/biosboot
169system primary stage bootstrap (PBR)
170.It Pa /usr/mdec/boot
171system second stage bootstrap (usually also installed as
172.Pa /boot )
173.El
174.Sh SEE ALSO
175.Xr ddb 4 ,
176.Xr boot 8 ,
177.Xr halt 8 ,
178.Xr init 8 ,
179.Xr installboot 8 ,
180.Xr reboot 8 ,
181.Xr savecore 8 ,
182.Xr shutdown 8
183.Sh BUGS
184The
185.Dq PC BIOS Architecture
186makes this process very prone to weird and
187wonderful interactions between different operating systems.
188.Pp
189There is no published standard to the MBR and PBR,
190which makes coding these a nightmare.
191.\" .Pp
192.\" Somebody *please* write me a decent BIOS, and make them (the masses) use it!
193