From: henning.schild@siemens.com
To: isar-users@googlegroups.com
Cc: Henning Schild <henning.schild@siemens.com>,
"Roberto A . Foglietta" <roberto.foglietta@gmail.com>,
Joe MacDonald <joe_macdonald@mentor.com>
Subject: [PATCH v5 2/6] expand-on-first-boot: support resizing a btrfs
Date: Thu, 15 Dec 2022 15:27:55 +0100 [thread overview]
Message-ID: <20221215142759.26327-3-henning.schild@siemens.com> (raw)
In-Reply-To: <20221215142759.26327-1-henning.schild@siemens.com>
From: Henning Schild <henning.schild@siemens.com>
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 <roberto.foglietta@gmail.com>
Suggested-by: Joe MacDonald <joe_macdonald@mentor.com>
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
...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
next prev parent reply other threads:[~2022-12-15 14:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 14:27 [PATCH v5 0/6] expand-on-first-boot btrfs and CI testing henning.schild
2022-12-15 14:27 ` [PATCH v5 1/6] expand-on-first-boot: really only do that once, especially on failure henning.schild
2022-12-15 15:32 ` Roberto A. Foglietta
2022-12-15 14:27 ` henning.schild [this message]
2022-12-15 17:48 ` [PATCH v5 2/6] expand-on-first-boot: support resizing a btrfs Roberto A. Foglietta
2022-12-15 14:27 ` [PATCH v5 3/6] meta-isar: introduce an example to use btrfs henning.schild
2022-12-15 14:27 ` [PATCH v5 4/6] CI: improve cibuilder readability henning.schild
2022-12-15 14:27 ` [PATCH v5 5/6] meta-isar: install expand-on-first-boot in most images and add space henning.schild
2022-12-15 14:27 ` [PATCH v5 6/6] CI: expect a message about filesystem resize vom expand script henning.schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221215142759.26327-3-henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=joe_macdonald@mentor.com \
--cc=roberto.foglietta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox