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