mkosi icon indicating copy to clipboard operation
mkosi copied to clipboard

`DEFAULT_HOSTNAME=` in os-release is not set when `Hostname=` is set

Open septatrix opened this issue 1 year ago • 3 comments

mkosi commit the issue has been seen with

main

Used host distribution

Fedora 40

Used target distribution

Fedora 40

Linux kernel version used

6.8.7-300.fc40.x86_64

CPU architectures issue was seen on

x86_64

Unexpected behaviour you saw

On a usr/-only build the hostname reverted to "fedora" after losing a DHCP lease which assigned a hostname instead of the hostname set during image build by mkosi. See https://github.com/systemd/systemd/issues/32541

As there is only one level of transient hostname "storage" there is no way to get the original hostname back afterwards. Therefore the only fallback possible is to use the default hostname from os-release (or the one compiled during systemd build). mkosi should therefore also update that variable to ensure the expected behavior.

Used mkosi config

No response

mkosi output

No response

septatrix avatar May 01 '24 14:05 septatrix

Reading the linked issue I'm not sure setting the DEFAULT_HOSTNAME is something we should always do unconditionally, since it then would put the burden on people do remove that from the os-release file, if they don't want it and it doesn't seem like something that warrants an extra option. It might be something that's best left documented as is with a hint to use a script to change the os-release file.

behrmann avatar May 01 '24 15:05 behrmann

I see no scenario where people would have to remove that line. If people are already setting Hostname= they expect the machine to have a certain hostname. So if the hostname is reset after losing a DHCP lease it makes way more sense to have that set as the Fallback instead of whatever the distribution usually ships

septatrix avatar May 01 '24 18:05 septatrix

Turning this into an RFE as I don't think this is necessarily a bug

DaanDeMeyer avatar May 09 '24 07:05 DaanDeMeyer