diff options
authorLi-Wen Hsu <lwhsu@FreeBSD.org>2022-11-07 03:30:09 +0000
committerLi-Wen Hsu <lwhsu@FreeBSD.org>2022-11-07 03:30:09 +0000
commit72a1cb05cd230ce0d12a7180ae65ddbba2e0cb6d (patch)
parentf83db6441a2f4f925a169c7ddf844589cb73c9b5 (diff)
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
4 files changed, 36 insertions, 1 deletions
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index bc908075d033..a71a3fa4063d 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -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
diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile
index e8ee61ffdff8..0f0d87bdde80 100644
--- a/libexec/rc/rc.d/Makefile
+++ b/libexec/rc/rc.d/Makefile
@@ -328,6 +328,7 @@ ZFS+= zfsd
ZFS+= zfskeys
ZFS+= zpool
ZFS+= zpoolreguid
+ZFS+= zpoolupgrade
ZFS+= zvol
diff --git a/libexec/rc/rc.d/zpoolupgrade b/libexec/rc/rc.d/zpoolupgrade
new file mode 100755
index 000000000000..6f5720bac6a7
--- /dev/null
+++ b/libexec/rc/rc.d/zpoolupgrade
@@ -0,0 +1,25 @@
+# PROVIDE: zpoolupgrade
+# REQUIRE: zpool
+# BEFORE: mountcritlocal
+# KEYWORD: firstboot nojail
+. /etc/rc.subr
+desc="Upgrade zpool version"
+ local pool
+ for pool in ${zpool_upgrade}; do
+ zpool upgrade $pool
+ done
+load_rc_config $name
+run_rc_command "$1"
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index f9ceabc83120..43fa44a5f1cb 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -24,7 +24,7 @@
.\" $FreeBSD$
-.Dd August 28, 2022
+.Dd November 7, 2022
@@ -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
.It Va gptboot_enable
.Pq Vt bool
If set to