---
name: "core.lua"
section: "8"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/core.lua"
---

# core.lua(8)

bootloader core module

## NAME

**core.lua** – bootloader core module

## DESCRIPTION

**core.lua** contains core functionality that does not have a more fitting module.

Before hooking into or using the functionality provided by **core.lua**, it must be included with a statement such as the following:

```
local core = require("core")
```

### CONSTANTS

The following raw key code constants are defined in **core.lua**:

- **KEY\_BACKSPACE**

  The backspace code. Should generally be checked along with **KEY\_DELETE** for backspace functionality.

- **KEY\_ENTER**

  The enter key, or hard return.

- **KEY\_DELETE**

  The delete code. Should generally be checked along with **KEY\_BACKSPACE** for backspace functionality.

The following key-string constants are defined in **core.lua**:

- **KEYSTR\_ESCAPE**

  The escape key.

- **KEYSTR\_CSI**

  The ANSI CSI sequence.

The following menu entry type constants are defined in **core.lua**:

- **MENU\_RETURN**

  Return to the parent menu.

- **MENU\_ENTRY**

  A normal menu entry.

- **MENU\_SEPARATOR**

  A menu entry that serves as a separator.

- **MENU\_SUBMENU**

  A menu entry that opens a submenu when selected.

- **MENU\_CAROUSEL\_ENTRY**

  A menu entry that rotates through items like a carousel upon selection of the menu entry.

Please see [menu.lua(8)](/menu.lua/8.md) for extended descriptions and usage of the **MENU\_\*** constants.

### Exported functions

The following functions are exported from **core.lua**:

- **core.setVerbose**(*verbose*)

  Sets or unsets boot\_verbose. If *verbose* is omitted, toggle the current verbose setting.

- **core.setSingleUser**(*singleUser*)

  Sets or unsets boot\_single. If *singleUser* is omitted, toggle the current single user setting.

- **core.getACPI**()

  Return true if ACPI is both present and not explicitly disabled by hints.acpi.0.disabled.

- **core.hasACPI**()

  Checks whether ACPI support is present. This requires the loader to probe the system and set acpi.rsdp early before starting the interpreter.

- **core.setACPI**(*acpi*)

  Sets or unsets acpi\_load, hint.acpi.0.disabled, and loader.acpi\_disabled\_by\_user. If *acpi* is omitted, toggle the current ACPI setting.

- **core.setSafeMode**(*safeMode*)

  Set the safe mode setting. Sets or unsets kern.smp.disabled, hw.ata.ata\_dma, hw.ata.atapi\_dma, kern.eventtimer.periodic, and kern.geom.part.check\_integrity. If *safeMode* is omitted, toggle the current safe mode setting.

- **core.clearCachedKernels**()

  Clears out the cache of kernels to be displayed on the boot menu. This function is registered as a config.reloaded hook. It is used to invalidate the kernel list whenever it may have changed, either due to a boot environment change or a potential change in either **kernel** or **kernels**.

- **core.hasFeature**(*featureName*)

  Checks whether the named *featureName* is enabled in the current loader. This is specifically used for detecting capabilities of the loaded loader binary, so that one can reasonably implement backwards compatibility shims if needed.

- **core.kernelList**()

  Returns a table of kernels to display on the boot menu. This will combine **kernel** and **kernels** from [loader.conf(5)](/loader.conf/5.md). If **kernels\_autodetect** is set in [loader.conf(5)](/loader.conf/5.md), kernels will be autodetected from the current system.

- **core.bootenvDefault**()

  Returns the default boot environment, nil if unset.

- **core.bootenvFilter**(*func*)

  Installs a filter *func* into **core.bootenvList**(). If the *func* returns true, then the boot environment is retained in the list. Otherwise, the boot environment is hidden. The old filter, if any, is returned to allow the caller to compose a filter on top of another filter.

- **core.bootenvIter**()

  Returns an iterator over the known boot environment list. The returned boot environment names do not include the boot environmnt root, which would need to be added back on from the zfs\_be\_root environment variable.

- **core.bootenvList**()

  Returns a table of boot environments, or an empty table. These will be picked up using the bootenvs and bootenvs\_count variables set by [loader(8)](/loader/8.md).

- **core.setDefaults**()

  Resets ACPI, safe mode, single user, and verbose settings to their system defauilts.

- **core.autoboot**(*argstr*)

  Loads the kernel and specified modules, then invokes the **autoboot** [loader(8)](/loader/8.md) command with *argstr* as-is.

- **core.boot**(*argstr*)

  Loads the kernel and specified modules, then invokes the **boot** [loader(8)](/loader/8.md) command with *argstr* as-is.

- **core.isSingleUserBoot**()

  Returns true if boot\_single is set to yes.

- **core.isZFSBoot**()

  Returns true if currdev is set to a [zfs(8)](/zfs/8.md) dataset.

- **core.isSerialBoot**()

  Returns true if we are booting over serial. This checks console, boot\_serial, and boot\_multicons.

- **core.deepCopyTable**(*tbl*)

  Recursively deep copies *tbl* and returns the result.

- **core.popFrontTable**(*tbl*)

  Pops the front element off of *tbl*, and returns two return values: the front element, and the rest of the table. If there are no elements, this returns nil and nil. If there is one element, this returns the front element and an empty table. This will not operate on truly associative tables; numeric indices are required.

- **core.switchBE**(*beName*)

  Switch to the requested *beName*. It may be either be formatted as a fully-qualified loader dataset path “zfs:pool/ROOT/beName”, or like one of “pool/ROOT/beName” or “beName”.

- **core.loaderTooOld**()

  Returns true if the loader is too old. Specifically, this means, is the loader old enough to require one or more workarounds in the current lua base modules.

## SEE ALSO

[loader.conf(5)](/loader.conf/5.md), [loader(8)](/loader/8.md), [menu.lua(8)](/menu.lua/8.md)

## AUTHORS

The **core.lua** file was originally written by Pedro Souza ⟨*pedrosouza@FreeBSD.org*⟩. Later work and this manual page was done by Kyle Evans ⟨*kevans@FreeBSD.org*⟩.
