[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Generating new IDs for cloning



On Thu, Aug 08, 2019 at 06:16:31PM +0200, Marc Haber wrote:
On Thu, 8 Aug 2019 11:50:07 -0400, Michael Stone <mstone@debian.org>
wrote:
On Thu, Aug 08, 2019 at 11:41:52AM -0400, Marvin Renich wrote:
* Michael Stone <mstone@debian.org> [190808 08:42]:
On Thu, Aug 08, 2019 at 08:37:16AM -0400, Marvin Renich wrote:
> Does anyone know what applications use this file for what purpose?  Is
> this a systemd-ism?

man machine-id

The man page says what it is (a unique, random ID for the machine) and
how to initialize it, but says nothing about why it exists. What
applications expect it to be there?

From the man page:

      The machine ID does not change based on local or network configuration
      or when hardware is replaced. Due to this and its greater length, it
      is a more useful replacement for the gethostid(3) call that POSIX
      specifies.
[...]
      When a machine is booted with systemd(1) the ID of the machine will be
      established. If systemd.machine_id= or --machine-id= options (see
      first section) are specified, this value will be used. Otherwise, the
      value in /etc/machine-id will be used. If this file is empty or
      missing, systemd will attempt to use the D-Bus machine ID from
      /var/lib/dbus/machine-id, the value of the kernel command line option
      container_uuid, the KVM DMI product_uuid (on KVM systems), and finally
      a randomly generated UUID.

What Marvin says: That doesn't explain anything.

I guess I need you to say what's confusing. It's an ID that doesn't change. You can look up gethostid to get a little more background. If you need an ID for a host it's useful. If you don't need an ID for a host, then it's not so useful. Once upon a time (gethostid(3) alludes to this) it was thought that an IPv4 would be a good unique ID, but with the rise of NAT it quickly became useless and hence the search for an alternative. The second paragraph is pretty clear that machine-id is one of a number of possible seeds for systemd to set the machine's ID. The rest of the file talks about how applications can use an API to get a constant ID based on the machine ID and that applications should generally not use the contents of the machine-id file directly. So to find out what applications use the file you'd have to look for references to the various APIs (such as sd_id128_get_machine_app_specific or dbus-uuidgen) which themselves use /etc/machine-id


Reply to: