From nobody Sat Dec 10 19:41:14 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 4NTytg01d1z4kHnn; Sat, 10 Dec 2022 19:41:15 +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 4NTytf68s3z3kpQ; Sat, 10 Dec 2022 19:41:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670701274; 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=HCeHKWX0Z/Fc8obaDeqF45/lEC3TLkmt2jTiStLxeC0=; b=w0wiUdQ1/c+XCPuNbRUw1EsDi+sEWZvRSyIKb90HGktTRynbqQJQDsmJfNo1cIcYOM8xpW BOq5J6S1KEYO2AWGV3rPCEbgzMP33R8hXD7WRFGuqS9yEAg10ZICeePs48RJoIStG+2d/Y ktznKXQ3Diz1ItZU54+WDfL4LFBjVIgVH6GAI4vE1IJP8gLe8Ud/Chi8C+UDnBkiGbs4AX uMUY3QdQg/WfFY1DCrlpwJs8+KgaR9j8CCO0bALWUyBerhe0NBoMAfdeerfz/j/Nq7vRVi 5No6Qa57dCF92B1Y0G4xtQqJH1Dbks8Nejfd3TexA5QOlj0YREsKzZDySxU0Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670701274; 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=HCeHKWX0Z/Fc8obaDeqF45/lEC3TLkmt2jTiStLxeC0=; b=jmpgYv3fj50PplkyNm59g4HTfdDClZJr+yz4XfzPSorniWzo2K1rPKjk9V1xb5BdKxjnWs lv3uLH7OV+WA6hZGwrWPYY565eL44VjPcYhxCDJ4NEY/Us2W08fKg76B8krSMpBgd0mVHw iEaJf3i54YH06pO4iR4qg0lyI7JN9EV/pdZLD+Gb2QJFzVvVIziE5IqQhiydhir6mVi+eC 3xVw39D6FmXadstv5/m/NZ6BccFuAn+kRPpAFteWtUwR9fJ8BX5/UKBoPfp5ghp0gkhLCP OSIakiWAyyd2RcpoUoFUWbbqnvBsKCsJEVw4Yle7ByFHydnlFWAf93aMCtnBCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670701274; a=rsa-sha256; cv=none; b=jtwN6H/CEVZQvbR0FtDYjtBdT0MlTeiRYqvt/lRvUTyq2utXeediwYlA3+piIGd1FXysBH /TZnMWNo1oheBWrM/O/aq3Ns2OD8+KFzJS80uOLmDfmMKlyddaRWxgCogpW/7xJO9gaoOd EtEHdYmY7SVC6o4BemWaFqzsXgRKK4cElp9zOd20fMaKLQ1NmTpWA/dEWyDUOnEHc2xal5 M+GqiOsCcLOdy4v/Z4QYRQAAH3HEqgRAWJhi7F8QvXqt7mUWDB4EkMsk0dTwuUkJDeBtKA Fn/3MtBg29hlk1V2y79Ay6c/rHaxRv3yAEPST93LmcTN19jhAI96vECNp5lKZw== 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 4NTytf5GXlzSGQ; Sat, 10 Dec 2022 19:41:14 +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 2BAJfEF5085267; Sat, 10 Dec 2022 19:41:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BAJfEa8085266; Sat, 10 Dec 2022 19:41:14 GMT (envelope-from git) Date: Sat, 10 Dec 2022 19:41:14 GMT Message-Id: <202212101941.2BAJfEa8085266@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mike Karels Subject: git: d670a8f7c596 - main - growfs_fstab: add new /etc/rc.d script to add swap to fstab 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: karels X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d670a8f7c596fd387823644c5cbf1ddee788eee4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=d670a8f7c596fd387823644c5cbf1ddee788eee4 commit d670a8f7c596fd387823644c5cbf1ddee788eee4 Author: Mike Karels AuthorDate: 2022-12-10 19:39:59 +0000 Commit: Mike Karels CommitDate: 2022-12-10 19:39:59 +0000 growfs_fstab: add new /etc/rc.d script to add swap to fstab The growfs_fstab script is a helper for the growfs script to add any new swap partition to /etc/fstab on first boot. If growfs adds a swap partition, it sets growfs_swap_pdev in the kenv. In this case, after the root file system is read/write, if there is no swap partition in the fstab, growfs_fstab adds growfs_swap as a swap partition to the fstab. Also, it runs dumpon to add the swap partition (as this happened earlier in the startup sequence). Discussed with: cperciva Differential Revision: https://reviews.freebsd.org/D37463 --- libexec/rc/rc.d/growfs_fstab | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/libexec/rc/rc.d/growfs_fstab b/libexec/rc/rc.d/growfs_fstab new file mode 100755 index 000000000000..8ad34f452ce0 --- /dev/null +++ b/libexec/rc/rc.d/growfs_fstab @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Copyright 2022 Michael J. Karels +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# PROVIDE: growfs_fstab +# REQUIRE: growfs root +# KEYWORD: firstboot + +# If the growfs script added a swap partition, then add a swap entry +# to /etc/fstab if none exists, and add as dumpdev. + +. /etc/rc.subr + +name="growfs_fstab" +desc="Add new swap partition to /etc/fstab" +start_cmd="growfs_fstab_start" +stop_cmd=":" +rcvar="growfs_enable" + +growfs_fstab_start() +{ + if kenv -q growfs_swap_pdev >/dev/null + then + if awk ' + /^#/ { next } + $3 == "swap" { exit 1 } + ' < /etc/fstab + then + printf "/dev/label/growfs_swap\tnone\t\tswap\tsw\t\t0\t0\n" >>/etc/fstab + + case "$dumpdev" in + [Aa][Uu][Tt][Oo]) + dumpon $dumpon_flags /dev/label/growfs_swap + ;; + *) + ;; + esac + fi + fi +} + +load_rc_config $name +run_rc_command "$1"