[systemd-devel] systemd and hostnamed (and nss-myhostname) - an alternative path

Lennart Poettering lennart at poettering.net
Sat Jul 30 07:29:24 PDT 2011


On Fri, 29.07.11 14:20, JB (jerome at silentdome.com) wrote:

> After browsing through git I think I may have a viable solution to
> the main issue of not being able to change that hostname before it
> is set at boot time.
> 
> Move the logic from hostname-setup.c into hostnamed a hostnamed

Sorry, I am not interested in this. We want the hostname initialized to
some value very early at boot, so that userspace can rely that the
hostname is set at all times, even if that is not the final host name.

In most cases it will be the final name, but if in many cases (like the
hostname from DHCP usecase) it isn't then this is fine.

In your case I'd just recommend removing any configuration of the static
hostname entirely. (i.e. remove /etc/hostname and friends). systemd will
then just initialize the hostname to "localhost". Then, when you know
your "final" hostname, just set it with dbus-send for example.

> Make a hostnamed --setfromfile option and use in in a
> set-hostname.service file.

But why?

> That would allow a user (me) to use ExecStartPre or to create
> another unit and set a Before=set-hostname.service.  In this unit I
> can change the /etc/hostname file before the hostname is set.

This is all designed so that writes to /etc are never necessary,
(i.e. that dir can be mounted read-only). So, when you figure out your
network-based hostname, then set the transient hostname to it, not the
static one.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list