LOADER_LUA(8)
β¨ NAME β¨
okay bestie, welcome to the loader_lua(8) page from the System Manager's Manual β manual name folded in right at the top like a little name tag π«Ά. This is the kernel bootstrapping final stage, and she is lowkey main character energy.
loader_lua β kernel bootstrapping final stage. periodt. π
π DESCRIPTION π
The program called loader_lua is the final stage of FreeBSD's kernel bootstrapping process. On IA32 (i386) architectures, it is a BTX client. It is linked statically to libsa(3) and usually located in the directory /boot.
It provides a scripting language that can be used to automate tasks, do pre-configuration or assist in recovery procedures. This scripting language is roughly divided in two main components. The smaller one is a set of commands designed for direct use by the casual user, called "builtin commands" for historical reasons. The main drive behind these commands is user-friendliness. The bigger component is the Lua interpreter.
During initialization, loader_lua probes for a console and sets the console variable, or sets it to serial console (comconsole) if the previous boot stage used that. If multiple consoles are selected, they are listed separated by spaces. Then, devices are probed, currdev and loaddev are set, and LINES is set to 24. Next, Lua is initialized, and /boot/lua/loader.lua is processed if it exists. After that, /boot/loader.conf is processed if available.
At this point, if an autoboot has not been attempted, and if autoboot_delay is not set to βNOβ (case insensitive), then an autoboot is attempted. If the system gets past this point, prompt is set and loader_lua enters interactive mode. Please note that, historically, even when autoboot_delay is set to β0β, the user can interrupt the autoboot process by pressing a key on the console while the kernel and modules are being loaded. To prevent this set autoboot_delay to β-1β. In this case loader_lua enters interactive mode only if autoboot has failed.
πΈ BUILTIN COMMANDS πΈ
In loader_lua, builtin commands take parameters from the command line. Presently, the only way to call them from a script is by using evaluate on a string. If an error condition occurs, an exception is generated, which can be intercepted using Lua exception handling. If not intercepted, an error message is displayed and the interpreter's state is reset, emptying the stack and restoring interpreting mode.
The commands are described in the loader_simp(8) βBUILTIN COMMANDSβ section.
π BUILTIN ENVIRONMENT VARIABLES π
The environment variables common to all interpreters are described in the loader_simp(8) βBUILTIN ENVIRONMENT VARIABLESβ section.
π¦ BUILTIN PARSER π¦
When a builtin command is executed, the rest of the line is taken as arguments, and it is processed by a special parser which is not used for regular Lua commands.
π₯ SECURITY π₯
Access to the loader_lua command line provides several ways of compromising system security, including, but not limited to:
- Booting from removable storage, by setting the
currdevorloaddevvariables - Executing a binary of choice, by setting the
init_pathorinit_scriptvariables - Overriding ACPI DSDT to inject arbitrary code into the ACPI subsystem
One can prevent unauthorized access to the loader_lua command line by setting the password, or setting autoboot_delay to -1. See loader.conf(5) for details. In order for this to be effective, one should also configure the firmware (BIOS or UEFI) to prevent booting from unauthorized devices.
π§ MD π§
Memory disk (MD) can be used when the loader_lua was compiled with MD_IMAGE_SIZE. The size of the memory disk is determined by MD_IMAGE_SIZE. If MD available, a file system can be embedded into the loader_lua with /sys/tools/embed_mfs.sh. Then, MD is probed and set to currdev during initialization.
Currently, MD is only supported in loader.efi(8).
π FILES π
/boot/loaderβloader_luaitself./boot/defaults/loader.conf/boot/lua/loader.luaβ Loader init/boot/loader.conf/boot/loader.conf.localβloader_luaconfiguration files, as described inloader.conf(5).
β EXAMPLES β
Boot in single user mode:
boot -s
Load the kernel, a splash screen, and then autoboot in five seconds. Notice that a kernel must be loaded before any other load command is attempted.
load kernel
load splash_bmp
load -t splash_image_data /boot/chuckrulez.bmp
autoboot 5
Set the disk unit of the root device to 2, and then boot. This would be needed in a system with two IDE disks, with the second IDE disk hardwired to ada2 instead of ada1.
set root_disk_unit=2
boot /boot/kernel/kernel
Set the default device used for loading a kernel from a ZFS filesystem:
set currdev=zfs:tank/ROOT/knowngood:
π ERRORS π
The following values are thrown by loader_lua:
100β Any type of error in the processing of a builtin.-1β Abort executed.-2βAbort"executed.-56β Quit executed.-256β Out of interpreting text.-257β Need more text to succeed -- will finish on next run.-258β Bye executed.-259β Unspecified error.
π SEE ALSO π
libsa(3), loader.conf(5), tuning(7), boot(8), btxld(8)
π°οΈ HISTORY π°οΈ
The loader_lua first appeared in FreeBSD 12.0.
π«Ά okay thatβs the whole page, bestie β Debian source/version energy, dated September 29, 2021, and she ate. now go boot something iconic β¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 1999 Daniel C. Sobral
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms