aboutsummaryrefslogtreecommitdiff
path: root/sbin/bectl/bectl.c
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2020-09-21 09:01:10 +0000
committerToomas Soome <tsoome@FreeBSD.org>2020-09-21 09:01:10 +0000
commite307eb94ae520d98dc1d346a0c53667a41beab5d (patch)
tree388cef449cfe2f57e0f2c494db23b11a1390072f /sbin/bectl/bectl.c
parent7d54cc9165a3990849b60835c85ddb388905e1b7 (diff)
downloadsrc-e307eb94ae520d98dc1d346a0c53667a41beab5d.tar.gz
src-e307eb94ae520d98dc1d346a0c53667a41beab5d.zip
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
Notes: svn path=/head/; revision=365938
Diffstat (limited to 'sbin/bectl/bectl.c')
-rw-r--r--sbin/bectl/bectl.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c
index 31ece42c6ff2..8a319a0d67f6 100644
--- a/sbin/bectl/bectl.c
+++ b/sbin/bectl/bectl.c
@@ -74,6 +74,7 @@ usage(bool explicit)
"\tbectl add (path)*\n"
#endif
"\tbectl activate [-t] beName\n"
+ "\tbectl activate [-T]\n"
"\tbectl check\n"
"\tbectl create [-r] [-e {nonActiveBe | beName@snapshot}] beName\n"
"\tbectl create [-r] beName@snapshot\n"
@@ -141,14 +142,22 @@ static int
bectl_cmd_activate(int argc, char *argv[])
{
int err, opt;
- bool temp;
+ bool temp, reset;
temp = false;
- while ((opt = getopt(argc, argv, "t")) != -1) {
+ reset = false;
+ while ((opt = getopt(argc, argv, "tT")) != -1) {
switch (opt) {
case 't':
+ if (reset)
+ return (usage(false));
temp = true;
break;
+ case 'T':
+ if (temp)
+ return (usage(false));
+ reset = true;
+ break;
default:
fprintf(stderr, "bectl activate: unknown option '-%c'\n",
optopt);
@@ -159,11 +168,18 @@ bectl_cmd_activate(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (argc != 1) {
+ if (argc != 1 && (!reset || argc != 0)) {
fprintf(stderr, "bectl activate: wrong number of arguments\n");
return (usage(false));
}
+ if (reset) {
+ if ((err = be_deactivate(be, NULL, reset)) == 0)
+ printf("Temporary activation removed\n");
+ else
+ printf("Failed to remove temporary activation\n");
+ return (err);
+ }
/* activate logic goes here */
if ((err = be_activate(be, argv[0], temp)) != 0)