Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: add patch to consider systemd.hostname= a static hostname #2

Closed
wants to merge 1 commit into from

Conversation

hnez
Copy link
Member

@hnez hnez commented Nov 15, 2022

We use the systemd.hostname= kernel commandline parameter to set a unique hostname from factory data via barebox.

The current semantics result in somewhat unexpected behaviour when doing so. Clean up the semantics of the systemd.hostname=` kernel parameter to make it more useful and predictable.

The previous semantics were:

  • systemd.hostname= takes precedence over /etc/hostname during boot, even though it is technically considered a transient hostname.
  • In systemd-hostnamed however /etc/hostname takes precedence over systemd.hostname= as it is considered transient again and the normal priorities (static over transient over default) are followed. This means if a new transient hostname is set, the hostname of the system will be sethostname()'d to the one in /etc/hostname (if present) or the new transient hostname.
  • If /etc/hostname does not exist, systemd-hostnamed does not report a static hostname via dbus to consumers like the NetworkManager dhcp client. In the case of NetworkManager this results in no hostname being set in DHCP requests.

The new semantics are:

  • systemd.hostname= is considered a static hostname during boot and in systemd-hostnamed and as such takes precedence over transient or default hostnames.
  • systemd.hostname= takes precedence over /etc/hostname.

@hnez hnez requested a review from jluebbe November 15, 2022 14:11
@jluebbe jluebbe requested review from michaelolbrich and removed request for jluebbe November 22, 2022 09:10
@hnez hnez force-pushed the lgo/systemd-hostname-static branch from a3d92af to ac0d17e Compare November 22, 2022 09:54
@hnez hnez changed the base branch from kirkstone to langdale November 22, 2022 09:55
@hnez
Copy link
Member Author

hnez commented Dec 1, 2022

Just to add some context on this PR and why it is not merged yet.
The patch was also sent upstream systemd/systemd#25158 and it does not look too likely that it will be merged.
We will likely put on our thinking cap again and think of other nice approaches how to set a static unique hostname on systems with read only root fs, like bind-mounting a config to /etc/hostname.

@hnez hnez force-pushed the lgo/systemd-hostname-static branch from ac0d17e to 24b1c05 Compare December 1, 2022 12:28
@hnez hnez closed this Feb 1, 2023
@hnez hnez deleted the lgo/systemd-hostname-static branch March 3, 2023 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants