public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] In expand last partition wait for udev have finished
@ 2022-12-12 20:23 roberto.foglietta
  2022-12-13  2:01 ` Moessbauer, Felix
  0 siblings, 1 reply; 5+ messages in thread
From: roberto.foglietta @ 2022-12-12 20:23 UTC (permalink / raw)
  To: isar-users; +Cc: roberto.foglietta

From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>

bugfix, expand last partition, wait for udev completion

On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh         | 2 ++
 1 file changed, 2 insertions(+)

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 acfef8a..68e6698 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
@@ -9,6 +9,8 @@
 
 set -e
 
+udevadm settle
+
 ROOT_DEV="$(findmnt / -o source -n)"
 ROOT_DEV_NAME=${ROOT_DEV##*/}
 ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
-- 
2.34.1


https://16F0H.trk.elasticemail.com/tracking/unsubscribe?d=uQeFOzkk8plXVVZ2VnEcpnRSdsZJXyyuanyoKUe_hgUtRGm67z-BYxoD4dUduarMjrGtkXTgZjMZXUuF072gCX_KXuQap6OFDQDgYq9jqpv90

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] In expand last partition wait for udev have finished
  2022-12-12 20:23 [PATCH] In expand last partition wait for udev have finished roberto.foglietta
@ 2022-12-13  2:01 ` Moessbauer, Felix
  2022-12-13  8:44   ` Schaffner, Tobias
  0 siblings, 1 reply; 5+ messages in thread
From: Moessbauer, Felix @ 2022-12-13  2:01 UTC (permalink / raw)
  To: roberto.foglietta, isar-users

On Mon, 2022-12-12 at 20:23 +0000, roberto.foglietta@gmail.com wrote:
> From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
> 
> bugfix, expand last partition, wait for udev completion
> 
> On some hardware the udev did not created the links to the disk
> partitions
> while this script is working thus it fails. This patch fixes that
> cases.
> 
> Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
> ---
>  .../expand-on-first-boot/files/expand-last-partition.sh         | 2
> ++
>  1 file changed, 2 insertions(+)
> 
> 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 acfef8a..68e6698 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
> @@ -9,6 +9,8 @@
>  
>  set -e
>  
> +udevadm settle

Hi Roberto,

thanks for this patch.
I thought about something like that as well.
If that reliably works, I vote to simply add this line instead of -
again - re-writing this component.

Felix

> +
>  ROOT_DEV="$(findmnt / -o source -n)"
>  ROOT_DEV_NAME=${ROOT_DEV##*/}
>  ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth
> 1 -print -quit 2>/dev/null || true)
> -- 
> 2.34.1
> 
> 
> https://16F0H.trk.elasticemail.com/tracking/unsubscribe?d=uQeFOzkk8plXVVZ2VnEcpnRSdsZJXyyuanyoKUe_hgUtRGm67z-BYxoD4dUduarMjrGtkXTgZjMZXUuF072gCX_KXuQap6OFDQDgYq9jqpv90
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] In expand last partition wait for udev have finished
  2022-12-13  2:01 ` Moessbauer, Felix
@ 2022-12-13  8:44   ` Schaffner, Tobias
  2022-12-13 10:03     ` Roberto A. Foglietta
  0 siblings, 1 reply; 5+ messages in thread
From: Schaffner, Tobias @ 2022-12-13  8:44 UTC (permalink / raw)
  To: MOESSBAUER, FELIX JONATHAN, roberto.foglietta, isar-users

On 13.12.22 03:01, Moessbauer, Felix wrote:
> On Mon, 2022-12-12 at 20:23 +0000, roberto.foglietta@gmail.com wrote:
>> From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
>>
>> bugfix, expand last partition, wait for udev completion
>>
>> On some hardware the udev did not created the links to the disk
>> partitions
>> while this script is working thus it fails. This patch fixes that
>> cases.
>>
>> Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
>> ---
>>   .../expand-on-first-boot/files/expand-last-partition.sh         | 2
>> ++
>>   1 file changed, 2 insertions(+)
>>
>> 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 acfef8a..68e6698 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
>> @@ -9,6 +9,8 @@
>>   
>>   set -e
>>   
>> +udevadm settle
> 
> Hi Roberto,
> 
> thanks for this patch.
> I thought about something like that as well.
> If that reliably works, I vote to simply add this line instead of -
> again - re-writing this component.
> 
> Felix

Hi Felix, hi Roberto,

udev is started via systemd-udevd and this service might not be up
yet when the script runs.

Adding this line would only work reliably if we add
Requires=systemd-udevd and After=systemd-udevd to the
expand-on-first-boot.service

But adding this dependency might obviously increase the boot time.

Best,
Tobias

>> +
>>   ROOT_DEV="$(findmnt / -o source -n)"
>>   ROOT_DEV_NAME=${ROOT_DEV##*/}
>>   ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth
>> 1 -print -quit 2>/dev/null || true)
>> -- 
>> 2.34.1
>>
>>
>> https://16F0H.trk.elasticemail.com/tracking/unsubscribe?d=uQeFOzkk8plXVVZ2VnEcpnRSdsZJXyyuanyoKUe_hgUtRGm67z-BYxoD4dUduarMjrGtkXTgZjMZXUuF072gCX_KXuQap6OFDQDgYq9jqpv90
>>
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] In expand last partition wait for udev have finished
  2022-12-13  8:44   ` Schaffner, Tobias
@ 2022-12-13 10:03     ` Roberto A. Foglietta
  0 siblings, 0 replies; 5+ messages in thread
