* [PATCH v3 0/1] expand-on-first-boot: wait for udev to create symlink @ 2022-12-09 11:24 T. Schaffner 2022-12-09 11:24 ` [PATCH v3 1/1] " T. Schaffner 0 siblings, 1 reply; 6+ messages in thread From: T. Schaffner @ 2022-12-09 11:24 UTC (permalink / raw) To: isar-users Cc: henning.schild, felix.moessbauer, jan.kiszka, roberto.foglietta, Tobias Schaffner From: Tobias Schaffner <tobias.schaffner@siemens.com> Changes since v2: - Remove unneeded helper function - Sign commit and create a cover letter with version changes Changes since v1: - Run systemd-growfs and retry on missing symlink in /dev/block systemd-growfs depends on a symlink to the partition of the filesystem that should be resized. This symlink is created by udev in /dev/block/. If this symlink is not yet created for example because systemd-udev is not up yet systemd-growfs will fail. We could use Require and After to depend on the systemd-udev service but this could again create a race condition if udev is up but not fast enough after the partx -u. Run systemd-growfs periodically until the symlink appears. Tobias Schaffner (1): expand-on-first-boot: wait for udev to create symlink .../files/expand-last-partition.sh | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink 2022-12-09 11:24 [PATCH v3 0/1] expand-on-first-boot: wait for udev to create symlink T. Schaffner @ 2022-12-09 11:24 ` T. Schaffner 2022-12-09 11:56 ` Jan Kiszka 2022-12-09 13:57 ` Henning Schild 0 siblings, 2 replies; 6+ messages in thread From: T. Schaffner @ 2022-12-09 11:24 UTC (permalink / raw) To: isar-users Cc: henning.schild, felix.moessbauer, jan.kiszka, roberto.foglietta, Tobias Schaffner From: Tobias Schaffner <tobias.schaffner@siemens.com> systemd-growfs depends on a symlink to the partition of the filesystem that should be resized. This symlink is created by udev in /dev/block/. If this symlink is not yet created for example because systemd-udev is not up yet systemd-growfs will fail. We could use Require and After to depend on the systemd-udev service but this could again create a race condition if udev is up but not fast enough after the partx -u. Run systemd-growfs periodically until the symlink appears. Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com> --- .../files/expand-last-partition.sh | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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..4d78e4f 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 @@ -80,6 +80,25 @@ if [ ! -d "${MOUNT_POINT}" ]; then fi mount "${LAST_PART}" "${MOUNT_POINT}" -/lib/systemd/systemd-growfs "${MOUNT_POINT}" + +EXIT_CODE=1 +# If systemd-udevd if not up yet or was not fast enough the symlinks in +# /dev/block/ might be missing. Retry in that case. +# This retry logic is only needed up to systemd-version 252 +for run in $(seq 0 50); do + if GROWFS_OUTPUT=$(/lib/systemd/systemd-growfs "${MOUNT_POINT}" 2>&1); then + EXIT_CODE=0 + break + else: + if ! echo ${GROWFS_OUTPUT} | grep -q "^Failed to open \"/dev/block/.*\": No such file or directory$"; then + break + fi + fi + sleep 0.1 +done + +echo "${GROWFS_OUTPUT}" umount "${MOUNT_POINT}" rmdir "${MOUNT_POINT}" +exit ${EXIT_CODE} + -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink 2022-12-09 11:24 ` [PATCH v3 1/1] " T. Schaffner @ 2022-12-09 11:56 ` Jan Kiszka 2022-12-09 13:57 ` Henning Schild 1 sibling, 0 replies; 6+ messages in thread From: Jan Kiszka @ 2022-12-09 11:56 UTC (permalink / raw) To: T. Schaffner, isar-users Cc: henning.schild, felix.moessbauer, roberto.foglietta On 09.12.22 12:24, T. Schaffner wrote: > From: Tobias Schaffner <tobias.schaffner@siemens.com> > > systemd-growfs depends on a symlink to the partition of the filesystem > that should be resized. This symlink is created by udev in /dev/block/. > > If this symlink is not yet created for example because systemd-udev is > not up yet systemd-growfs will fail. > > We could use Require and After to depend on the systemd-udev service > but this could again create a race condition if udev is up but not > fast enough after the partx -u. > > Run systemd-growfs periodically until the symlink appears. > > Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com> > --- > .../files/expand-last-partition.sh | 21 ++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > 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..4d78e4f 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 > @@ -80,6 +80,25 @@ if [ ! -d "${MOUNT_POINT}" ]; then > fi > > mount "${LAST_PART}" "${MOUNT_POINT}" > -/lib/systemd/systemd-growfs "${MOUNT_POINT}" > + > +EXIT_CODE=1 > +# If systemd-udevd if not up yet or was not fast enough the symlinks in > +# /dev/block/ might be missing. Retry in that case. > +# This retry logic is only needed up to systemd-version 252 > +for run in $(seq 0 50); do > + if GROWFS_OUTPUT=$(/lib/systemd/systemd-growfs "${MOUNT_POINT}" 2>&1); then > + EXIT_CODE=0 > + break > + else: ^^^ ? And why else at all? You break the loop anyway. Jan > + if ! echo ${GROWFS_OUTPUT} | grep -q "^Failed to open \"/dev/block/.*\": No such file or directory$"; then > + break > + fi > + fi > + sleep 0.1 > +done > + > +echo "${GROWFS_OUTPUT}" > umount "${MOUNT_POINT}" > rmdir "${MOUNT_POINT}" > +exit ${EXIT_CODE} > + -- Siemens AG, Technology Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink 2022-12-09 11:24 ` [PATCH v3 1/1] " T. Schaffner 2022-12-09 11:56 ` Jan Kiszka @ 2022-12-09 13:57 ` Henning Schild 2022-12-09 15:11 ` Schaffner, Tobias 2022-12-09 17:23 ` Roberto A. Foglietta 1 sibling, 2 replies; 6+ messages in thread From: Henning Schild @ 2022-12-09 13:57 UTC (permalink / raw) To: T. Schaffner; +Cc: isar-users, felix.moessbauer, jan.kiszka, roberto.foglietta Am Fri, 9 Dec 2022 12:24:41 +0100 schrieb "T. Schaffner" <tobias.schaffner@siemens.com>: > From: Tobias Schaffner <tobias.schaffner@siemens.com> > > systemd-growfs depends on a symlink to the partition of the filesystem > that should be resized. This symlink is created by udev in > /dev/block/. > > If this symlink is not yet created for example because systemd-udev is > not up yet systemd-growfs will fail. > > We could use Require and After to depend on the systemd-udev service > but this could again create a race condition if udev is up but not > fast enough after the partx -u. > > Run systemd-growfs periodically until the symlink appears. > > Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com> > --- > .../files/expand-last-partition.sh | 21 > ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) > > 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..4d78e4f 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 > @@ -80,6 +80,25 @@ if [ ! -d "${MOUNT_POINT}" ]; then fi mount > "${LAST_PART}" "${MOUNT_POINT}" -/lib/systemd/systemd-growfs > "${MOUNT_POINT}" + > +EXIT_CODE=1 > +# If systemd-udevd if not up yet or was not fast enough the symlinks > in +# /dev/block/ might be missing. Retry in that case. > +# This retry logic is only needed up to systemd-version 252 > +for run in $(seq 0 50); do > + if GROWFS_OUTPUT=$(/lib/systemd/systemd-growfs "${MOUNT_POINT}" > 2>&1); then > + EXIT_CODE=0 > + break > + else: > + if ! echo ${GROWFS_OUTPUT} | grep -q "^Failed to open > \"/dev/block/.*\": No such file or directory$"; then > + break > + fi > + fi > + sleep 0.1 > +done I wanted to review this and suggest some changes to better deal with systemd 252. But i am actually getting the strong feeling that we should simply go back to calling the respective filesystem resize tool. The whole story with repart did not work out so we thought we could at least use some bits (growfs) to support i.e. btrfs. But that thing now has this weird mount, and that funny udev problem ... who knows what comes next ... I propose to go back to resize2fs and add btrfs support with a switch-case. Still the whole story told us how repart/growfs can be used and we now have the wic patches needed for that and the bail-outs so the two methods do not start conflicting. We just did not manage to write a generic isar helper package. Maybe i will propose to switch one target over to repart/growfs ... but honestly, i do not trust that stuff too much at the moment and am not sure it has the maturity one might want. Henning > + > +echo "${GROWFS_OUTPUT}" > umount "${MOUNT_POINT}" > rmdir "${MOUNT_POINT}" > +exit ${EXIT_CODE} > + ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink 2022-12-09 13:57 ` Henning Schild @ 2022-12-09 15:11 ` Schaffner, Tobias 2022-12-09 17:23 ` Roberto A. Foglietta 1 sibling, 0 replies; 6+ messages in thread From: Schaffner, Tobias @ 2022-12-09 15:11 UTC (permalink / raw) To: Schild, Henning Cc: isar-users, MOESSBAUER, FELIX JONATHAN, Kiszka, Jan, roberto.foglietta On 09.12.22 14:57, Schild, Henning (T CED SES-DE) wrote: > Am Fri, 9 Dec 2022 12:24:41 +0100 > schrieb "T. Schaffner" <tobias.schaffner@siemens.com>: > >> From: Tobias Schaffner <tobias.schaffner@siemens.com> >> >> systemd-growfs depends on a symlink to the partition of the filesystem >> that should be resized. This symlink is created by udev in >> /dev/block/. >> >> If this symlink is not yet created for example because systemd-udev is >> not up yet systemd-growfs will fail. >> >> We could use Require and After to depend on the systemd-udev service >> but this could again create a race condition if udev is up but not >> fast enough after the partx -u. >> >> Run systemd-growfs periodically until the symlink appears. >> >> Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com> >> --- >> .../files/expand-last-partition.sh | 21 >> ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) >> >> 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..4d78e4f 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 >> @@ -80,6 +80,25 @@ if [ ! -d "${MOUNT_POINT}" ]; then fi mount >> "${LAST_PART}" "${MOUNT_POINT}" -/lib/systemd/systemd-growfs >> "${MOUNT_POINT}" + >> +EXIT_CODE=1 >> +# If systemd-udevd if not up yet or was not fast enough the symlinks >> in +# /dev/block/ might be missing. Retry in that case. >> +# This retry logic is only needed up to systemd-version 252 >> +for run in $(seq 0 50); do >> + if GROWFS_OUTPUT=$(/lib/systemd/systemd-growfs "${MOUNT_POINT}" >> 2>&1); then >> + EXIT_CODE=0 >> + break >> + else: >> + if ! echo ${GROWFS_OUTPUT} | grep -q "^Failed to open >> \"/dev/block/.*\": No such file or directory$"; then >> + break >> + fi >> + fi >> + sleep 0.1 >> +done > > I wanted to review this and suggest some changes to better deal with > systemd 252. But i am actually getting the strong feeling that we > should simply go back to calling the respective filesystem resize tool. > > The whole story with repart did not work out so we thought we could at > least use some bits (growfs) to support i.e. btrfs. But that thing now > has this weird mount, and that funny udev problem ... who knows what > comes next ... > > I propose to go back to resize2fs and add btrfs support with a > switch-case. Still the whole story told us how repart/growfs can be used > and we now have the wic patches needed for that and the bail-outs so > the two methods do not start conflicting. We just did not manage to > write a generic isar helper package. > > Maybe i will propose to switch one target over to repart/growfs ... but > honestly, i do not trust that stuff too much at the moment and am not > sure it has the maturity one might want. > > Henning I don't think that we can completely blame systemd-growfs for that. The combination of systemd units coming up in a nondeterministic order and asynchronous udev events creates an environment that is hard to test. That why we had problems with this script in several times with multiple projects. Reverting the patches that introduced systemd-growfs might anyways be a sane decision for now as it saves us a lot of complexity. Best, Tobias >> + >> +echo "${GROWFS_OUTPUT}" >> umount "${MOUNT_POINT}" >> rmdir "${MOUNT_POINT}" >> +exit ${EXIT_CODE} >> + > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink 2022-12-09 13:57 ` Henning Schild 2022-12-09 15:11 ` Schaffner, Tobias @ 2022-12-09 17:23 ` Roberto A. Foglietta 1 sibling, 0 replies; 6+ messages in thread From: Roberto A. Foglietta @ 2022-12-09 17:23 UTC (permalink / raw) To: Henning Schild; +Cc: T. Schaffner, isar-users, felix.moessbauer, jan.kiszka [-- Attachment #1: Type: text/plain, Size: 681 bytes --] On Fri, 9 Dec 2022 at 14:58, Henning Schild <henning.schild@siemens.com> wrote: > > I propose to go back to resize2fs and add btrfs support with a > switch-case. Still the whole story told us how repart/growfs can be used > and we now have the wic patches needed for that and the bail-outs so > the two methods do not start conflicting. We just did not manage to > write a generic isar helper package. In such a case, please give a second chance at this patch I submitted to add btrfs to last partition growth https://groups.google.com/g/isar-users/c/dxVJqRvnWjw/m/Y5g5mbIPBQAJ In a positive case, I can manage to deliver a further version of it more suitable Best regards, R- [-- Attachment #2: 0001-expand-last-partition-btrfs-support-added.patch --] [-- Type: text/x-patch, Size: 1936 bytes --] From 67c4ea67ac96276c5ec0e6b15d035543b99b8e04 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com> Date: Thu, 29 Sep 2022 15:36:48 +0000 Subject: [PATCH v2] expand last partition 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/expand-on-first-boot_1.1.bb | 2 +- .../expand-on-first-boot/files/expand-last-partition.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb index 1703a64..d41dd83 100644 --- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb +++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb @@ -9,7 +9,7 @@ inherit dpkg-raw DESCRIPTION = "This service grows the last partition to the full medium during first boot" -DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk, util-linux" +DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk, 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 759ff8b..5b73dc4 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 @@ -61,4 +61,9 @@ partx -u "${LAST_PART}" # when using systemd mount units. export EXT2FS_NO_MTAB_OK=1 -resize2fs "${LAST_PART}" +if ! resize2fs "${LAST_PART}"; then + mkdir -p /tmp/btrfs + mount "${LAST_PART}" /tmp/btrfs + btrfs filesystem resize max /tmp/btrfs + umount /tmp/btrfs && rmdir /tmp/btrfs +fi -- 2.30.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-09 17:23 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-09 11:24 [PATCH v3 0/1] expand-on-first-boot: wait for udev to create symlink T. Schaffner 2022-12-09 11:24 ` [PATCH v3 1/1] " T. Schaffner 2022-12-09 11:56 ` Jan Kiszka 2022-12-09 13:57 ` Henning Schild 2022-12-09 15:11 ` Schaffner, Tobias 2022-12-09 17:23 ` Roberto A. Foglietta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox