diff options
| author | Toomas Soome <tsoome@FreeBSD.org> | 2020-09-21 09:01:10 +0000 |
|---|---|---|
| committer | Toomas Soome <tsoome@FreeBSD.org> | 2020-09-21 09:01:10 +0000 |
| commit | e307eb94ae520d98dc1d346a0c53667a41beab5d (patch) | |
| tree | 388cef449cfe2f57e0f2c494db23b11a1390072f /libexec | |
| parent | 7d54cc9165a3990849b60835c85ddb388905e1b7 (diff) | |
loader: zfs should support bootonce an nextboot
bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.
By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.
By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.
bootonce dataset name is recorded in boot pool labels, bootenv area.
in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.
bootonce and nextboot features are usable in both UEFI and BIOS boot.
To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).
At this time, only lua loader is updated.
Sponsored by: Netflix, Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25512
Notes
svn path=/head/; revision=365938
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/rc/rc.conf | 1 | ||||
| -rwxr-xr-x | libexec/rc/rc.d/zfsbe | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 1d01b551dc6a..4d9406cf73c5 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -64,6 +64,7 @@ rc_conf_files="/etc/rc.conf /etc/rc.conf.local" # ZFS support zfs_enable="NO" # Set to YES to automatically mount ZFS file systems +zfs_bootonce_activate="NO" # Set YES to make successful bootonce BE permanent # ZFSD support zfsd_enable="NO" # Set to YES to automatically start the ZFS fault diff --git a/libexec/rc/rc.d/zfsbe b/libexec/rc/rc.d/zfsbe index 3c852017aa41..e0a30c5a16b4 100755 --- a/libexec/rc/rc.d/zfsbe +++ b/libexec/rc/rc.d/zfsbe @@ -48,6 +48,21 @@ mount_subordinate() done } +activate_bootonce() +{ + local _dev + local _bootonce + local _be + + _dev=$1 + _be=${_dev##*/} + + _bootonce="`kenv -q zfs-bootonce`" + if [ "$_bootonce" = "zfs:${_dev}:" ] ; then + bectl activate $_be + fi +} + be_start() { if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then @@ -57,6 +72,9 @@ be_start() [ $_mp = "/" ] || continue if [ $_type = "zfs" ] ; then mount_subordinate $_dev + if checkyesno zfs_bootonce_activate; then + activate_bootonce $_dev + fi fi break done |
