From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7176574724112121856 X-Received: by 2002:a17:906:b088:b0:7bd:6295:cdd with SMTP id x8-20020a170906b08800b007bd62950cddmr49222664ejy.534.1671114485666; Thu, 15 Dec 2022 06:28:05 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6402:190a:b0:45c:bfd9:fb45 with SMTP id e10-20020a056402190a00b0045cbfd9fb45ls4791968edz.3.-pod-prod-gmail; Thu, 15 Dec 2022 06:28:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7imADvR8hkN5bAfBjCWHEIrZS45cNjAwY/rR4qo0imtEdSvbcNl6lNUhV++hFxC5Ba59lH X-Received: by 2002:aa7:cd78:0:b0:46c:be9f:7c3b with SMTP id ca24-20020aa7cd78000000b0046cbe9f7c3bmr23279397edb.19.1671114484562; Thu, 15 Dec 2022 06:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671114484; cv=none; d=google.com; s=arc-20160816; b=084GrTyNS/kIhcvUMGTDtcV/0tXqNZqXb3ECLW+O1tfNvhohW9RejkCnOi3mAabsUA Rm5izNDUJkqBaIypDhDEHprmAsz//ZmRhhz20l3ARS8OMtduYnz7T9jtCt6H2srSLIJn jr8d3+pICxgoILogD9710zcTivRRLuWjX6qbpANsVDlvj6oKYveaIs6XxwBUUNWJXgq/ RhcYkhQpE0NSN/5ZuGn9X1Kj8hDOmjLcAlrJGeE+Dq9FUa5dLtoHs0fTszcSqodZuv9H YR6shzfb/FDBz7eqdUZRjMOhP7xkZOM1g4YChu9a0qX3zOWVjjQNqgtLgy+0HMVEzIla 8nhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=Dbw68Ih8nBWlt1Bo2w0VuFeoSiSGlqoMVywCBr2+Am4=; b=c9ydJqxc1C6W1CiM3ph0dN4Dg07h3waY4AIoSefryRfvZTuDGikrs3GpyrB4Rru8Px qdpQ2zYSnuAj0TRQ0PKBVSkKHjDI5vDvMjDTANs1JwyaPc7NpVMRf3+GksqD87d2FAVK zINMfmztX+A0X5Tg0XI6gyGeEuIP2Qgfvw3cKEJJ1nDTim23iUri50YAXW4r1aTBsnuB +BlydOJzUBwtog/dOcFmLcI1cmTDNRUbQ/8svWCW5h5RqltFBWxv4El0SNS+FADPxSBS ySh8bAiAq2YTnt0TWBzNF4vNPVHQ6Y0UFStuX3zpKkYxM+WUUpEwXvic4bKzNNSSipiC P30Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=V+jkZMqS; spf=pass (google.com: domain of fm-52304-20221215142803665d1745c04eaccc5d-4t9cbq@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) smtp.mailfrom=fm-52304-20221215142803665d1745c04eaccc5d-4t9cBQ@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net. [185.136.64.225]) by gmr-mx.google.com with ESMTPS id ba13-20020a0564021acd00b004704657766csi361090edb.1.2022.12.15.06.28.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Dec 2022 06:28:04 -0800 (PST) Received-SPF: pass (google.com: domain of fm-52304-20221215142803665d1745c04eaccc5d-4t9cbq@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) client-ip=185.136.64.225; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=V+jkZMqS; spf=pass (google.com: domain of fm-52304-20221215142803665d1745c04eaccc5d-4t9cbq@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) smtp.mailfrom=fm-52304-20221215142803665d1745c04eaccc5d-4t9cBQ@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20221215142803665d1745c04eaccc5d for ; Thu, 15 Dec 2022 15:28:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=henning.schild@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=Dbw68Ih8nBWlt1Bo2w0VuFeoSiSGlqoMVywCBr2+Am4=; b=V+jkZMqSdwWoVwK2ZOF6Qj1pCUUsS5qjY5dV98NS/mu71xDtLGEY49oTIerzJIRscPHFpx HICRk09psCQANjhk4YIEit3CO/OQQHyizAybpeEocAD0dtFqWRFiLk0iJLuTNjbwZav+BgD6 pbNvsC0XDpewND3henRLS8zwc2UBM=; From: henning.schild@siemens.com To: isar-users@googlegroups.com Cc: Henning Schild , "Roberto A . Foglietta" , Joe MacDonald Subject: [PATCH v5 2/6] expand-on-first-boot: support resizing a btrfs Date: Thu, 15 Dec 2022 15:27:55 +0100 Message-Id: <20221215142759.26327-3-henning.schild@siemens.com> In-Reply-To: <20221215142759.26327-1-henning.schild@siemens.com> References: <20221215142759.26327-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-52304:519-21489:flowmailer X-TUID: qgO6Cf9epkjs From: Henning Schild This adds support for resizing btrfs filesystems if they are in that last partition. It also prepares for potentially other filesystems to come in the future by introducing a switch-case. The mounting logic is taken from the systemd-growfs patches we had to revert again. Some filesystems need to online for resizing, but in order to find the filesystem of a partition (without udev) mounting it and letting the kernel detect seems a good idea. Suggested-by: Roberto A. Foglietta Suggested-by: Joe MacDonald Signed-off-by: Henning Schild --- ...oot_1.3.bb => expand-on-first-boot_1.4.bb} | 0 .../files/expand-last-partition.sh | 35 ++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) rename meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.3.bb => expand-on-first-boot_1.4.bb} (100%) diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.3.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb similarity index 100% rename from meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.3.bb rename to meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh index 93eddda2a3b7..753b8c33399c 100755 --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh @@ -62,8 +62,35 @@ if grep -q x-systemd.growfs /etc/fstab; then exit 0 fi -# Do not fail resize2fs if no mtab entry is found, e.g., -# when using systemd mount units. -export EXT2FS_NO_MTAB_OK=1 +# some filesystems need to be mounted i.e. btrfs, but mounting also helps +# detect the filesystem type without having to wait for udev +# mount $LAST_PART out of tree, so we won't conflict with other mounts +MOUNT_POINT=$(mktemp -d --tmpdir "$(basename "$0").XXXXXXXXXX") +if [ ! -d "${MOUNT_POINT}" ]; then + echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2 + exit 1 +fi +mount "${LAST_PART}" "${MOUNT_POINT}" + +ret=0 +# Determine the filesystem type and perform the appropriate resize function +FS_TYPE=$(findmnt -fno FSTYPE "${MOUNT_POINT}" ) +case ${FS_TYPE} in +ext*) + # Do not fail resize2fs if no mtab entry is found, e.g., + # when using systemd mount units. + export EXT2FS_NO_MTAB_OK=1 + resize2fs "${LAST_PART}" + ;; +btrfs) + btrfs filesystem resize max "${MOUNT_POINT}" + ;; +*) + echo "Unrecognized filesystem type ${FS_TYPE} - no resize performed" + ret=1 + ;; +esac -resize2fs "${LAST_PART}" +umount "${MOUNT_POINT}" +rmdir "${MOUNT_POINT}" +exit $ret -- 2.37.4