mkosi icon indicating copy to clipboard operation
mkosi copied to clipboard

Wrong hostname since #3922

Open septatrix opened this issue 3 months ago • 8 comments

mkosi commit the issue has been seen with

main

Used host distribution

Fedora 42

Used target distribution

Fedora 42

Linux kernel version used

6.16.10-200.fc42.x86_64

CPU architectures issue was seen on

x86_64

Unexpected behaviour you saw

Since #3922 my machines have the transient hostname fedora set instead of the one I configured using Hostname=. This is likely because the hostname is no longer propagated to the default initrd and thus not saved in DEFAULT_HOSTNAME= in /etc/os-release. I assume this needs an updated SettingScope though I am unsure which one to use

Used mkosi config


mkosi output


septatrix avatar Oct 14 '25 22:10 septatrix

It would be SettingScope.inherit but I'm unsure if it's the right behavior to have all subimages inherit the locale, root password, hostname and other firstboot settings.

DaanDeMeyer avatar Oct 15 '25 08:10 DaanDeMeyer

Hostname is unique in that regard as it is the only setting not actually handled by the firstboot service

septatrix avatar Oct 15 '25 09:10 septatrix

But the same worry still applies that propagating it into every subimage might not be applicable.

DaanDeMeyer avatar Oct 15 '25 09:10 DaanDeMeyer

Could also introduce a new settings scope but that seems like unnecessary complexity just for this setting

septatrix avatar Oct 15 '25 11:10 septatrix

I'm inclined to just say that if you want your initrd to have the same hostname then you'll have to define a custom initrd subimage and set it there.

DaanDeMeyer avatar Oct 15 '25 11:10 DaanDeMeyer

The problem are usr-only images where /etc/hostname is lost. In that case the hostname just gets set to "fedora" in the initrd (or whatever is set in the initrd's os-release) and not updated when transitioning to the proper rootfs

septatrix avatar Oct 15 '25 11:10 septatrix

I don't get the issue? If you add a custom initrd subimage and set Hostname= there it'll be included in the initrd as before.

DaanDeMeyer avatar Oct 15 '25 12:10 DaanDeMeyer

Yes sure that works, as would setting systemd.hostname= on the cmdline, however, this is very unintuitive for usr-only images and one more thing to stumble upon and figure out why it does not work if one does not find this discussion

septatrix avatar Oct 15 '25 15:10 septatrix