From nobody Mon May 30 14:54:30 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 D4A331B49B4D; Mon, 30 May 2022 14:54:30 +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 4LBdjL5JLPz4TBQ; Mon, 30 May 2022 14:54:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653922470; 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=KEtRnos3zCvYXWlixKTFgp8MEzjNxzlpNNd0oTTFVck=; b=cZ1M1ol0sKBbe+WZqBVWmINPxc5IR260Yt2EJcbsr8GvnrlJjVlVUchV4781Y2JLQeRyf8 j/PxVgcHM/rFcTEy54yLJtBT1fnhAUPtoyj07pYOHjCjDz5lIXZ1ZU2W9uEiuf/9cM++L8 xG/XwXYAalYOgPllYSGHoEWFD1TAJ4oUMjKYnP2FO1aGXMdbX5CZ+u0RQcokdB8fQEbCZc WFzOi2T2GQMM3qYFim2vUeiTHpxsCHVNjVVnm5sKEBezdGh8ZIXIvdNDgrgOcCC1Uys+SL 9KV2u1yXIWlNN/HeIXsKP/kcLpoo2Xr848oi0+bxfNOJtaJ1PFV1EGaVIaA/dg== 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 8C85F193FC; Mon, 30 May 2022 14:54:30 +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 24UEsU1K090701; Mon, 30 May 2022 14:54:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24UEsULJ090700; Mon, 30 May 2022 14:54:30 GMT (envelope-from git) Date: Mon, 30 May 2022 14:54:30 GMT Message-Id: <202205301454.24UEsULJ090700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 227caacc918a - main - 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/main X-Git-Reftype: branch X-Git-Commit: 227caacc918a8c9b32608cff42116e7d890b9ddc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653922470; 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=KEtRnos3zCvYXWlixKTFgp8MEzjNxzlpNNd0oTTFVck=; b=fGsuL6/5a/Xs1FweyWBY6yEM6lxX9b59bP1UwskgR8jdX3MQZU2IxsEpt9aIzqw/iMQl18 WzeyBQH7X3vBAiS47MqX55n+6aZ4AG8IyCs5ItRKzbAQHednIm+OwlQrxMqxkWoIh4+sJ/ 5eGCbfsBBSCwvn9JoXIfPlZfunqB4L4A4urpx93bTiXrkOtmSEJyseDKgbiZdH3qbav75V +dU7zFAVZo6SyxAFrgzV7uk72jEqcSN8I7C16axh/G6hSYMsga3tWznpU57qOdx1p/KK9q d1w7DGT2LQFkZJrUma4XJY3mI05OsmqVo+Mk5NARhf6r43A6mLqvgjPHHw01rQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653922470; a=rsa-sha256; cv=none; b=KLg1sTw4PISbvLyXjeNe9Z5l+jchC/5AGKI41uNn3SXmX9GlL6JABIAdp22Wtee4LWPwVB uzIuIuw8XMO/9crdDuHsAF8VR4C5KrYmazzbMDLH/7hxVrKPI0z3u1JUQBu/YLAiicW+8/ 9QtA6pqML3h+p+gASwZ0HsWC2eR8hLVZlXFRmqBqFnP1Pjmi3/j41UpslkQG3SIKXHZTi4 oT2p28f1SZNNpkGryU2YG0/thzrAx+by8iJnV9iB7HrkaV4RcIPvK+NVChlYw/ZUoQoFFl TFwGW4gILItbAhcne+R3iNfFk1WJTxTE8cf0wgibkUCtZcL12IlO7/rTRD+w8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=227caacc918a8c9b32608cff42116e7d890b9ddc commit 227caacc918a8c9b32608cff42116e7d890b9ddc Author: Mark Johnston AuthorDate: 2022-05-30 14:43:44 +0000 Commit: Mark Johnston CommitDate: 2022-05-30 14:43: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) MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35336 --- libexec/rc/rc.conf | 2 ++ libexec/rc/rc.d/Makefile | 1 + libexec/rc/rc.d/zpoolreguid | 25 +++++++++++++++++++++++++ share/man/man5/rc.conf.5 | 8 +++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index a497740eff85..c12377d035d6 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 c61d4528bcee..3eabd17df993 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -326,6 +326,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 01b09b1a59bd..5687fa6bec7c 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 3, 2022 +.Dd May 26, 2022 .Dt RC.CONF 5 .Os .Sh NAME @@ -2067,6 +2067,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