git: e51074735fa3 - stable/13 - MFC growfs script change from August 2021:
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Jan 2023 20:59:38 UTC
The branch stable/13 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=e51074735fa32fb48496bdc0dd3799eaf84afd19 commit e51074735fa32fb48496bdc0dd3799eaf84afd19 Author: Scott Long <scottl@FreeBSD.org> AuthorDate: 2021-08-17 21:50:18 +0000 Commit: Mike Karels <karels@FreeBSD.org> CommitDate: 2023-01-13 19:11:30 +0000 MFC growfs script change from August 2021: - Fix the growfs rc script to cope with diskid labels. - Fix a warning in growfs. gpart commit is supposed to be called on disk device. - Silence a gpart commit warning in growfs. Submitted by: loos Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D31587 Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 045001075ed18295288176211456dde3df7faf46) --- libexec/rc/rc.d/growfs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/libexec/rc/rc.d/growfs b/libexec/rc/rc.d/growfs index c2955c740d43..5402bd442279 100755 --- a/libexec/rc/rc.d/growfs +++ b/libexec/rc/rc.d/growfs @@ -48,6 +48,19 @@ start_cmd="growfs_start" stop_cmd=":" rcvar="growfs_enable" +growfs_get_diskdev () +{ + local _search=${1} + sysctl -b kern.geom.conftxt | + while read x1 _type _dev line + do + if [ "${_type}" = "DISK" -a -n "$(echo ${_search} | grep ${_dev})" ]; then + echo -n ${_dev} + break + fi + done +} + growfs_start () { echo "Growing root partition to fill device" @@ -69,13 +82,24 @@ growfs_start () # raw device rawdev="$rootdev" else - rawdev=$(glabel status | awk '$1 == "'"$rootdev"'" { print $3 }') + rawdev=$(glabel status | awk -v rootdev=$rootdev 'index(rootdev, $1) { print $3; }') if [ x"$rawdev" = x"" ]; then echo "Can't figure out device for: $rootdev" return fi fi + if [ x"diskid" = x"${rootdev%/*}" ]; then + search=$rootdev + else + search=$rawdev + fi + + diskdev=$(growfs_get_diskdev ${search}) + if [ -z "${diskdev}" ]; then + diskdev=${rootdev} + fi + sysctl -b kern.geom.conftxt | awk ' { lvl=$1 @@ -104,8 +128,8 @@ growfs_start () } exit 0 } -}' dev="$rawdev" - gpart commit "$rootdev" +}' dev="$search" + gpart commit "$diskdev" 2> /dev/null case "$FSTYPE" in ufs) growfs -y /dev/"$rootdev"