xref: /freebsd/sbin/bectl/bectl.8 (revision b1ea63e2e3c92d1346af067f5cf609e3e062f8b9)
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*b1ea63e2SRobert Wing.Dd January 6, 2021
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
29e307eb94SToomas 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
74*b1ea63e2SRobert Wing.Brq Ar jailId | jailName | beName
755952343eSKyle Evans.Nm
76d81df689SKyle Evans.Brq Cm umount | unmount
775952343eSKyle Evans.Op Fl f
78d81df689SKyle Evans.Ar beName
7977688bffSMateusz Piotrowski.Pp
8077688bffSMateusz Piotrowski.Nm
8177688bffSMateusz Piotrowski.Op Fl h\&?
825952343eSKyle Evans.Sh DESCRIPTION
835952343eSKyle EvansThe
845952343eSKyle Evans.Nm
85d81df689SKyle Evanscommand is used to setup and interact with ZFS boot environments, which are
86d81df689SKyle Evansbootable clones of datasets.
875952343eSKyle Evans.Pp
8877688bffSMateusz PiotrowskiBoot environments
8977688bffSMateusz Piotrowskiallow the system to be upgraded, while preserving the old system environment in
90d81df689SKyle Evansa separate ZFS dataset.
9177688bffSMateusz Piotrowski.Pp
925952343eSKyle EvansThe following commands are supported by
935952343eSKyle Evans.Nm :
945952343eSKyle Evans.Bl -tag -width activate
95d81df689SKyle Evans.It Xo
96d81df689SKyle Evans.Cm activate
97e307eb94SToomas Soome.Op Fl t | Fl T
98d81df689SKyle Evans.Ar beName
99d81df689SKyle Evans.Xc
1005952343eSKyle EvansActivate the given
1015952343eSKyle Evans.Ar beName
10284e61219SKyle Evansas the default boot filesystem.
10384e61219SKyle EvansIf the
10455b954c6SMateusz Piotrowski.Fl t
1055952343eSKyle Evansflag is given, this takes effect only for the next boot.
106e307eb94SToomas SoomeFlag
107e307eb94SToomas Soome.Fl T
108e307eb94SToomas Soomeremoves temporary boot once configuration.
109e307eb94SToomas SoomeWithout temporary configuration, the next boot will use zfs dataset specified
110e307eb94SToomas Soomein boot pool
111e307eb94SToomas Soome.Ar bootfs
112e307eb94SToomas Soomeproperty.
113d81df689SKyle Evans.It Xo
114490e13c1SKyle Evans.Cm check
115490e13c1SKyle Evans.Xc
116490e13c1SKyle EvansPerforms a silent sanity check on the current system.
117490e13c1SKyle EvansIf boot environments are supported and used,
118490e13c1SKyle Evans.Nm
119490e13c1SKyle Evanswill exit with a status code of 0.
120490e13c1SKyle EvansAny other status code is not currently defined and may, in the future, grow
121490e13c1SKyle Evansspecial meaning for different degrees of sanity check failures.
122490e13c1SKyle Evans.It Xo
123d81df689SKyle Evans.Cm create
1245952343eSKyle Evans.Op Fl r
12577688bffSMateusz Piotrowski.Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
12677688bffSMateusz Piotrowski.Ar newBeName
127d81df689SKyle Evans.Xc
12877688bffSMateusz PiotrowskiCreate a new boot environment named
12977688bffSMateusz Piotrowski.Ar newBeName .
13077688bffSMateusz Piotrowski.Pp
13177688bffSMateusz PiotrowskiIf the
13277688bffSMateusz Piotrowski.Fl r
13377688bffSMateusz Piotrowskiflag is given, a recursive boot environment will be made.
13477688bffSMateusz Piotrowski.Pp
1355952343eSKyle EvansIf the
136d81df689SKyle Evans.Fl e
13777688bffSMateusz Piotrowskiflag is specified, the new environment will be cloned from the given
13877688bffSMateusz Piotrowski.Ar nonActiveBe
13977688bffSMateusz Piotrowskior
14077688bffSMateusz Piotrowski.Ar beName Ns Cm @ Ns Ar snapshot .
14177688bffSMateusz PiotrowskiOtherwise, the new environment will be created from the currently booted environment.
14277688bffSMateusz Piotrowski.Pp
14377688bffSMateusz PiotrowskiIf
14477688bffSMateusz Piotrowski.Nm
14577688bffSMateusz Piotrowskiis creating from another boot environment, a snapshot of that boot environment will be created to clone from.
146d81df689SKyle Evans.It Xo
14755ece394SKyle Evans.Cm create
14855ece394SKyle Evans.Op Fl r
14955ece394SKyle Evans.Ar beName@snapshot
15055ece394SKyle Evans.Xc
15155ece394SKyle EvansCreate a snapshot of the boot environment named
15255ece394SKyle Evans.Ar beName .
15355ece394SKyle Evans.Pp
15455ece394SKyle EvansIf the
15555ece394SKyle Evans.Fl r
15655ece394SKyle Evansflag is given, a recursive snapshot of the boot environment will be created.
15755ece394SKyle EvansA snapshot is created for each descendant dataset of the boot environment.
15855ece394SKyle Evans.Pp
15955ece394SKyle EvansNo new boot environment is created with this command.
16055ece394SKyle Evans.It Xo
161d81df689SKyle Evans.Cm destroy
16277b4126cSKyle Evans.Op Fl \&Fo
16377688bffSMateusz Piotrowski.Ar beName Ns Op Cm @ Ns Ar snapshot
164d81df689SKyle Evans.Xc
16577688bffSMateusz PiotrowskiDestroy the given
1665952343eSKyle Evans.Ar beName
1675952343eSKyle Evansboot environment or
16877688bffSMateusz Piotrowski.Ar beName Ns Cm @ Ns Ar snapshot
1698369ba42SKyle Evanssnapshot without confirmation, unlike in
17077688bffSMateusz Piotrowski.Xr beadm 1 .
1715952343eSKyle EvansSpecifying
1725952343eSKyle Evans.Fl F
1735952343eSKyle Evanswill automatically unmount without confirmation.
17477b4126cSKyle Evans.Pp
17577b4126cSKyle EvansBy default,
17677b4126cSKyle Evans.Nm
17777b4126cSKyle Evanswill warn that it is not destroying the origin of
17877b4126cSKyle Evans.Ar beName .
17977b4126cSKyle EvansThe
18077b4126cSKyle Evans.Fl o
18177b4126cSKyle Evansflag may be specified to destroy the origin as well.
182d81df689SKyle Evans.It Cm export Ar sourceBe
18334761e84SKyle EvansExport
18434761e84SKyle Evans.Ar sourceBe
18534761e84SKyle Evansto
18677688bffSMateusz Piotrowski.Xr stdout 4 .
18777688bffSMateusz Piotrowski.Xr stdout 4
18834761e84SKyle Evansmust be piped or redirected to a file.
189d81df689SKyle Evans.It Cm import Ar targetBe
19034761e84SKyle EvansImport
19134761e84SKyle Evans.Ar targetBe
19234761e84SKyle Evansfrom
19377688bffSMateusz Piotrowski.Xr stdin 4 .
194d81df689SKyle Evans.It Xo
195d81df689SKyle Evans.Cm jail
19677688bffSMateusz Piotrowski.Op Fl bU
19777688bffSMateusz Piotrowski.Oo Bro Fl o Ar key Ns Cm = Ns Ar value | Fl u Ar key Brc Oc Ns ...
19877688bffSMateusz Piotrowski.Ar beName
199cd816834SKyle Evans.Op Ar utility Op Ar argument ...
200d81df689SKyle Evans.Xc
20177688bffSMateusz PiotrowskiCreate a jail of the given boot environment.
202d694059fSKyle EvansMultiple
203d694059fSKyle Evans.Fl o
2042a0b8dc2SKyle Evansand
2052a0b8dc2SKyle Evans.Fl u
206d694059fSKyle Evansarguments may be specified.
2072a0b8dc2SKyle Evans.Fl o
2082a0b8dc2SKyle Evanswill set a jail parameter, and
2092a0b8dc2SKyle Evans.Fl u
2102a0b8dc2SKyle Evanswill unset a jail parameter.
211cd816834SKyle Evans.Pp
212cd816834SKyle EvansBy default, jails are created in interactive mode and
213cd816834SKyle Evans.Pa /bin/sh
214cd816834SKyle Evansis
215b509cad4SKyle Evansexecuted within the jail.
216cd816834SKyle EvansIf
217cd816834SKyle Evans.Ar utility
218cd816834SKyle Evansis specified, it will be executed instead of
219cd816834SKyle Evans.Pa /bin/sh .
220db9db0e7SKyle EvansThe jail will be destroyed and the boot environment unmounted when the command
221db9db0e7SKyle Evansfinishes executing, unless the
222db9db0e7SKyle Evans.Fl U
223db9db0e7SKyle Evansargument is specified.
224cd816834SKyle Evans.Pp
225b509cad4SKyle EvansThe
226b509cad4SKyle Evans.Fl b
227b509cad4SKyle Evansargument enables batch mode, thereby disabling interactive mode.
228db9db0e7SKyle EvansThe
229db9db0e7SKyle Evans.Fl U
230db9db0e7SKyle Evansargument will be ignored in batch mode.
2312a0b8dc2SKyle Evans.Pp
2322a0b8dc2SKyle EvansThe
2332a0b8dc2SKyle Evans.Va name ,
2342a0b8dc2SKyle Evans.Va host.hostname ,
2352a0b8dc2SKyle Evansand
2362a0b8dc2SKyle Evans.Va path
2377ce09314SKyle Evansmust be set, the default values are specified below.
2382a0b8dc2SKyle Evans.Pp
2392a0b8dc2SKyle EvansAll
24077688bffSMateusz Piotrowski.Ar key Ns Cm = Ns Ar value
241d694059fSKyle Evanspairs are interpreted as jail parameters as described in
242d694059fSKyle Evans.Xr jail 8 .
243d694059fSKyle EvansThe following default parameters are provided:
244d81df689SKyle Evans.Bl -column "allow.mount.devfs" ""
245d81df689SKyle Evans.It Va allow.mount Ta Cm true
246d81df689SKyle Evans.It Va allow.mount.devfs Ta Cm true
247d81df689SKyle Evans.It Va enforce_statfs Ta Cm 1
24877688bffSMateusz Piotrowski.It Va name Ta Set to jail ID.
249d81df689SKyle Evans.It Va host.hostname Ta Va bootenv
25077688bffSMateusz Piotrowski.It Va path Ta Set to a path in Pa /tmp
25177688bffSMateusz Piotrowskigenerated by
25284e61219SKyle Evans.Xr libbe 3 .
253d694059fSKyle Evans.El
2545952343eSKyle Evans.Pp
2552a0b8dc2SKyle EvansAll default parameters may be overwritten.
256f0298be0SKyle Evans.It Xo
257f0298be0SKyle Evans.Cm list
258*b1ea63e2SRobert Wing.Op Fl aDHs
259f0298be0SKyle Evans.Oo Bro Fl c Ar property | Fl C Ar property Brc Oc
260f0298be0SKyle Evans.Xc
261f0298be0SKyle Evans.Pp
26277688bffSMateusz PiotrowskiDisplay all boot environments.
26377688bffSMateusz PiotrowskiThe
26477688bffSMateusz Piotrowski.Em Active
26577688bffSMateusz Piotrowskifield indicates whether the boot environment is active now
26677688bffSMateusz Piotrowski.Pq Em \&N ;
26777688bffSMateusz Piotrowskiactive on reboot
26877688bffSMateusz Piotrowski.Pq Em \&R ;
269e307eb94SToomas Soomeis used on next boot once
270e307eb94SToomas Soome.Pq Em \&T ;
271e307eb94SToomas Soomeor combination of
272e307eb94SToomas Soome.Pq Em \&NRT .
2735952343eSKyle Evans.Pp
274f0298be0SKyle Evans.Bl -tag -width indent
275f0298be0SKyle Evans.It Fl a
276f0298be0SKyle EvansDisplay all datasets.
277f0298be0SKyle Evans.It Fl D
278f0298be0SKyle EvansDisplay the full space usage for each boot environment, assuming all
279d81df689SKyle Evansother boot environments were destroyed.
280f0298be0SKyle Evans.It Fl H
281f0298be0SKyle EvansUsed for scripting.
282f0298be0SKyle EvansDo not print headers and separate fields by a single tab instead of
283d81df689SKyle Evansarbitrary white space.
284f0298be0SKyle Evans.It Fl s
285f0298be0SKyle EvansDisplay all snapshots as well.
286f0298be0SKyle Evans.It Fl c Ar property
287f0298be0SKyle EvansSort boot environments by given property name.
288f0298be0SKyle EvansThe following properties are supported:
289f0298be0SKyle Evans.Pp
290f0298be0SKyle Evans.Bl -tag -width 4n -offset indent -compact
291f0298be0SKyle Evans.It name (default output)
292f0298be0SKyle Evans.It creation
293f0298be0SKyle Evans.It origin
294f0298be0SKyle Evans.It used
295f0298be0SKyle Evans.It usedds
296f0298be0SKyle Evans.It usedsnap
297f0298be0SKyle Evans.It usedrefreserv
298f0298be0SKyle Evans.El
299f0298be0SKyle Evans.It Fl C Ar property
300f0298be0SKyle EvansSame as the
301f0298be0SKyle Evans.Fl c
302f0298be0SKyle Evansoption, but displays in descending order.
303f0298be0SKyle Evans.El
304f0298be0SKyle Evans.Pp
305f0298be0SKyle EvansThe
306f0298be0SKyle Evans.Fl D
307f0298be0SKyle Evansoption is ignored when either the
3085952343eSKyle Evans.Fl s
309f0298be0SKyle Evansor
310f0298be0SKyle Evans.Fl a
311f0298be0SKyle Evansoption is used.
312d81df689SKyle Evans.It Cm mount Ar beName Op Ar mountpoint
3135952343eSKyle EvansTemporarily mount the boot environment.
3145952343eSKyle EvansMount at the specified
3155952343eSKyle Evans.Ar mountpoint
3165952343eSKyle Evansif provided.
317d81df689SKyle Evans.It Cm rename Ar origBeName newBeName
31877688bffSMateusz PiotrowskiRename the given
3195952343eSKyle Evans.Ar origBeName
3205952343eSKyle Evansto the given
321d81df689SKyle Evans.Ar newBeName .
3228369ba42SKyle EvansThe boot environment will not be unmounted in order for this rename to occur.
323*b1ea63e2SRobert Wing.It Cm ujail Brq Ar jailId | jailName | beName
324*b1ea63e2SRobert Wing.It Cm unjail Brq Ar jailId | jailName | beName
32577688bffSMateusz PiotrowskiDestroy the jail created from the given boot environment.
32677688bffSMateusz Piotrowski.It Xo
32777688bffSMateusz Piotrowski.Cm umount
32877688bffSMateusz Piotrowski.Op Fl f
32977688bffSMateusz Piotrowski.Ar beName
33077688bffSMateusz Piotrowski.Xc
331d81df689SKyle Evans.It Xo
332d81df689SKyle Evans.Cm unmount
3335952343eSKyle Evans.Op Fl f
334d81df689SKyle Evans.Ar beName
335d81df689SKyle Evans.Xc
3365952343eSKyle EvansUnmount the given boot environment, if it is mounted.
3375952343eSKyle EvansSpecifying
3385952343eSKyle Evans.Fl f
3395952343eSKyle Evanswill force the unmount if busy.
3405952343eSKyle Evans.El
34177688bffSMateusz Piotrowski.Pp
34277688bffSMateusz Piotrowski.Nm
34377688bffSMateusz Piotrowskiprints usage information if
34477688bffSMateusz Piotrowski.Fl h
34577688bffSMateusz Piotrowskior
34677688bffSMateusz Piotrowski.Fl \&?
34777688bffSMateusz Piotrowskiis specified.
348d6105756SMateusz Piotrowski\" .Sh EXAMPLES
349d6105756SMateusz Piotrowski\" .Bl -bullet
350d6105756SMateusz Piotrowski\" .It
351d6105756SMateusz Piotrowski\" To fill in with jail upgrade example when behavior is firm.
352d6105756SMateusz Piotrowski\" .El
3535952343eSKyle Evans.Sh SEE ALSO
354f5c8cb4cSMateusz Piotrowski.Xr libbe 3 ,
355cb67aaf2SAlan Somers.Xr beinstall.sh 8 ,
3565952343eSKyle Evans.Xr jail 8 ,
3575952343eSKyle Evans.Xr zfs 8 ,
3585952343eSKyle Evans.Xr zpool 8
3595952343eSKyle Evans.Sh HISTORY
3605952343eSKyle Evans.Nm
3615952343eSKyle Evansis based on
36277688bffSMateusz Piotrowski.Xr beadm 1
3635952343eSKyle Evansand was implemented as a project for the 2017 Summer of Code, along with
3645952343eSKyle Evans.Xr libbe 3 .
3655952343eSKyle Evans.Sh AUTHORS
366d81df689SKyle Evans.Nm
367d81df689SKyle Evanswas written by
368d81df689SKyle Evans.An Kyle Kneitinger (kneitinger) Aq Mt kyle@kneit.in .
3695952343eSKyle Evans.Pp
37077688bffSMateusz Piotrowski.Xr beadm 1
371d81df689SKyle Evanswas written and is maintained by
372d81df689SKyle Evans.An Slawomir Wojciech Wojtczak (vermaden) Aq Mt vermaden@interia.pl .
3735952343eSKyle Evans.Pp
37434761e84SKyle Evans.An Bryan Drewery (bdrewery) Aq Mt bryan@shatow.net
375d81df689SKyle Evanswrote the original
37677688bffSMateusz Piotrowski.Xr beadm 1
3775952343eSKyle Evansmanual page that this one is derived from.
378