[v3] classes/image-postproc-extension: Remove /etc/machine-id

Message ID 20220420130044.668017-1-Quirin.Gylstorff@siemens.com
State Accepted, archived
Headers show
Series [v3] classes/image-postproc-extension: Remove /etc/machine-id | expand

Commit Message

Quirin Gylstorff April 20, 2022, 5 a.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

In a read-only system the machine id should be deleted or
set to `unitialized\n`[1]. 

Systemd will generate a new machine-id during the first boot.
In the case of a read-only root file system Systemd generates a mount point with
the machine id. If an overlay for /etc is used this creates a mount conflict.
To avoid the conflict between the overlay filesystem and systemd /etc/machine-id
mount point deleted the file /etc/machine-id.


This partly reverts 98d6a72d3064. The man page[2] was updated for Debian Bullseye to
allow a missing machine id. For Debian Bullseye it reads:

```
For operating system images which are created once and used on multiple machines,
for example for containers or in the cloud, /etc/machine-id should be either missing
or an empty file in the generic file system image
```

[1]: https://systemd.io/BUILDING_IMAGES/
[2]: https://manpages.debian.org/bullseye/systemd/machine-id.5.en.html

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---

Changes V2:
 - add information about revert of 98d6a72d3064
 Changes V3:
 - Fix From:

 meta/classes/image-postproc-extension.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anton Mikanovich May 14, 2022, 6:04 a.m. UTC | #1
20.04.2022 16:00, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>
> In a read-only system the machine id should be deleted or
> set to `unitialized\n`[1].
>
> Systemd will generate a new machine-id during the first boot.
> In the case of a read-only root file system Systemd generates a mount point with
> the machine id. If an overlay for /etc is used this creates a mount conflict.
> To avoid the conflict between the overlay filesystem and systemd /etc/machine-id
> mount point deleted the file /etc/machine-id.
>
>
> This partly reverts 98d6a72d3064. The man page[2] was updated for Debian Bullseye to
> allow a missing machine id. For Debian Bullseye it reads:
>
> ```
> For operating system images which are created once and used on multiple machines,
> for example for containers or in the cloud, /etc/machine-id should be either missing
> or an empty file in the generic file system image
> ```
>
> [1]: https://systemd.io/BUILDING_IMAGES/
> [2]: https://manpages.debian.org/bullseye/systemd/machine-id.5.en.html
>
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Applied to next, thanks.

Patch

diff --git a/meta/classes/image-postproc-extension.bbclass b/meta/classes/image-postproc-extension.bbclass
index ca520273..0c412c0d 100644
--- a/meta/classes/image-postproc-extension.bbclass
+++ b/meta/classes/image-postproc-extension.bbclass
@@ -57,7 +57,7 @@  ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_machine_id"
 image_postprocess_machine_id() {
     # systemd(1) takes care of recreating the machine-id on first boot
     sudo rm -f '${IMAGE_ROOTFS}/var/lib/dbus/machine-id'
-    sudo install -m 644 '/dev/null' '${IMAGE_ROOTFS}/etc/machine-id'
+    sudo rm -f '${IMAGE_ROOTFS}/etc/machine-id'
 }
 
 ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_sshd_key_regen"