From: "T. Schaffner" <tobias.schaffner@siemens.com>
To: <isar-users@googlegroups.com>
Cc: <henning.schild@siemens.com>, <felix.moessbauer@siemens.com>,
<jan.kiszka@siemens.com>, <roberto.foglietta@gmail.com>,
Tobias Schaffner <tobias.schaffner@siemens.com>
Subject: [PATCH v3 1/1] expand-on-first-boot: wait for udev to create symlink
Date: Fri, 9 Dec 2022 12:24:41 +0100 [thread overview]
Message-ID: <20221209112441.87669-2-tobias.schaffner@siemens.com> (raw)
In-Reply-To: <20221209112441.87669-1-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
+
+echo "${GROWFS_OUTPUT}"
umount "${MOUNT_POINT}"
rmdir "${MOUNT_POINT}"
+exit ${EXIT_CODE}
+
--
2.34.1
next prev parent reply other threads:[~2022-12-09 11:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 11:24 [PATCH v3 0/1] " T. Schaffner
2022-12-09 11:24 ` T. Schaffner [this message]
2022-12-09 11:56 ` [PATCH v3 1/1] " Jan Kiszka
2022-12-09 13:57 ` Henning Schild
2022-12-09 15:11 ` Schaffner, Tobias
2022-12-09 17:23 ` 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=20221209112441.87669-2-tobias.schaffner@siemens.com \
--to=tobias.schaffner@siemens.com \
--cc=felix.moessbauer@siemens.com \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.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