xref: /freebsd/sbin/bectl/bectl.8 (revision e307eb94ae520d98dc1d346a0c53667a41beab5d)
15952343eSKyle Evans.\"
2b179da01SKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3b179da01SKyle Evans.\"
4b179da01SKyle Evans.\" Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
55952343eSKyle Evans.\"
65952343eSKyle Evans.\" Redistribution and use in source and binary forms, with or without
75952343eSKyle Evans.\" modification, are permitted provided that the following conditions
85952343eSKyle Evans.\" are met:
95952343eSKyle Evans.\" 1. Redistributions of source code must retain the above copyright
105952343eSKyle Evans.\"    notice, this list of conditions and the following disclaimer.
115952343eSKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright
125952343eSKyle Evans.\"    notice, this list of conditions and the following disclaimer in the
135952343eSKyle Evans.\"    documentation and/or other materials provided with the distribution.
145952343eSKyle Evans.\"
155952343eSKyle Evans.\"
165952343eSKyle Evans.\"     @(#)be.1
17b6e7c421SKyle Evans.\"
185952343eSKyle Evans.\" $FreeBSD$
195952343eSKyle Evans.\"
20*e307eb94SToomas Soome.Dd August 25, 2020
21edbfe3bcSKyle Evans.Dt BECTL 8
2284e61219SKyle Evans.Os
235952343eSKyle Evans.Sh NAME
24edbfe3bcSKyle Evans.Nm bectl
2577688bffSMateusz Piotrowski.Nd Utility to manage boot environments on ZFS
265952343eSKyle Evans.Sh SYNOPSIS
275952343eSKyle Evans.Nm
28d81df689SKyle Evans.Cm activate
29*e307eb94SToomas Soome.Op Fl t | Fl T
30d81df689SKyle Evans.Ar beName
315952343eSKyle Evans.Nm
32490e13c1SKyle Evans.Cm check
33490e13c1SKyle Evans.Nm
34d81df689SKyle Evans.Cm create
355952343eSKyle Evans.Op Fl r
3677688bffSMateusz Piotrowski.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
3777688bffSMateusz Piotrowski.Ar newBeName
385952343eSKyle Evans.Nm
3955ece394SKyle Evans.Cm create
4055ece394SKyle Evans.Op Fl r
4155ece394SKyle Evans.Ar beName@snapshot
4255ece394SKyle Evans.Nm
43d81df689SKyle Evans.Cm destroy
4477b4126cSKyle Evans.Op Fl \&Fo
4577688bffSMateusz Piotrowski.Ar beName Ns Op Cm @ Ns Ar snapshot
465952343eSKyle Evans.Nm
47d81df689SKyle Evans.Cm export
48d81df689SKyle Evans.Ar sourceBe
4934761e84SKyle Evans.Nm
50d81df689SKyle Evans.Cm import
51d81df689SKyle Evans.Ar targetBe
5234761e84SKyle Evans.Nm
53d81df689SKyle Evans.Cm jail
5477688bffSMateusz Piotrowski.Op Fl bU
5577688bffSMateusz Piotrowski.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ...
5677688bffSMateusz Piotrowski.Ar beName
57cd816834SKyle Evans.Op Ar utility Op Ar argument ...
585952343eSKyle Evans.Nm
59d81df689SKyle Evans.Cm list
6077688bffSMateusz Piotrowski.Op Fl aDHs
61f0298be0SKyle Evans.Op Fl c Ar property
62f0298be0SKyle Evans.Op Fl C Ar property
63f0298be0SKyle Evans.Oo Bro Fl c Ar property | Fl C Ar property Brc Oc
645952343eSKyle Evans.Nm
65d81df689SKyle Evans.Cm mount
66d81df689SKyle Evans.Ar beName
6777688bffSMateusz Piotrowski.Op Ar mountpoint
685952343eSKyle Evans.Nm
69d81df689SKyle Evans.Cm rename
70d81df689SKyle Evans.Ar origBeName
71d81df689SKyle Evans.Ar newBeName
725952343eSKyle Evans.Nm
73d81df689SKyle Evans.Brq Cm ujail | unjail
7477688bffSMateusz Piotrowski.Brq Ar jailId | jailName
7577688bffSMateusz Piotrowski.Ar beName
765952343eSKyle Evans.Nm
77d81df689SKyle Evans.Brq Cm umount | unmount
785952343eSKyle Evans.Op Fl f
79d81df689SKyle Evans.Ar beName
8077688bffSMateusz Piotrowski.Pp
8177688bffSMateusz Piotrowski.Nm
8277688bffSMateusz Piotrowski.Op Fl h\&?
835952343eSKyle Evans.Sh DESCRIPTION
845952343eSKyle EvansThe
855952343eSKyle Evans.Nm
86d81df689SKyle Evanscommand is used to setup and interact with ZFS boot environments, which are
87d81df689SKyle Evansbootable clones of datasets.
885952343eSKyle Evans.Pp
8977688bffSMateusz PiotrowskiBoot environments
9077688bffSMateusz Piotrowskiallow the system to be upgraded, while preserving the old system environment in
91d81df689SKyle Evansa separate ZFS dataset.
9277688bffSMateusz Piotrowski.Pp
935952343eSKyle EvansThe following commands are supported by
945952343eSKyle Evans.Nm :
955952343eSKyle Evans.Bl -tag -width activate
96d81df689SKyle Evans.It Xo
97d81df689SKyle Evans.Cm activate
98*e307eb94SToomas Soome.Op Fl t | Fl T
99d81df689SKyle Evans.Ar beName
100d81df689SKyle Evans.Xc
1015952343eSKyle EvansActivate the given
1025952343eSKyle Evans.Ar beName
10384e61219SKyle Evansas the default boot filesystem.
10484e61219SKyle EvansIf the
10555b954c6SMateusz Piotrowski.Fl t
1065952343eSKyle Evansflag is given, this takes effect only for the next boot.
107*e307eb94SToomas SoomeFlag
108*e307eb94SToomas Soome.Fl T
109*e307eb94SToomas Soomeremoves temporary boot once configuration.
110*e307eb94SToomas SoomeWithout temporary configuration, the next boot will use zfs dataset specified
111*e307eb94SToomas Soomein boot pool
112*e307eb94SToomas Soome.Ar bootfs
113*e307eb94SToomas Soomeproperty.
114d81df689SKyle Evans.It Xo
115490e13c1SKyle Evans.Cm check
116490e13c1SKyle Evans.Xc
117490e13c1SKyle EvansPerforms a silent sanity check on the current system.
118490e13c1SKyle EvansIf boot environments are supported and used,
119490e13c1SKyle Evans.Nm
120490e13c1SKyle Evanswill exit with a status code of 0.
121490e13c1SKyle EvansAny other status code is not currently defined and may, in the future, grow
122490e13c1SKyle Evansspecial meaning for different degrees of sanity check failures.
123490e13c1SKyle Evans.It Xo
124d81df689SKyle Evans.Cm create
1255952343eSKyle Evans.Op Fl r
12677688bffSMateusz Piotrowski.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
12777688bffSMateusz Piotrowski.Ar newBeName
128d81df689SKyle Evans.Xc
12977688bffSMateusz PiotrowskiCreate a new boot environment named
13077688bffSMateusz Piotrowski.Ar newBeName .
13177688bffSMateusz Piotrowski.Pp
13277688bffSMateusz PiotrowskiIf the
13377688bffSMateusz Piotrowski.Fl r
13477688bffSMateusz Piotrowskiflag is given, a recursive boot environment will be made.
13577688bffSMateusz Piotrowski.Pp
1365952343eSKyle EvansIf the
137d81df689SKyle Evans.Fl e
13877688bffSMateusz Piotrowskiflag is specified, the new environment will be cloned from the given
13977688bffSMateusz Piotrowski.Ar nonActiveBe
14077688bffSMateusz Piotrowskior
14177688bffSMateusz Piotrowski.Ar beName Ns Cm @ Ns Ar snapshot .
14277688bffSMateusz PiotrowskiOtherwise, the new environment will be created from the currently booted environment.
14377688bffSMateusz Piotrowski.Pp
14477688bffSMateusz PiotrowskiIf
14577688bffSMateusz Piotrowski.Nm
14677688bffSMateusz Piotrowskiis creating from another boot environment, a snapshot of that boot environment will be created to clone from.
147d81df689SKyle Evans.It Xo
14855ece394SKyle Evans.Cm create
14955ece394SKyle Evans.Op Fl r
15055ece394SKyle Evans.Ar beName@snapshot
15155ece394SKyle Evans.Xc
15255ece394SKyle EvansCreate a snapshot of the boot environment named
15355ece394SKyle Evans.Ar beName .
15455ece394SKyle Evans.Pp
15555ece394SKyle EvansIf the
15655ece394SKyle Evans.Fl r
15755ece394SKyle Evansflag is given, a recursive snapshot of the boot environment will be created.
15855ece394SKyle EvansA snapshot is created for each descendant dataset of the boot environment.
15955ece394SKyle Evans.Pp
16055ece394SKyle EvansNo new boot environment is created with this command.
16155ece394SKyle Evans.It Xo
162d81df689SKyle Evans.Cm destroy
16377b4126cSKyle Evans.Op Fl \&Fo
16477688bffSMateusz Piotrowski.Ar beName Ns Op Cm @ Ns Ar snapshot
165d81df689SKyle Evans.Xc
16677688bffSMateusz PiotrowskiDestroy the given
1675952343eSKyle Evans.Ar beName
1685952343eSKyle Evansboot environment or
16977688bffSMateusz Piotrowski.Ar beName Ns Cm @ Ns Ar snapshot
1708369ba42SKyle Evanssnapshot without confirmation, unlike in
17177688bffSMateusz Piotrowski.Xr beadm 1 .
1725952343eSKyle EvansSpecifying
1735952343eSKyle Evans.Fl F
1745952343eSKyle Evanswill automatically unmount without confirmation.
17577b4126cSKyle Evans.Pp
17677b4126cSKyle EvansBy default,
17777b4126cSKyle Evans.Nm
17877b4126cSKyle Evanswill warn that it is not destroying the origin of
17977b4126cSKyle Evans.Ar beName .
18077b4126cSKyle EvansThe
18177b4126cSKyle Evans.Fl o
18277b4126cSKyle Evansflag may be specified to destroy the origin as well.
183d81df689SKyle Evans.It Cm export Ar sourceBe
18434761e84SKyle EvansExport
18534761e84SKyle Evans.Ar sourceBe
18634761e84SKyle Evansto
18777688bffSMateusz Piotrowski.Xr stdout 4 .
18877688bffSMateusz Piotrowski.Xr stdout 4
18934761e84SKyle Evansmust be piped or redirected to a file.
190d81df689SKyle Evans.It Cm import Ar targetBe
19134761e84SKyle EvansImport
19234761e84SKyle Evans.Ar targetBe
19334761e84SKyle Evansfrom
19477688bffSMateusz Piotrowski.Xr stdin 4 .
195d81df689SKyle Evans.It Xo
196d81df689SKyle Evans.Cm jail
19777688bffSMateusz Piotrowski.Op Fl bU
19877688bffSMateusz Piotrowski.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ...
19977688bffSMateusz Piotrowski.Ar beName
200cd816834SKyle Evans.Op Ar utility Op Ar argument ...
201d81df689SKyle Evans.Xc
20277688bffSMateusz PiotrowskiCreate a jail of the given boot environment.
203d694059fSKyle EvansMultiple
204d694059fSKyle Evans.Fl o
2052a0b8dc2SKyle Evansand
2062a0b8dc2SKyle Evans.Fl u
207d694059fSKyle Evansarguments may be specified.
2082a0b8dc2SKyle Evans.Fl o
2092a0b8dc2SKyle Evanswill set a jail parameter, and
2102a0b8dc2SKyle Evans.Fl u
2112a0b8dc2SKyle Evanswill unset a jail parameter.
212cd816834SKyle Evans.Pp
213cd816834SKyle EvansBy default, jails are created in interactive mode and
214cd816834SKyle Evans.Pa /bin/sh
215cd816834SKyle Evansis
216b509cad4SKyle Evansexecuted within the jail.
217cd816834SKyle EvansIf
218cd816834SKyle Evans.Ar utility
219cd816834SKyle Evansis specified, it will be executed instead of
220cd816834SKyle Evans.Pa /bin/sh .
221db9db0e7SKyle EvansThe jail will be destroyed and the boot environment unmounted when the command
222db9db0e7SKyle Evansfinishes executing, unless the
223db9db0e7SKyle Evans.Fl U
224db9db0e7SKyle Evansargument is specified.
225cd816834SKyle Evans.Pp
226b509cad4SKyle EvansThe
227b509cad4SKyle Evans.Fl b
228b509cad4SKyle Evansargument enables batch mode, thereby disabling interactive mode.
229db9db0e7SKyle EvansThe
230db9db0e7SKyle Evans.Fl U
231db9db0e7SKyle Evansargument will be ignored in batch mode.
2322a0b8dc2SKyle Evans.Pp
2332a0b8dc2SKyle EvansThe
2342a0b8dc2SKyle Evans.Va name ,
2352a0b8dc2SKyle Evans.Va host.hostname ,
2362a0b8dc2SKyle Evansand
2372a0b8dc2SKyle Evans.Va path
2387ce09314SKyle Evansmust be set, the default values are specified below.
2392a0b8dc2SKyle Evans.Pp
2402a0b8dc2SKyle EvansAll
24177688bffSMateusz Piotrowski.Ar key Ns Cm = Ns Ar value
242d694059fSKyle Evanspairs are interpreted as jail parameters as described in
243d694059fSKyle Evans.Xr jail 8 .
244d694059fSKyle EvansThe following default parameters are provided:
245d81df689SKyle Evans.Bl -column "allow.mount.devfs" ""
246d81df689SKyle Evans.It Va allow.mount Ta Cm true
247d81df689SKyle Evans.It Va allow.mount.devfs Ta Cm true
248d81df689SKyle Evans.It Va enforce_statfs Ta Cm 1
24977688bffSMateusz Piotrowski.It Va name Ta Set to jail ID.
250d81df689SKyle Evans.It Va host.hostname Ta Va bootenv
25177688bffSMateusz Piotrowski.It Va path Ta Set to a path in Pa /tmp
25277688bffSMateusz Piotrowskigenerated by
25384e61219SKyle Evans.Xr libbe 3 .
254d694059fSKyle Evans.El
2555952343eSKyle Evans.Pp
2562a0b8dc2SKyle EvansAll default parameters may be overwritten.
257f0298be0SKyle Evans.It Xo
258f0298be0SKyle Evans.Cm list
259f0298be0SKyle Evans.Op Fl DHas
260f0298be0SKyle Evans.Oo Bro Fl c Ar property | Fl C Ar property Brc Oc
261f0298be0SKyle Evans.Xc
262f0298be0SKyle Evans.Pp
26377688bffSMateusz PiotrowskiDisplay all boot environments.
26477688bffSMateusz PiotrowskiThe
26577688bffSMateusz Piotrowski.Em Active
26677688bffSMateusz Piotrowskifield indicates whether the boot environment is active now
26777688bffSMateusz Piotrowski.Pq Em \&N ;
26877688bffSMateusz Piotrowskiactive on reboot
26977688bffSMateusz Piotrowski.Pq Em \&R ;
270*e307eb94SToomas Soomeis used on next boot once
271*e307eb94SToomas Soome.Pq Em \&T ;
272*e307eb94SToomas Soomeor combination of
273*e307eb94SToomas Soome.Pq Em \&NRT .
2745952343eSKyle Evans.Pp
275f0298be0SKyle Evans.Bl -tag -width indent
276f0298be0SKyle Evans.It Fl a
277f0298be0SKyle EvansDisplay all datasets.
278f0298be0SKyle Evans.It Fl D
279f0298be0SKyle EvansDisplay the full space usage for each boot environment, assuming all
280d81df689SKyle Evansother boot environments were destroyed.
281f0298be0SKyle Evans.It Fl H
282f0298be0SKyle EvansUsed for scripting.
283f0298be0SKyle EvansDo not print headers and separate fields by a single tab instead of
284d81df689SKyle Evansarbitrary white space.
285f0298be0SKyle Evans.It Fl s
286f0298be0SKyle EvansDisplay all snapshots as well.
287f0298be0SKyle Evans.It Fl c Ar property
288f0298be0SKyle EvansSort boot environments by given property name.
289f0298be0SKyle EvansThe following properties are supported:
290f0298be0SKyle Evans.Pp
291f0298be0SKyle Evans.Bl -tag -width 4n -offset indent -compact
292f0298be0SKyle Evans.It name (default output)
293f0298be0SKyle Evans.It creation
294f0298be0SKyle Evans.It origin
295f0298be0SKyle Evans.It used
296f0298be0SKyle Evans.It usedds
297f0298be0SKyle Evans.It usedsnap
298f0298be0SKyle Evans.It usedrefreserv
299f0298be0SKyle Evans.El
300f0298be0SKyle Evans.It Fl C Ar property
301f0298be0SKyle EvansSame as the
302f0298be0SKyle Evans.Fl c
303f0298be0SKyle Evansoption, but displays in descending order.
304f0298be0SKyle Evans.El
305f0298be0SKyle Evans.Pp
306f0298be0SKyle EvansThe
307f0298be0SKyle Evans.Fl D
308f0298be0SKyle Evansoption is ignored when either the
3095952343eSKyle Evans.Fl s
310f0298be0SKyle Evansor
311f0298be0SKyle Evans.Fl a
312f0298be0SKyle Evansoption is used.
313d81df689SKyle Evans.It Cm mount Ar beName Op Ar mountpoint
3145952343eSKyle EvansTemporarily mount the boot environment.
3155952343eSKyle EvansMount at the specified
3165952343eSKyle Evans.Ar mountpoint
3175952343eSKyle Evansif provided.
318d81df689SKyle Evans.It Cm rename Ar origBeName newBeName
31977688bffSMateusz PiotrowskiRename the given
3205952343eSKyle Evans.Ar origBeName
3215952343eSKyle Evansto the given
322d81df689SKyle Evans.Ar newBeName .
3238369ba42SKyle EvansThe boot environment will not be unmounted in order for this rename to occur.
32477688bffSMateusz Piotrowski.It Cm ujail Bro Ar jailId | jailName Brc Ar beName
32577688bffSMateusz Piotrowski.It Cm unjail Bro Ar jailId | jailName Brc Ar beName
32677688bffSMateusz PiotrowskiDestroy the jail created from the given boot environment.
32777688bffSMateusz Piotrowski.It Xo
32877688bffSMateusz Piotrowski.Cm umount
32977688bffSMateusz Piotrowski.Op Fl f
33077688bffSMateusz Piotrowski.Ar beName
33177688bffSMateusz Piotrowski.Xc
332d81df689SKyle Evans.It Xo
333d81df689SKyle Evans.Cm unmount
3345952343eSKyle Evans.Op Fl f
335d81df689SKyle Evans.Ar beName
336d81df689SKyle Evans.Xc
3375952343eSKyle EvansUnmount the given boot environment, if it is mounted.
3385952343eSKyle EvansSpecifying
3395952343eSKyle Evans.Fl f
3405952343eSKyle Evanswill force the unmount if busy.
3415952343eSKyle Evans.El
34277688bffSMateusz Piotrowski.Pp
34377688bffSMateusz Piotrowski.Nm
34477688bffSMateusz Piotrowskiprints usage information if
34577688bffSMateusz Piotrowski.Fl h
34677688bffSMateusz Piotrowskior
34777688bffSMateusz Piotrowski.Fl \&?
34877688bffSMateusz Piotrowskiis specified.
349d6105756SMateusz Piotrowski\" .Sh EXAMPLES
350d6105756SMateusz Piotrowski\" .Bl -bullet
351d6105756SMateusz Piotrowski\" .It
352d6105756SMateusz Piotrowski\" To fill in with jail upgrade example when behavior is firm.
353d6105756SMateusz Piotrowski\" .El
3545952343eSKyle Evans.Sh SEE ALSO
355f5c8cb4cSMateusz Piotrowski.Xr libbe 3 ,
356cb67aaf2SAlan Somers.Xr beinstall.sh 8 ,
3575952343eSKyle Evans.Xr jail 8 ,
3585952343eSKyle Evans.Xr zfs 8 ,
3595952343eSKyle Evans.Xr zpool 8
3605952343eSKyle Evans.Sh HISTORY
3615952343eSKyle Evans.Nm
3625952343eSKyle Evansis based on
36377688bffSMateusz Piotrowski.Xr beadm 1
3645952343eSKyle Evansand was implemented as a project for the 2017 Summer of Code, along with
3655952343eSKyle Evans.Xr libbe 3 .
3665952343eSKyle Evans.Sh AUTHORS
367d81df689SKyle Evans.Nm
368d81df689SKyle Evanswas written by
369d81df689SKyle Evans.An Kyle Kneitinger (kneitinger) Aq Mt kyle@kneit.in .
3705952343eSKyle Evans.Pp
37177688bffSMateusz Piotrowski.Xr beadm 1
372d81df689SKyle Evanswas written and is maintained by
373d81df689SKyle Evans.An Slawomir Wojciech Wojtczak (vermaden) Aq Mt vermaden@interia.pl .
3745952343eSKyle Evans.Pp
37534761e84SKyle Evans.An Bryan Drewery (bdrewery) Aq Mt bryan@shatow.net
376d81df689SKyle Evanswrote the original
37777688bffSMateusz Piotrowski.Xr beadm 1
3785952343eSKyle Evansmanual page that this one is derived from.
379