Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Nov 2022 03:39:19 GMT
From:      Li-Wen Hsu <lwhsu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 72a1cb05cd23 - main - rc(8): Add a zpoolupgrade rc.d script
Message-ID:  <202211070339.2A73dJlO027991@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/src/commit/?id=72a1cb05cd230ce0d12a7180ae65ddbba2e0cb6d

commit 72a1cb05cd230ce0d12a7180ae65ddbba2e0cb6d
Author:     Li-Wen Hsu <lwhsu@FreeBSD.org>
AuthorDate: 2022-11-07 03:30:09 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2022-11-07 03:30:09 +0000

    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
---
 libexec/rc/rc.conf           |  2 ++
 libexec/rc/rc.d/Makefile     |  1 +
 libexec/rc/rc.d/zpoolupgrade | 25 +++++++++++++++++++++++++
 share/man/man5/rc.conf.5     |  9 ++++++++-
 4 files changed, 36 insertions(+), 1 deletion(-)

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
 ZFSPACKAGE=	rc
 .endif
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 @@
+#!/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"
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
 .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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211070339.2A73dJlO027991>