xref: /openbsd-src/sys/arch/amd64/stand/biosboot/biosboot.8 (revision 1ab5fc2386da5c3ba2c9098bcffe53acbd311901)
1.\"	$OpenBSD: biosboot.8,v 1.15 2022/06/27 16:39:34 jmc Exp $
2.\"
3.\" Copyright (c) 2003 Tom Cosgrove <tom.cosgrove@arches-consulting.com>
4.\" Copyright (c) 1997 Michael Shalayeff
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 MIND, 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: June 27 2022 $
29.Dt BIOSBOOT 8 amd64
30.Os
31.Sh NAME
32.Nm biosboot
33.Nd amd64-specific first-stage system bootstrap
34.Sh DESCRIPTION
35This small program (roughly 512 bytes of code) is responsible for
36loading the second-stage
37.Xr boot 8
38program (typically /boot), which in turn will load the kernel.
39.Pp
40.Nm
41must be installed by
42.Xr installboot 8 .
43As part of the installation,
44.Xr installboot 8
45patches
46.Nm
47with information about the location of
48.Xr boot 8
49on disk.
50Specifically, it writes the filesystem block number of
51.Xr boot 8 Ns 's
52inode,
53the offset within this block of the inode,
54and various filesystem parameters (taken from the superblock)
55required to convert filesystem blocks to disk sectors.
56Usually,
57.Xr boot 8
58is loaded from the root filesystem of the boot disk.
59If the boot disk is a
60.Xr softraid 4
61volume,
62.Xr installboot 8
63arranges for a copy of
64.Xr boot 8
65to be loaded from a dedicated single-inode filesystem located within
66the volume's meta data area.
67.Pp
68You must re-run
69.Xr installboot 8
70whenever
71.Xr boot 8
72is changed, as its inode may change.
73While it should not be necessary,
74it may also be advisable to re-run
75.Xr installboot 8
76if you move your disk between machines and/or controllers.
77.Pp
78When
79.Nm
80receives control from either the BIOS or the
81master boot record (MBR), it will print the message:
82.Pp
83.Dl Loading
84.Pp
85followed by a dot for every filesystem block it attempts to load.
86If /boot is loaded successfully,
87.Nm
88will put the cursor on the next line just before
89transferring control to the newly-loaded program.
90.Pp
91If possible,
92.Nm
93will read disk sectors using calls detailed in the Phoenix
94Enhanced Disk Drive Specification (EDD, sometimes known as LBA, reads).
95It will fall back to CHS reads only if EDD calls are not available.
96.Pp
97.Nm
98prints a
99.Sq ;\&
100after the
101.Dq Loading
102message if it is going to use CHS reads for any reason.
103For example, when booting from floppy or CD-ROM.
104.Pp
105.Nm
106may fail with any of the following error messages:
107.Bl -tag -width ERR_X__
108.It Er ERR I
109Too many indirect blocks.
110.Nm
111is capable of reading the direct blocks in
112.Xr boot 8 Ns 's
113inode (the location of which is patched into
114.Nm
115by
116.Xr installboot 8 )
117and the first indirect block,
118but it is not capable of reading further indirect blocks.
119This error indicates that further such indirect blocks were found.
120The system will not be able to boot.
121.Pp
122This is unlikely to ever happen in practice, as
123.Xr boot 8
124has to be quite large for this to be an issue.
125The smallest possible filesystem block size is 512 bytes
126(one sector per filesystem block).
127On such a system, there are 140 filesystem blocks that
128.Nm
129can read, so
130.Xr boot 8
131can be up to 70 KB.
132.Pp
133However, even on floppy disks the filesystem block size is 1024 bytes.
134This allows
135.Xr boot 8
136to occupy up to 268 disk blocks,
137i.e. to be 268 KB.
138On hard disks (default filesystem block size 16 KB)
1394,108 disk blocks are available, to allow
140.Xr boot 8
141to be over 64 MB in size!
142(Only direct blocks are required for
143.Xr boot 8 Ns s
144of up to 192 KB.)
145.It Er ERR M
146Bad magic.
147The ELF
148.Dq magic number
149\e7fELF in
150.Xr boot 8 Ns 's
151header was not found.
152This indicates that the first block of
153.Xr boot 8
154was not read correctly.
155This could be due to disk corruption,
156failing to run
157.Xr installboot 8 ,
158giving an invalid
159.Xr boot 8
160program as the
161.Ar boot
162argument to
163.Xr installboot 8 ,
164or
165incorrect geometry translation.
166.It Er ERR R
167Read error.
168The BIOS returned an error indication when
169.Nm
170attempted to read a disk sector.
171This might be any media error, including bad sectors (common on floppy disks),
172and invalid sectors (can occur with bad geometry translations).
173.It Er ERR X
174Can't boot.
175Issued when trying to read sectors in CHS mode,
176but the BIOS call
177.Em get\ drive\ parameters
178failed or gave a value of 0 for the number of sectors per track.
179In either case, it is not possible for
180.Nm
181to calculate the (cylinder, head, sector) values required to
182read any sectors.
183.El
184.Sh NOTES
185Using
186.Nm
187as the MBR,
188as has been done in the past,
189is not recommended, and is not supported.
190Instead, create a single
191.Xr fdisk 8
192partition that spans the entire disk.
193.Pp
194Despite the support for
195.Xr boot 8
196over the 8 GB boundary,
197good
198.Xr disklabel 8
199partitioning practices should still be followed.
200.Sh FILES
201.Bl -tag -width /usr/mdec/biosbootxx -compact
202.It Pa /usr/mdec/mbr
203Master Boot Record block
204.It Pa /usr/mdec/biosboot
205primary bootstrap
206.It Pa /boot
207secondary bootstrap
208.It Pa /usr/mdec/pxeboot
209PXE bootstrap
210.It Pa /bsd
211.Ox
212kernel
213.It Pa /bsd.sp
214.Ox
215kernel for single processor machines
216.It Pa /bsd.mp
217.Ox
218kernel for multiprocessor machines
219.It Pa /bsd.rd
220.Ox
221kernel for installation/recovery
222.El
223.Sh SEE ALSO
224.Xr softraid 4 ,
225.Xr boot 8 ,
226.Xr boot_amd64 8 ,
227.Xr disklabel 8 ,
228.Xr fdisk 8 ,
229.Xr installboot 8 ,
230.Xr pxeboot 8
231.Sh HISTORY
232.Nm
233was originally written by Michael Shalayeff for
234.Ox 2.1 .
235However it was based on bootstrap code from older versions of this
236operating system, other operating systems, other programs, and
237other people's work.
238.Pp
239It was significantly revised in December 2003 by Tom Cosgrove,
240in order to support LBA disk access (via the Phoenix Enhanced Disk
241Drive Specification API).
242At that time the internal table of disk blocks was removed, and
243.Nm
244modified to read filesystem block numbers from the inode.
245.Sh BUGS
246.Nm
247should perform and verify a checksum across the entire loaded
248.Xr boot 8
249image,
250rather than just checking the magic number in the first block.
251.Pp
252There is no BIOS error number reported nor is the location of the error
253reported.
254.Pp
255You can pick your motherboard, and you can pick your BIOS,
256but you can't pick your motherboard's BIOS.
257