LOADER.LUA(8)
π LOADER.LUA(8) β the bootloader Lua binding module, bestie π
okay so real talk, this is a System Manager's Manual page for loader.lua, and it's genuinely one of the most useful little pages in the whole FreeBSD boot situation. buckle up π
β¨ NAME β¨
loader.lua β the bootloader Lua binding module π¦
πΈ DESCRIPTION πΈ
The built-in Lua bindings for the FreeBSD boot loaders (the ones using the Lua interpreter, obvi) are available via the loader table.
The loader table is always available in Lua scripts. Like, no need to require it like you have to do with other loader-specific modules β it's just there. main character energy fr fr π
π Exported Variables π
The following variables are provided by the Lua interpreter in the loader table:
machineβ the target'shw.machinesysctl(8)value.machine_archβ the target'shw.machine_archsysctl(8)value. iykyk but some boot loaders are 32-bit applications that then load a 64-bit kernel. In those cases,machine_archrepresents the 32-bit architecture, not the 64-bit architecture. don't get it twisted πlua_pathβ the current lua loading path.versionβ the version of the boot program.
π§ Exported Functions π§
The following functions are exported in the loader table.
delay(usec)β delay for usec microseconds. nap time bestie π΄command_error()β returns the error string from the last command to fail.command(argc, argv)β likeperform()but the arguments are already parsed onto the stack.exit(status)β exit the boot loader back to the firmware with a status of status. The interpretation of this value is firmware specific. bye bye πinterpret(str)β execute the loader builtin command str as if it were typed by the user. This will first try to execute str as Lua. If that fails, it will attempt to execute it as a cli command, including those defined by thecli.lua(8)mechanism. If that fails, it will attempt to execute it as a builtin command and return the same values asperform(). she's versatile πββοΈparse(str)β parses the command str into its words and return those words on the stack.getenv(name)β obtains the value of the environment variable name.has_command(cmd)β returnstrueif command is present in the interpreter as a builtin. Otherwise it returnsniland an error string. It does not check the βcliβ table to see if a user defined command has been created. so don't come for her about that πhas_feature(feature)β returnstrueif the feature is enabled. Otherwise it returnsniland an error string.perform(str)β execute the loader builtin command str. Returns the result of the command, one of the following values:loader.CMD_OKβ the command completed successfully. slay βloader.CMD_WARNβ the command was successful, but the user stopped its output prematurely.loader.CMD_ERRORβ the command did not complete successfully. Usecommand_errorto retrieve the error.loader.CMD_CRITβ the command returned a critical error that was already printed.loader.CMD_FATALβ the command determined continuation was not possible and the loader panicked. In practice, though,panic()does not return. π like. it literally does not come back.
printc(str)β outputs the string using the loader'sputchar()function. This function is also available globally asprintc(). two names, one icon π«Άsetenv(name, value)β insert or reset the environment variable name into the loader's environment list. If no environment variable with this name exists, one is created. If one exists, its value is replaced.time()β returns the loader's notion of time, in seconds since1970. The value of loader's notion varies somewhat between different loading environments. ngl time is lowkey a vibe check in itself βunsetenv(name)β removes the environment variable name from the loader's environment list.
π¦ Compatibility π¦
The functions fb_bezier(), fb_drawrect(), fb_line(), fb_putimage(), fb_set_pixel(), term_drawrect(), and term_putimage() have moved to the gfx table. They remain in the loader table for a transition period and are documented in gfx.lua(8). so if you're looking for them, they're over there now β she moved out but still left a forwarding address π
π Default File π
In addition, the Lua interpreters start with the file /boot/lua/loader.lua when they start to boot the system. The default one will fixup the screen, load the configuration files, check for a password, and then load the menu or load the kernel file and then return. If autoboot is enabled, the loaded files will boot. iconic behavior honestly π
π₯ SEE ALSO π₯
loader.conf(5), core.lua(8), gfx.lua(8), loader(8), sysctl(8)
π AUTHORS π
The loader.lua man page was written by Warner Losh <imp@FreeBSD.org>. thank you warner, we love you π«Ά
π BUGS π
command() and perform() should return a tuple when there's CMD_ERROR or worse. yeah. that's the whole bug. it's giving "known issue, we're aware" π
β¨ and that's the page, bestie β¨
this one came out of the Debian side of things, dated March 29, 2025 β so go forth, boot responsibly, and remember: the loader table was always there for you πππ¦
π¦ 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) 2024 Netflix, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms