public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Schaffner, Tobias" <tobias.schaffner@siemens.com>
To: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>,
	"Schild, Henning" <henning.schild@siemens.com>
Cc: "isar-users@googlegroups.com" <isar-users@googlegroups.com>,
	"MOESSBAUER, FELIX JONATHAN" <felix.moessbauer@siemens.com>,
	"Kiszka, Jan" <jan.kiszka@siemens.com>
Subject: Re: [PATCH] expand-on-first-boot: wait for udev to create symlink
Date: Fri, 9 Dec 2022 10:51:42 +0000	[thread overview]
Message-ID: <05f02754-df02-54c8-8cd0-7bf6595ca1a3@siemens.com> (raw)
In-Reply-To: <CAJGKYO70KdJLRrSk8BX_pPA83zKjcJJ+6Ce3ZA9VDJ89WxFXEA@mail.gmail.com>

On 09.12.22 01:22, Roberto A. Foglietta wrote:
> On Thu, 8 Dec 2022 at 18:39, Henning Schild <henning.schild@siemens.com> wrote:
>>
>> Am Thu, 8 Dec 2022 17:55:42 +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/.
>>>
> 
> reading that patch I had a flash-back about two patches I did recently
> for another project
> 
> https://github.com/robang74/tinycore-editor/commit/d57271e3229551ddfbd3deba1363d2efe2914908
> https://github.com/robang74/tinycore-editor/commit/4ff435bb8a73c7e956ea4f9303a36fe06a136e54
> 
> both altered this file
> 
> https://github.com/robang74/tinycore-editor/blob/main/tinycore/changes/rcS
> 
> the main problem and the final result was much the same: trigger udev
> and wait for the dev link.
> 
> # Start Udev to populate /dev and handle hotplug events
> /sbin/udevd --daemon 2>&1 >/dev/null
> /sbin/udevadm trigger --action=add 2>&1 >/dev/null
> /sbin/udevadm settle --timeout=5
> echo -ne "\e[1;37m"
> for i in $(seq 1 10); do
>      if gettcdev; then
>      break;
> fi >/dev/null
> echo -n .
> sleep 1
> done
> echo -e "\e[0m"
> /sbin/udevadm control --exit --timeout=5
> 
> in my case, the booting device is not meaningful because the rootfs is a file.
> 
> function gettcdev() {
>      blkid --label $tclabel
> }
> 
> So, the search for the USB stick device is done s by label

Thanks for providing this Roberto!

In isar we have the systemd-udevd service which is responsible for the 
start of the udevd.

The problem appears if this systemd unit is not up yet when we try to 
use systemd-growfs by hand.

Therefore a udevadm trigger/settle would also most probably hit to early.

Correct me if I am wrong.

Best,
Tobias

>>
>>> /dev/block/ as +# systemd-growfs depends on it
>>> +while ! readlink /dev/block/* | grep -q "${LAST_PART_NAME}"; do
>>
>> I would make that much stricter to not be tricked by partial matches
>>
>> sda4 vs sda42
> 
> Irrelevant, if sda42 has been found then sda4 exists as well
> considering the problem is not yet started.
> However, for sake of precision and to avoid corner cases in which
> sda42 is created before sda4 a dollar at the end of regex will solve
> this issue.
> 
> +while ! readlink /dev/block/* | grep -qe "${LAST_PART_NAME}$"; do
> 
>>
>> readlink -f /dev/block/* | grep -e -q "^${LAST_PART}$"
>>
>>> +    sleep 0.1
>>
>> I wonder if there is anything we could do here. Maybe "udevadm trigger"
>> and depend on udev after all. Because the 5 is a nasty guess ...
> 
> This is the reason because I cited my patches. I hope they will help you.
> 
> Best regards, R-

  reply	other threads:[~2022-12-09 10:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 16:55 T. Schaffner
2022-12-08 17:39 ` Henning Schild
2022-12-08 19:18   ` Schaffner, Tobias
2022-12-08 19:42     ` Henning Schild
2022-12-09  0:22   ` Roberto A. Foglietta
2022-12-09 10:51     ` Schaffner, Tobias [this message]
2022-12-09 17:17       ` 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=05f02754-df02-54c8-8cd0-7bf6595ca1a3@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