rc(8): Add a zpoolupgrade rc.d script

If a zpool is created by makefs(8), its version is 5000, i.e., all
feature flags are off.  Introduce an rc script to run `zpool upgrade`
over the assigned zpools on the first boot.  This is useful to the
ZFS based VM images built from release(7).

Reviewed by:	imp, markj, mav
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37282
This commit is contained in:
Li-Wen Hsu 2022-11-07 11:30:09 +08:00
parent f83db6441a
commit 72a1cb05cd
No known key found for this signature in database
GPG key ID: 82B261B14D3BC7AF
4 changed files with 36 additions and 1 deletions

View file

@ -77,6 +77,8 @@ zfskeys_enable="NO" # Set YES to autoload ZFS encryption keys
zfs_bootonce_activate="NO" # Set YES to make successful bootonce BE permanent
zpool_reguid="" # Set to zpools for which the GUID should be replaced
# upon first boot.
zpool_upgrade="" # Set to zpools for which the version should be upgraded
# upon first boot.
# ZFSD support
zfsd_enable="NO" # Set to YES to automatically start the ZFS fault

View file

@ -328,6 +328,7 @@ ZFS+= zfsd
ZFS+= zfskeys
ZFS+= zpool
ZFS+= zpoolreguid
ZFS+= zpoolupgrade
ZFS+= zvol
ZFSPACKAGE= rc
.endif

25
libexec/rc/rc.d/zpoolupgrade Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
# PROVIDE: zpoolupgrade
# REQUIRE: zpool
# BEFORE: mountcritlocal
# KEYWORD: firstboot nojail
. /etc/rc.subr
name="zpoolupgrade"
desc="Upgrade zpool version"
rcvar="zfs_enable"
start_cmd="zpoolupgrade_start"
zpoolupgrade_start()
{
local pool
for pool in ${zpool_upgrade}; do
zpool upgrade $pool
done
}
load_rc_config $name
run_rc_command "$1"

View file

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 28, 2022
.Dd November 7, 2022
.Dt RC.CONF 5
.Os
.Sh NAME
@ -2109,6 +2109,13 @@ A space-separated list of ZFS pool names for which new pool GUIDs should be
assigned upon first boot.
This is useful when using a ZFS pool copied from a template, such as a virtual
machine image.
.It Va zpool_upgrade
.Pq Vt str
A space-separated list of ZFS pool names for which version should be upgraded
upon first boot.
This is useful when using a ZFS pool generated by
.Xr makefs 8
utility.
.It Va gptboot_enable
.Pq Vt bool
If set to