From nobody Tue Jul 19 14:09:25 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LnLLG0rQbz4XNyP; Tue, 19 Jul 2022 14:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LnLLG0Ndkz3Z3W; Tue, 19 Jul 2022 14:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658239766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qzrlAP8QJuDV0RIuAaX36WkNKU5vc9U8iVhuHxikh8Q=; b=u9WYRiwLU8duh4W0CRpM/ooRIA8mTl9rZR9DDdJOnn8ogaskEaVo/Im48Gq/k/3f6EcRtg UyWHiuGfCj50Gy2TV77LoMXHeQ+VS0yxJ9Pi1hZgntaGkTii4jFwW0fEFn/Jj4JquNG1Yj OzKFqoMZkLsKC0XdhCAMazn8BbmvzjZG91thGt4mL35iwJT+ymg4CG64SL0ZNvJAOEJenV sz6LEdjWcmxD+JOoRwrdArIJCJBSqEw/oYZ0hi6vlYe+gLU1Fx4CJta9zUi6lAONjXBFGG 1o6LH9URIHtfk3xosaBNmEc9RjYJrbHlOakCwK3Cm3EPDrihRiDu/o8XmlOPRw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LnLLF6MqPzLxp; Tue, 19 Jul 2022 14:09:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26JE9P9D051964; Tue, 19 Jul 2022 14:09:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26JE9PqA051963; Tue, 19 Jul 2022 14:09:25 GMT (envelope-from git) Date: Tue, 19 Jul 2022 14:09:25 GMT Message-Id: <202207191409.26JE9PqA051963@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f82f93ffc12d - stable/13 - rc: Add a zpoolreguid rc.d script List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f82f93ffc12da319aff0e0411167cc32ed375a87 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658239766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qzrlAP8QJuDV0RIuAaX36WkNKU5vc9U8iVhuHxikh8Q=; b=YG+IvCte3SFS2+z5BOrZVUyzWmf8cgnEIIlgCw8hxv2jusVekx3z0FwowmCFIAopfAR/a6 Basp4VHDVqNeVXvBynhhrqhV+PK21zDLqtUxnxDGvc+xuVfTO8ge6c51zzfKKE3vdHf7aF oVuVgofY6ZECCJizB3ry7qR2vJGZokUxpK8BzfW4PCTEf7a/HDqTMsxHQXVI3xvtbXG4CK VHDRxuC0oE25oEbf2ecevl9sj77CRhfkCGvuXu50S0SQdMWEh0EuV7hB5eRfid6Fn53FFU mt6gx3H0M1V5rUcHc/n6CMSM3+CJiCyaAu4N+YACQvmRLT0rk4NNJkGHTmNzSA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658239766; a=rsa-sha256; cv=none; b=LO8bY88YZox99zzNabf7zNIE4jWkqXO0mB48j1kIBbRoA5UXvo4NrpBVx3l3ajUSwb1WLh 7VRcjpJMTEAOrNPYYzldBD6J54vsXblSI5TbHZraGry7H5hBAoR/f9J3leUHGBi2pGT6j+ Y8IzvXwgzbY656F2QHD92uN8DvTl1aeEDC4hREdAyQDpHve2C+A27X9i6q5l4NXhPpLCpG Py1/a2R1GumGYgFqVvRbeF6N7Cuft6Vmx5o5GCCmkQw/jJOwrTdafDNE1xjcCN7JzKcfS6 9sM3qumxlObkCh3P9izWeesTHMfMvvUHI9ZUfW+ap9b/VYGuPOiLQ/v45e4b3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f82f93ffc12da319aff0e0411167cc32ed375a87 commit f82f93ffc12da319aff0e0411167cc32ed375a87 Author: Mark Johnston AuthorDate: 2022-05-30 14:43:44 +0000 Commit: Mark Johnston CommitDate: 2022-07-19 13:49:44 +0000 rc: Add a zpoolreguid rc.d script If one boots up multiple copies of a template VM image containing a zpool, the pool GUIDs will be identical, making it impossible to, e.g., share datasets between them. This diff introduces a simple workaround for the problem: one can use the script to, upon first boot, assign a new GUID to one or more zpools. This will be useful when building ZFS-based VM images from release(7). Reviewed by: mav, allanjude, asomers Reviewed by: Pau Amma (docs) Sponsored by: The FreeBSD Foundation (cherry picked from commit 227caacc918a8c9b32608cff42116e7d890b9ddc) --- libexec/rc/rc.conf | 2 ++ libexec/rc/rc.d/Makefile | 1 + libexec/rc/rc.d/zpoolreguid | 25 +++++++++++++++++++++++++ share/man/man5/rc.conf.5 | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index f3fb3fd9473c..422c2efa9b59 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -69,6 +69,8 @@ rc_conf_files="/etc/rc.conf /etc/rc.conf.local" zfs_enable="NO" # Set to YES to automatically mount ZFS file systems 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. # 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 c724119cdf48..34846411dce9 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -328,6 +328,7 @@ ZFS+= zfsbe ZFS+= zfsd ZFS+= zfskeys ZFS+= zpool +ZFS+= zpoolreguid ZFS+= zvol ZFSPACKAGE= rc .endif diff --git a/libexec/rc/rc.d/zpoolreguid b/libexec/rc/rc.d/zpoolreguid new file mode 100755 index 000000000000..83c703d5d6c4 --- /dev/null +++ b/libexec/rc/rc.d/zpoolreguid @@ -0,0 +1,25 @@ +#!/bin/sh + +# PROVIDE: zpoolreguid +# REQUIRE: zpool +# BEFORE: mountcritlocal +# KEYWORD: firstboot nojail + +. /etc/rc.subr + +name="zpoolreguid" +desc="Generate a new zpool GUID" +rcvar="zfs_enable" +start_cmd="zpoolreguid_start" + +zpoolreguid_start() +{ + local pool + + for pool in "${zpool_reguid}"; do + zpool reguid $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 2581783794be..1f268ada7f47 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -2051,6 +2051,12 @@ If set to .Pa /etc/rc.d/zfs will attempt to automatically mount ZFS file systems and initialize ZFS volumes (ZVOLs). +.It Va zpool_reguid +.Pq Vt str +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 gptboot_enable .Pq Vt bool If set to