Skip to contentSkip to conversation

systemd-systemctl: Create machine-id with "uninitialized" text in it

PATCH In review Marek Vasut 2 participants 7 messages Feb 27, 2023 – Mar 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd-systemctl: Create machine-id with "uninitialized" text in it

Instead of creating empty /etc/machine-id file using touch, write text "uninitialized" into it. Systemd requires "uninitialized" in the /etc/machine-id file to trigger systemd-firstboot .

---
Cc: Alexandre Belloni <[email protected]>
Cc: Armin Kuster <[email protected]>
Cc: Bob Henz <[email protected]>
Cc: Kristian Klausen <[email protected]>
Cc: Nick Potenski <[email protected]>
Cc: Richard Purdie <[email protected]>

---
 meta/recipes-core/systemd/systemd-systemctl/systemctl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-systemctl/systemctl +1 -1
index cddae75a06..45b29671ee 100755
@@ -302,7 +302,7 @@ def preset_all(root):
     # For the stateless configuration, where /etc is generated at runtime
     # (for example on a tmpfs), this script shouldn't run at all and we
     # allow systemd to completely populate /etc.
-    (root / SYSCONFDIR / "machine-id").touch()
+    (root / SYSCONFDIR / "machine-id").write_text("uninitialized")
 
 
 def main():
Signature · 1 line
2.39.2
#1 lore raw

This patch is forcing systemd to do preset-all at boot time (first boot) in a function that simulates 'preset-all' at rootfs time.

If we look at the comments above the changed line, we can see that the /etc/machine-id file was deliberately created as empty, for the purpose of making systemd not treat the system as first boot. """
    # If we populate the systemd links we also create /etc/machine-id, which

    # allows systemd to boot with the filesystem read-only before generating
    # a real value and then committing it back.
    #
    # For the stateless configuration, where /etc is generated at runtime
    # (for example on a tmpfs), this script shouldn't run at all and we
    # allow systemd to completely populate /etc.
"""

I'm going to send out a patch to revert this patch.

Regards,
Qi

Quoted 38 lines · Marek Vasut

Instead of creating empty /etc/machine-id file using touch, write text "uninitialized" into it. Systemd requires "uninitialized" in the /etc/machine-id file to trigger systemd-firstboot .

---
Cc: Alexandre Belloni <[email protected]>
Cc: Armin Kuster <[email protected]>
Cc: Bob Henz <[email protected]>
Cc: Kristian Klausen <[email protected]>
Cc: Nick Potenski <[email protected]>
Cc: Richard Purdie <[email protected]>

---
  meta/recipes-core/systemd/systemd-systemctl/systemctl | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/systemd/systemd-systemctl/systemctl +1 -2
index cddae75a06..45b29671ee 100755
@@ -302,7 +302,7 @@ def preset_all(root):
      # For the stateless configuration, where /etc is generated at runtime
      # (for example on a tmpfs), this script shouldn't run at all and we
      # allow systemd to completely populate /etc.
-    (root / SYSCONFDIR / "machine-id").touch()
+    (root / SYSCONFDIR / "machine-id").write_text("uninitialized")
 
 
  def main():
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#177804): https://lists.openembedded.org/g/openembedded-core/message/177804
Mute This Topic: https://lists.openembedded.org/mt/97273986/7304865
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

On 3/15/23 11:10, ChenQi wrote:

Hi,

Quoted 15 lines

This patch is forcing systemd to do preset-all at boot time (first boot) in a function that simulates 'preset-all' at rootfs time.

If we look at the comments above the changed line, we can see that the /etc/machine-id file was deliberately created as empty, for the purpose of making systemd not treat the system as first boot. """
    # If we populate the systemd links we also create /etc/machine-id,
which

     # allows systemd to boot with the filesystem read-only before 
generating
     # a real value and then committing it back.
     #
     # For the stateless configuration, where /etc is generated at runtime
     # (for example on a tmpfs), this script shouldn't run at all and we
     # allow systemd to completely populate /etc.
"""
Quoted 1 line

I'm going to send out a patch to revert this patch.

Hmmm, the problem is that without this patch, systemd firstboot does not work and I would like to use that. How can we accommodate both options, i.e. no breakage for you and working systemd-firstboot ?

#3 lore raw

Hi Marek,

I used the following line in local.conf and the firstboot worked:
IMAGE_PREPROCESS_COMMAND:remove = "systemd_preset_all;"

Regards,
Qi

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Friday, March 17, 2023 7:54 PM
To: Chen, Qi <[email protected]>; [email protected]
Cc: Alexandre Belloni <[email protected]>; Armin Kuster <[email protected]>; Bob Henz <[email protected]>; Kristian Klausen <[email protected]>; Nick Potenski <[email protected]>; Richard Purdie <[email protected]>
Subject: Re: [OE-core] [PATCH] systemd-systemctl: Create machine-id with "uninitialized" text in it

On 3/15/23 11:10, ChenQi wrote:

Hi,

Quoted 20 lines

This patch is forcing systemd to do preset-all at boot time (first boot) in a function that simulates 'preset-all' at rootfs time.

If we look at the comments above the changed line, we can see that the /etc/machine-id file was deliberately created as empty, for the purpose of making systemd not treat the system as first boot. """
    # If we populate the systemd links we also create
/etc/machine-id, which

     # allows systemd to boot with the filesystem read-only before 
generating
     # a real value and then committing it back.
     #
     # For the stateless configuration, where /etc is generated at 
runtime
     # (for example on a tmpfs), this script shouldn't run at all and 
we
     # allow systemd to completely populate /etc.
"""
Quoted 1 line

