1 .\" Copyright (c) 1999 Daniel C. Sobral
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .Dd September 29, 2021
32 .Nd kernel bootstrapping final stage
38 kernel bootstrapping process.
39 On IA32 (i386) architectures, it is a
42 It is linked statically to
44 and usually located in the directory
47 It provides a scripting language that can be used to
48 automate tasks, do pre-configuration or assist in recovery
50 This scripting language is roughly divided in
52 The smaller one is a set of commands
53 designed for direct use by the casual user, called "builtin
54 commands" for historical reasons.
55 The main drive behind these commands is user-friendliness.
56 The bigger component is the Lua interpreter.
58 During initialization,
60 probes for a console and sets the
62 variable, or sets it to serial console
64 if the previous boot stage used that.
65 If multiple consoles are selected, they are listed separated by spaces.
66 Then, devices are probed,
73 Next, Lua is initialized, and
74 .Pa /boot/lua/loader.lua
75 is processed if it exists.
78 is processed if available.
82 has not been attempted, and if
86 (case insensitive), then an
89 If the system gets past this point,
93 enters interactive mode.
94 Please note that, historically, even when
98 the user can interrupt the autoboot process by pressing a key
99 on the console while the kernel and modules are being loaded.
106 enters interactive mode only if
112 builtin commands take parameters from the command line.
114 the only way to call them from a script is by using
117 If an error condition occurs, an exception is generated,
118 which can be intercepted using Lua exception handling.
119 If not intercepted, an error message is displayed and
120 the interpreter's state is reset, emptying the stack and restoring
123 The commands are described in the
127 .Ss BUILTIN ENVIRONMENT VARIABLES
128 The environment variables common to all interpreters are described in the
130 .Dq BUILTIN ENVIRONMENT VARIABLES
133 When a builtin command is executed, the rest of the line is taken
134 as arguments, and it is processed by a special parser which
135 is not used for regular Lua commands.
139 command line provides several ways of compromising system security,
140 including, but not limited to:
144 Booting from removable storage, by setting the
150 Executing a binary of choice, by setting the
156 Overriding ACPI DSDT to inject arbitrary code into the ACPI subsystem
159 One can prevent unauthorized access
162 command line by setting the
170 In order for this to be effective, one should also configure the firmware
171 (BIOS or UEFI) to prevent booting from unauthorized devices.
173 Memory disk (MD) can be used when the
177 The size of the memory disk is determined by
179 If MD available, a file system can be embedded into the
182 .Pa /sys/tools/embed_mfs.sh .
183 Then, MD is probed and set to
185 during initialization.
187 Currently, MD is only supported in
190 .Bl -tag -width /usr/share/examples/bootforth/ -compact
194 .It Pa /boot/defaults/loader.conf
195 .It Pa /boot/lua/loader.lua
197 .It Pa /boot/loader.conf
198 .It Pa /boot/loader.conf.local
200 configuration files, as described in
203 Boot in single user mode:
207 Load the kernel, a splash screen, and then autoboot in five seconds.
208 Notice that a kernel must be loaded before any other
210 command is attempted.
211 .Bd -literal -offset indent
214 load -t splash_image_data /boot/chuckrulez.bmp
218 Set the disk unit of the root device to 2, and then boot.
219 This would be needed in a system with two IDE disks,
220 with the second IDE disk hardwired to ada2 instead of ada1.
221 .Bd -literal -offset indent
223 boot /boot/kernel/kernel
226 Set the default device used for loading a kernel from a ZFS filesystem:
227 .Bd -literal -offset indent
228 set currdev=zfs:tank/ROOT/knowngood:
232 The following values are thrown by
234 .Bl -tag -width XXXXX -offset indent
236 Any type of error in the processing of a builtin.
247 Out of interpreting text.
249 Need more text to succeed -- will finish on next run.