[systemd-devel] How to factory reset?

Lennart Poettering lennart at poettering.net
Wed Apr 22 08:39:23 PDT 2015


On Fri, 13.03.15 01:16, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> On Tue, Mar 10, 2015 at 10:23:23PM +0100, Tobias Hunger wrote:
> > On Tue, Mar 10, 2015 at 9:33 PM, Tobias Hunger <tobias.hunger at gmail.com> wrote:
> > >> presets and machined ID are applied by PID 1, before it begins with
> > >> starting any units, hence *really* early on. Note though that actually
> > >> /etc/machine-id is used as flag for "is /etc empty". If the file
> > >> exists it is assumed that /etc is provisioned properly. If it is
> > >> missing PID 1 will generate the machiend id and apply presets.
> > >
> > > An OS installer could put the machine-id into /usr just fine (and so
> > > can I) and systemd could just get it from there if available before
> > > generating a new one.
> > >
> > > It would be nice if the machine-id did not change during to a factory
> > > reset: It is used in the logs and changing it will basically make
> > > historical log data much harder to analyze. IIRC networkd also uses it
> > > to generate persistent MAC addresses for containers and such.
> > >
> > > So far this seems to be the only critical piece of information that
> > > can not get restored via tmpfiles.d.
> > 
> > Thinking about this a bit longer: /usr does not seem like a good idea.
> > The machine-id is supposed to be unique and usr-images are meant to be
> > reused.
> > 
> > Maybe provide a kernel command line option to force the machine-id if
> > none is set yet?
> I think this could be an option.  We currently check
> /var/lib/dbus/machine-id, $container_uuid, and /sys/class/dmi/id/product_uuid.
> I think that the first should work for your use case, since you keep /var.
> But we also check some commandline option, this seems useful for some
> use cases.

I think /var/lib/dbus/machine-id is nothing to use here. It purely
exists for compat with upgrades from classic dbus1 systems, where we
should avoid inventing a new machine id, if the dbus one is fine.

I'd be fine with adding a kernel switch to make this configurable, as
Zbigniew suggested.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list