I'm going to send out a patch to revert this patch.

Hmmm, the problem is that without this patch, systemd firstboot does not work and I would like to use that. How can we accommodate both options, i.e. no breakage for you and working systemd-firstboot ?

#4 lore raw
Quoted 1 line · Qi

Hi Marek,

Hi,

sorry for the delay

Quoted 2 lines

I used the following line in local.conf and the firstboot worked:
IMAGE_PREPROCESS_COMMAND:remove = "systemd_preset_all;"

But doesn't that also inhibit the rootfs-time preset-all ? I would like to keep that, I just need for the systemd firstboot units to run on first boot to do first boot system setup things, which they won't without the 'uninitialized' in /etc/machine-id .

Quoted 34 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Friday, March 17, 2023 7:54 PM
To: Chen, Qi <[email protected]>; [email protected]
Cc: Alexandre Belloni <[email protected]>; Armin Kuster <[email protected]>; Bob Henz <[email protected]>; Kristian Klausen <[email protected]>; Nick Potenski <[email protected]>; Richard Purdie <[email protected]>
Subject: Re: [OE-core] [PATCH] systemd-systemctl: Create machine-id with "uninitialized" text in it

On 3/15/23 11:10, ChenQi wrote:

Hi,

Quoted 20 lines

This patch is forcing systemd to do preset-all at boot time (first boot) in a function that simulates 'preset-all' at rootfs time.

If we look at the comments above the changed line, we can see that the /etc/machine-id file was deliberately created as empty, for the purpose of making systemd not treat the system as first boot. """
    # If we populate the systemd links we also create
/etc/machine-id, which

      # allows systemd to boot with the filesystem read-only before
generating
      # a real value and then committing it back.
      #
      # For the stateless configuration, where /etc is generated at
runtime
      # (for example on a tmpfs), this script shouldn't run at all and
we
      # allow systemd to completely populate /etc.
"""
Quoted 1 line

I'm going to send out a patch to revert this patch.

Hmmm, the problem is that without this patch, systemd firstboot does not work and I would like to use that. How can we accommodate both options, i.e. no breakage for you and working systemd-firstboot ?

#5 lore raw
Quoted 11 lines · Marek Vasut
Quoted 1 line · Qi

Hi Marek,

Hi,

sorry for the delay

Quoted 2 lines

I used the following line in local.conf and the firstboot worked:
IMAGE_PREPROCESS_COMMAND:remove = "systemd_preset_all;"

But doesn't that also inhibit the rootfs-time preset-all ? I would like to keep that, I just need for the systemd firstboot units to run on first boot to do first boot system setup things, which they won't without the 'uninitialized' in /etc/machine-id .

1) Lacking of /etc/machine-id file also triggers firstboot.

2) systemd firstboot does 'preset-all'. If you enable firstboot, then you don't need rootfs-time preset-all.

Regards,

Qi

Quoted 35 lines
Quoted 35 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Friday, March 17, 2023 7:54 PM
To: Chen, Qi <[email protected]>; [email protected]
Cc: Alexandre Belloni <[email protected]>; Armin Kuster <[email protected]>; Bob Henz <[email protected]>; Kristian Klausen <[email protected]>; Nick Potenski <[email protected]>; Richard Purdie <[email protected]>
Subject: Re: [OE-core] [PATCH] systemd-systemctl: Create machine-id with "uninitialized" text in it

On 3/15/23 11:10, ChenQi wrote:

Hi,

Quoted 20 lines

This patch is forcing systemd to do preset-all at boot time (first boot) in a function that simulates 'preset-all' at rootfs time.

If we look at the comments above the changed line, we can see that the /etc/machine-id file was deliberately created as empty, for the purpose of making systemd not treat the system as first boot. """
      # If we populate the systemd links we also create /etc/machine-id, which

      # allows systemd to boot with the filesystem read-only before
generating
      # a real value and then committing it back.
      #
      # For the stateless configuration, where /etc is generated at
runtime
      # (for example on a tmpfs), this script shouldn't run at all and
we
      # allow systemd to completely populate /etc.
"""
Quoted 1 line

I'm going to send out a patch to revert this patch.

Hmmm, the problem is that without this patch, systemd firstboot does not work and I would like to use that. How can we accommodate both options, i.e. no breakage for you and working systemd-firstboot ?

#6 lore raw
Quoted 11 lines · ChenQi
Quoted 10 lines · Marek Vasut
Quoted 1 line · Qi

Hi Marek,

Hi,

sorry for the delay

Quoted 2 lines

I used the following line in local.conf and the firstboot worked:
IMAGE_PREPROCESS_COMMAND:remove = "systemd_preset_all;"

Quoted 6 lines
Quoted 1 line

But doesn't that also inhibit the rootfs-time preset-all ? I would like to keep that, I just need for the systemd firstboot units to run on first boot to do first boot system setup things, which they won't without the 'uninitialized' in /etc/machine-id .

1) Lacking of /etc/machine-id file also triggers firstboot.

2) systemd firstboot does 'preset-all'. If you enable firstboot, then you don't need rootfs-time preset-all.

All right, thank you. Please go ahead with the revert.

But can you please document this IMAGE_PREPROCESS_COMMAND:remove = "systemd_preset_all;" somewhere at least in the commit message, so others who run into non-working firstboot won't have to struggle with it ? Maybe even add this into the comment in 'systemctl' script ?