From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: Henning Schild <henning.schild@siemens.com>
Cc: Joe MacDonald <joe_macdonald@mentor.com>,
isar-users@googlegroups.com, joe.macdonald@siemens.com
Subject: Re: [PATCH v2] expand-on-first-boot: support resizing a btrfs root
Date: Sat, 10 Dec 2022 04:28:48 +0100 [thread overview]
Message-ID: <CAJGKYO63BfCYSVvzC9j_20SWhhOcTbE=rpwQwHg4FmxqySWtFw@mail.gmail.com> (raw)
In-Reply-To: <20221209164014.41bcdc55@md1za8fc.ad001.siemens.net>
[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]
On Fri, 9 Dec 2022 at 16:40, Henning Schild <henning.schild@siemens.com> wrote:
>
> It all looks like we want to revert the systemd-growfs patch and go
> back to using plain tools for each partition type. So i looked at this
> again and will likely propose another round, keeping the author but
> changing it quite a bit.
>
> Am Fri, 22 Oct 2021 15:50:47 -0400
> schrieb Joe MacDonald <joe_macdonald@mentor.com>:
>
> > resize2fs fails if the build sets the root filesystem for an image to
> > btrfs though the partition is expanded properly. Since the rest of the
> > script works as intended, simply checking the last partition type with
> > lsblk and adding `btrfs resize` instead of `resize2fs` in the
> > appropriate circumstance allows everything to function as expected.
>
> It it not about "rootfs" it is about the last partition.
This is the code you need to integrate btrfs filesystem
case $(lsblk -fno FSTYPE "${LAST_PART}") in
ext4) resize2fs "${LAST_PART}"
;;
btrfs) mkdir -p /tmp/btrfs
mount "${LAST_PART}" /tmp/btrfs
btrfs filesystem resize max /tmp/btrfs
umount /tmp/btrfs && rmdir /tmp/btrfs
;;
esac
In attachment the patch against the current next branch.
It has been sent by elastic mail but went in moderation, as usual.
Best regards, R-
[-- Attachment #2: 0001-In-expand-last-partition-script-btrfs-support-added.patch --]
[-- Type: text/x-patch, Size: 3052 bytes --]
From 77c85b611d3da5712b8c883e7f97af72201e11b7 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sat, 10 Dec 2022 04:13:42 +0100
Subject: [PATCH] In expand last partition script btrfs support added
improvement, expand-on-first-boot: support for btrfs added
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../expand-on-first-boot_1.2.bb | 2 +-
.../files/expand-last-partition.sh | 37 ++++++-------------
2 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index 0996000..fe7b72b 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -10,7 +10,7 @@ inherit dpkg-raw
DESCRIPTION = "This service grows the last partition to the full medium during first boot"
MAINTAINER = "isar-users <isar-users@googlegroups.com>"
-DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux"
+DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs"
SRC_URI = " \
file://expand-on-first-boot.service \
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 57055cc..acfef8a 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
@@ -57,29 +57,16 @@ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
# Inform the kernel about the partitioning change
partx -u "${LAST_PART}"
-# this is for debian stretch or systemd < 236
-if [ ! -x /lib/systemd/systemd-growfs ]; then
- # Do not fail resize2fs if no mtab entry is found, e.g.,
- # when using systemd mount units.
- export EXT2FS_NO_MTAB_OK=1
+# 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}"
- exit 0
-fi
-
-if grep -q x-systemd.growfs /etc/fstab; then
- echo "Found x-systemd.growfs option in /etc/fstab, won't call it explicitly." >&2
- exit 0
-fi
-
-# mount $LAST_PART out of tree, so we won't conflict with other mounts
-MOUNT_POINT=$(mktemp -d -p /mnt "$(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}"
-/lib/systemd/systemd-growfs "${MOUNT_POINT}"
-umount "${MOUNT_POINT}"
-rmdir "${MOUNT_POINT}"
+case $(lsblk -fno FSTYPE "${LAST_PART}") in
+ ext4) resize2fs "${LAST_PART}"
+ ;;
+ btrfs) mkdir -p /tmp/btrfs
+ mount "${LAST_PART}" /tmp/btrfs
+ btrfs filesystem resize max /tmp/btrfs
+ umount /tmp/btrfs && rmdir /tmp/btrfs
+ ;;
+esac
--
2.34.1
next prev parent reply other threads:[~2022-12-10 3:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 18:01 [PATCH] " Joe MacDonald
2021-10-22 18:19 ` Jan Kiszka
2021-10-22 19:50 ` Joe MacDonald
2021-10-22 19:50 ` [PATCH v2] " Joe MacDonald
2021-10-25 8:10 ` Henning Schild
2021-10-25 8:22 ` Henning Schild
2022-04-22 7:57 ` Henning Schild
2022-04-22 9:06 ` Jan Kiszka
2022-12-09 15:40 ` Henning Schild
2022-12-10 3:28 ` Roberto A. Foglietta [this message]
2022-12-10 16:29 ` Henning Schild
2022-12-10 20:37 ` Roberto A. Foglietta
2022-12-12 15:24 ` Henning Schild
2022-12-12 17:48 ` Roberto A. Foglietta
2022-12-13 2:10 ` Moessbauer, Felix
2022-12-13 6:02 ` Roberto A. Foglietta
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='CAJGKYO63BfCYSVvzC9j_20SWhhOcTbE=rpwQwHg4FmxqySWtFw@mail.gmail.com' \
--to=roberto.foglietta@gmail.com \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=joe.macdonald@siemens.com \
--cc=joe_macdonald@mentor.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