From owner-svn-src-head@freebsd.org Fri Feb 8 19:19:32 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31BFD14BE73E; Fri, 8 Feb 2019 19:19:32 +0000 (UTC) (envelope-from cperciva@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C588A8F17F; Fri, 8 Feb 2019 19:19:31 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA40B1D7E6; Fri, 8 Feb 2019 19:19:31 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x18JJVwm071443; Fri, 8 Feb 2019 19:19:31 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x18JJVNd071442; Fri, 8 Feb 2019 19:19:31 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201902081919.x18JJVNd071442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Fri, 8 Feb 2019 19:19:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343918 - head/libexec/rc/rc.d X-SVN-Group: head X-SVN-Commit-Author: cperciva X-SVN-Commit-Paths: head/libexec/rc/rc.d X-SVN-Commit-Revision: 343918 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C588A8F17F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2019 19:19:32 -0000 Author: cperciva Date: Fri Feb 8 19:19:31 2019 New Revision: 343918 URL: https://svnweb.freebsd.org/changeset/base/343918 Log: Teach /etc/rc.d/growfs how to handle systems running ZFS. There are many cases which this code does not handle (e.g. ZFS mirrors) but the code can handle the single-disk case -- so it's enough to take care of the "disk image which gets booted into a VM with a larger than expected disk" case for which this firstboot script was created. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19095 Modified: head/libexec/rc/rc.d/growfs Modified: head/libexec/rc/rc.d/growfs ============================================================================== --- head/libexec/rc/rc.d/growfs Fri Feb 8 18:31:54 2019 (r343917) +++ head/libexec/rc/rc.d/growfs Fri Feb 8 19:19:31 2019 (r343918) @@ -49,7 +49,20 @@ rcvar="growfs_enable" growfs_start () { echo "Growing root partition to fill device" - rootdev=$(df / | tail -n 1 | awk '{ sub("/dev/", "", $1); print $1 }') + FSTYPE=$(mount -p | awk '{ if ( $2 == "/") { print $3 }}') + FSDEV=$(mount -p | awk '{ if ( $2 == "/") { print $1 }}') + case "$FSTYPE" in + ufs) + rootdev=${FSDEV#/dev/} + ;; + zfs) + pool=${FSDEV%%/*} + rootdev=$(zpool list -v $pool | tail -n 1 | awk '{ print $1 }') + ;; + *) + echo "Don't know how to grow root filesystem type: $FSTYPE" + return + esac if [ x"$rootdev" = x"${rootdev%/*}" ]; then # raw device rawdev="$rootdev" @@ -91,7 +104,14 @@ growfs_start () } }' dev="$rawdev" gpart commit "$rootdev" - growfs -y /dev/"$rootdev" + case "$FSTYPE" in + ufs) + growfs -y /dev/"$rootdev" + ;; + zfs) + zpool online -e $pool $rootdev + ;; + esac } load_rc_config $name