From: Roberto A. Foglietta @ 2022-12-13 10:03 UTC (permalink / raw)
  To: Schaffner, Tobias; +Cc: MOESSBAUER, FELIX JONATHAN, isar-users

[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]

On Tue, 13 Dec 2022 at 09:44, Schaffner, Tobias
<tobias.schaffner@siemens.com> wrote:
>
> Hi Felix, hi Roberto,
>
> udev is started via systemd-udevd and this service might not be up
> yet when the script runs.
>
> Adding this line would only work reliably if we add
> Requires=systemd-udevd and After=systemd-udevd to the
> expand-on-first-boot.service
>
> But adding this dependency might obviously increase the boot time.
>

Hi Tobias,

 I do not think that adding that dependency will increase the boot
time in general case but just changing the order of the operations.
However, in those hardware which the devices recognition is slow, then
the boot will slow down but probably are also those cases in which
the resize will fail. In fast hardware, I think that udevd is just
started before that script otherwise udevadm would have failed and the
script as well due to set -e. This because the systemd paralyse the
activities. At the moment, I am trying these changes on a virtual
machine and it is enough fast that the script with udevadm settle do
not fail nor slow down the boot in a noticeable way.

 I sent the patch v2 with this dependency. Also here in attachment.

 Thanks, R-

[-- Attachment #2: v2-0001-In-expand-last-partition-wait-for-udev-have-finis.patch --]
[-- Type: text/x-patch, Size: 2291 bytes --]

From b5e52d2b7f542b6ec3645ff59e43da9fdedb9a9f Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH v2] In expand last partition wait for udev have finished

bugfix, expand last partition, wait for udev completion

On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.

v2: as underlined by Tobias this script requires systemd-udevd.service and
it can safely runs only after that service has been started otherwise might
fail. This dependency will reorder the boot procedure but not slow down it
unless the hardware is slow to get mapped by udev but in that case resize
the last partition would have failed. Thus, no regression are expected.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh         | 2 ++
 .../expand-on-first-boot/files/expand-on-first-boot.service     | 2 ++
 2 files changed, 4 insertions(+)

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..4d55645 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
@@ -9,6 +9,8 @@
 
 set -e
 
+udevadm settle
+
 ROOT_DEV="$(findmnt / -o source -n)"
 ROOT_DEV_NAME=${ROOT_DEV##*/}
 ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
index fda5001..2c120c4 100644
--- a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
@@ -7,7 +7,9 @@
 Description=Expand last partition
 DefaultDependencies=no
 Conflicts=shutdown.target
+Requires=systemd-udevd.service
 After=systemd-remount-fs.service
+After=systemd-udevd.service
 Before=local-fs-pre.target shutdown.target
 ConditionPathIsReadWrite=/etc
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] In expand last partition wait for udev have finished
@ 2022-12-12 20:33 Roberto A. Foglietta
  0 siblings, 0 replies; 5+ messages in thread
From: Roberto A. Foglietta @ 2022-12-12 20:33 UTC (permalink / raw)
  To: isar-users; +Cc: joe_macdonald, Henning Schild

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

Hi all,

 this patch add a simple command at the beginning of the expand last
partition script

 udevadm settle

 this command connects with the running udev and waits until it has
finished its work.

 Why is this simple line supposed to solve the problem? My opinion -
an opinion because I do not have such hardware to test this patch - is
that some hardware is too slow dealing with some devices to let udev
complete his job before this script runs. This supposes that the udev
is running at that time. So you might need an extra check about it or
udev could even started at that time but later. Obviously, without
udev or something equivalent to populate /dev any operations with
devices is unfeasible.

 It has been sent with git send-email by elastic mail as usual and it
went into moderation, as usual.

 Best regards, R-

[-- Attachment #2: 0001-In-expand-last-partition-wait-for-udev-have-finished.patch --]
[-- Type: text/x-patch, Size: 1203 bytes --]

From 357f8d178a571ff9cdd8e8e6aa43a321d5ee888a Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH] In expand last partition wait for udev have finished

bugfix, expand last partition, wait for udev completion

On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh         | 2 ++
 1 file changed, 2 insertions(+)

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 acfef8a..68e6698 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
@@ -9,6 +9,8 @@
 
 set -e
 
+udevadm settle
+
 ROOT_DEV="$(findmnt / -o source -n)"
 ROOT_DEV_NAME=${ROOT_DEV##*/}
 ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-13 10:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 20:23 [PATCH] In expand last partition wait for udev have finished roberto.foglietta
2022-12-13  2:01 ` Moessbauer, Felix
2022-12-13  8:44   ` Schaffner, Tobias
2022-12-13 10:03     ` Roberto A. Foglietta
2022-12-12 20:33 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