GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
* Sign Up! *

Support
Customer Portal
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Heritage
Credits
 

USA Flag

 

 

Man Pages
PKG-BE-PLUGIN(8) FreeBSD System Manager's Manual PKG-BE-PLUGIN(8)

pkg-be-plugin — automatically create ZFS boot environments before pkg transactions

The plugin is loaded by pkg(8) when it is explicitly listed in the PLUGINS option of pkg.conf(5):

PLUGINS ["be" ];

No explicit invocation is needed beyond that.

pkg-be-plugin is a pkg(8) plugin that creates a ZFS boot environment immediately before each package install, upgrade, or deinstall transaction. If the transaction leaves the system in a broken state, the user can reboot into the pre-transaction environment to recover.

The plugin calls libbe(3) directly. It does not invoke bectl(8) or zfs(8) as external processes.

Boot environment names have the form:

⟨prefix⟩-⟨YYYYMMDD⟩T⟨HHMMSS⟩

where ⟨prefix⟩ is controlled by the configuration key and the timestamp is the local time at which the transaction began, in ISO 8601 basic format. For example, with the default prefix:

pre-pkg-20260513T142301

After creating the new boot environment, the plugin prunes older automatically created boot environments so that at most remain. Boot environments younger than are never pruned regardless of count.

All operations are logged to syslog(3) under the facility, matching pkg(8):

LOG_NOTICE
Successful creation and each successful pruning.
LOG_WARNING
Creation failures in non-strict mode (transaction proceeds), and all pruning failures (pruning is always best-effort regardless of strict mode).
LOG_ERR
Creation failures in strict mode (transaction aborted).

Logging honours the global option of pkg.conf(5): when it is disabled, the plugin writes no syslog(3) messages, matching the behaviour of pkg(8) itself.

The plugin is configured by /usr/local/etc/pkg/be.conf, a UCL file. A missing file is not an error; compiled-in defaults are used.

To load the plugin, list it in the PLUGINS option of pkg.conf(5) as shown in the SYNOPSIS; plugin loading must not be disabled via .

The following options can be defined in be.conf:

Master switch. Set to “false” to load the plugin but register no hooks. Default: true.
Maximum number of automatically created boot environments to retain. Must be >= 1. Older environments beyond this limit are destroyed after each successful creation, subject to BE_PLUGIN_MIN_AGE. The origin snapshot created when the boot environment was cloned is reclaimed along with it, so pruning does not leak snapshots. Default: 5.
Prefix for generated boot environment names. Must not be empty and must not exceed 63 characters; a longer value is rejected at load time and the plugin fails to load. Default: “pre-pkg”.
Minimum age a boot environment must reach before it is eligible for pruning. Accepted formats: a bare integer (seconds), or an integer followed by “d” (days), “h” (hours), “m” (minutes), or “s” (seconds). Set to “0” to disable the minimum-age restriction. Default: “7d”.
In strict mode, a failure to create a boot environment causes the plugin to return EPKG_FATAL, aborting the transaction before any packages are changed. In non-strict mode, creation failures are logged and the transaction proceeds. Default: false.
Comma-separated list of transaction types to skip. Recognised tokens: “install”, “upgrade”, “deinstall”. Example: “deinstall” creates boot environments only for installs and upgrades. Unknown tokens produce a warning notice and are otherwise ignored. Default: empty.
Comma-separated list of repository names that trigger BE creation. If empty, every transaction creates a BE regardless of origin. If set, a BE is created only when at least one package in the transaction originates from a listed repository. Repository names must match exactly as shown in pkg -vv output (case-sensitive). The special token “local” matches packages installed directly from a file via pkg add (which carry no repository name). Example: to create BEs only for base system updates:

BE_PLUGIN_REPOSITORIES = "FreeBSD-base";

Default: empty.

/usr/local/lib/pkg/be.so
The plugin shared object.
/usr/local/etc/pkg/be.conf
Plugin configuration file (UCL format).

Minimal be.conf to retain ten boot environments for at least 14 days:

BE_PLUGIN_ENABLED = true;
BE_PLUGIN_KEEP = 10;
BE_PLUGIN_MIN_AGE = "14d";

To find the boot environment created before the last upgrade and boot into it:

grep "pkg-be-plugin: created" /var/log/messages | tail -1
bectl activate pre-pkg-20260513T142301
reboot

The syslog(3) entry written on creation always includes the exact boot environment name, providing a reliable audit trail for rollback.

Sasha Karcz

The plugin requires the system to be running from a ZFS boot environment. On UFS-rooted systems or inside jails without ZFS access, libbe_init() fails. This is detected once, when the plugin is loaded: the plugin emits a single informational message and registers no hooks, so it stays inert and does not affect package transactions. This check is independent of BE_PLUGIN_STRICT; strict mode never aborts transactions merely because the system lacks ZFS boot environment support.

The plugin opens and closes a libbe(3) handle for both the creation step and the pruning step. Two libbe_init() calls are made per transaction; this is intentional to keep error handling simple and is not a performance concern for typical workloads.

Pruning is best-effort. If be_destroy() fails (for example because a boot environment is currently mounted or is the active environment), the failure is logged and the remaining candidates are still considered for pruning. The transaction is never aborted due to a pruning failure regardless of the BE_PLUGIN_STRICT setting.

September 27, 2026 FreeBSD 15.1-RELEASE-p7

Search for    or go to Top of page |  Section 8 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.