[PATCH v2] classes/image-postproc: Enable systemd units based on systemd presets

1 view
Skip to first unread message

alexander...@siemens.com

unread,
Sep 17, 2025, 4:24:56 AM (10 days ago) Sep 17
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, Alexander Heinisch
From: Alexander Heinisch <alexander...@siemens.com>

By default population of the presets is automatically done by systemd
on first-boot.

There were several issues with that:

1. The rootfs we get as a build artifact does not reflect the actual
system running in the field.

2. For setups without writeable /etc this fails. With that addition
it happens already at build time.

Note: Additional services are enabled only. Services already enabled
during the package installation won't be changed.

Opt-out: `ROOTFS_POSTPROCESS_COMMAND:remove = "image_postprocess_populate_systemd_preset"`

Signed-off-by: Alexander Heinisch <alexander...@siemens.com>
---
RECIPE-API-CHANGELOG.md | 18 ++++++++++++++++++
meta/classes/image-postproc-extension.bbclass | 5 +++++
2 files changed, 23 insertions(+)

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 92e7811c..6c48b823 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -741,3 +741,21 @@ By setting `MS_TPM_20_REF_DIR` in an optee-ftpm recipe, it is now possible to
use the new optee_ftpm code base from the OP-TEE project. That variable has to
point to a subdir in `WORKDIR` which contains the unpacked ms-tpm-20-ref source
code.
+
+### Populate systemd units based on presets during image postprocessing
+
+By default population of the presets is automatically done by systemd
+on first-boot.
+
+There were several issues with that:
+
+1. The rootfs we get as a build artifact does not reflect the actual
+system running in the field.
+
+2. For setups without writeable /etc this fails. With that addition
+it happens already at build time.
+
+**Note**: Additional services are enabled only. Services already enabled
+during the package installation won't be changed.
+
+Opt-out: `ROOTFS_POSTPROCESS_COMMAND:remove = "image_postprocess_populate_systemd_preset"`
diff --git a/meta/classes/image-postproc-extension.bbclass b/meta/classes/image-postproc-extension.bbclass
index 991bac4c..269b86c0 100644
--- a/meta/classes/image-postproc-extension.bbclass
+++ b/meta/classes/image-postproc-extension.bbclass
@@ -95,3 +95,8 @@ image_posprocess_disable_systemd_firstboot() {
fi
fi
}
+
+ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_populate_systemd_preset"
+image_postprocess_populate_systemd_preset() {
+ sudo chroot '${ROOTFSDIR}' systemctl preset-all --preset-mode="enable-only"
+}
--
2.39.5

MOESSBAUER, Felix

unread,
Sep 17, 2025, 4:51:38 AM (10 days ago) Sep 17
to Heinisch, Alexander, isar-...@googlegroups.com, Kiszka, Jan
On Wed, 2025-09-17 at 10:24 +0200, alexander...@siemens.com
wrote:
> From: Alexander Heinisch <alexander...@siemens.com>
>
> By default population of the presets is automatically done by systemd
> on first-boot.
>
> There were several issues with that:
>
> 1. The rootfs we get as a build artifact does not reflect the actual
> system running in the field.
>
> 2. For setups without writeable /etc this fails. With that addition
> it happens already at build time.
>
> Note: Additional services are enabled only. Services already enabled
> during the package installation won't be changed.
>
> Opt-out: `ROOTFS_POSTPROCESS_COMMAND:remove = "image_postprocess_populate_systemd_preset"`

Hi,

please make it a rootfs feature (e.g. populate-systemd-preset) and
enable it in the image.bbclass. Apart from that, the change is fine.

Best regards,
Felix
--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany

Reply all
Reply to author
Forward
0 new messages