I searched my question and none of them answered me: Is machine-id as unique as mainboard UUID (fetched by "get csproduct UUID" command on windows)? And is enough reliable to bind a license on machine-id beside mac address? Or what is uuid on *nix system that can be used for licensing?
Asked
Active
Viewed 1.5k times
2 Answers
11
Yes, nowadays.
This is covered in the systemd manual. The value in /etc/machine-id was originally not a valid UUID, because the systemd people did not originally write correct code for generating a version 4 UUID. But this has since been fixed.
If you bind a licence to the machine ID, be aware that it can change …
- … if someone deletes
/etc/machine-idand it gets re-created at next bootstrap; - … if
/etc(usually on the root volume in practice) is not mounted read-write at bootstrap,/etc/machine-idis invalid or missing, and/etccannot be later re-mounted read-write allowing/etc/machine-idto be written; - … if the disc volume containing
/etcis replaced with another, different, disc volume whilst the operating system is not running or someone changes the machine-id on the disc volume with a tool such assystemd-firstboot; - … if the system is what the systemd people call "stateless" and (effectively, it being slightly more complex than this)
/etc/machine-idgets re-created at every bootstrap; - … inside containers on the machine.
But it, intentionally, does not change …
- … if the mainboard, processor, or NIC is replaced;
- … if the MAC addresses of NICs are changed;
- … if the root volume (more specifically, the volume containing
/etc) is imaged onto a replacement disc with something likeddorpax; - … during system runtime (unless the system administrator deliberately mucks around with it);
- …from one bootstrap to the next if
/etc/machine-idis valid, non-empty, and writable the first time around.
portability notes
- Don't use
/var/lib/dbus/machine-idin preference to/etc/machine-id.- The original Desktop Bus file which begat
/etc/machine-idis unfortunately not in a fixed location that is portable across operating systems. On some systems one finds it at/var/lib/dbus/machine-id; on others at/var/db/dbus/machine-id. - Sometime around 2013, D-Bus was modified to make use of
/etc/machine-idif it exists, superseding the file in/var, whereever it is. - In 2015, the Debian/Ubuntu people made the D-Bus file in
/vardefault to being a symbolic link to/etc/machine-id, in any case.
- The original Desktop Bus file which begat
/etc/machine-idis not limited to only being available in the bootstrap process after/varis mounted or after network interfaces are brought up.- Although vanilla FreeBSD/TrueOS, NetBSD, and OpenBSD do not provide a
/etc/machine-id, the nosh toolset provides portable tools (that are also usable on Linux) for creating it that also know of the BSD-specific places that the BSDs expect such IDs and keep the twain consistent.
Further reading
- Lennart Poettering et al..
machine-id. systemd manual pages. Freedesktop.org. - Jonathan de Boyne Pollard (2019).
machine-id. nosh Guide. JdeBP's Softwares. - Jonathan de Boyne Pollard (2017).
/etc/machine-id. Gazetteer. nosh Guide. JdeBP's Softwares. - How dbus calculates machine id?
- Why is my systemd journal not persistent across reboots?
- It is OK to change /etc/machine-id?
- Why are my cloned linux VMs fighting for the same IP
JdeBP
- 66,967
- 12
- 159
- 343
-
-
-
What do you mean by *imaged onto a replacement disc with something like [...] pax*? Are you talking of the POSIX `pax` (portable archiver) command? – Stéphane Chazelas Mar 20 '19 at 16:15
-
Something I ran into the other day: cloning a VM means the clone gets the same machine-id. And what makes matters worse, systemd uses it as the DHCP client identifier which means the clone will get the same IP address as the original. – Stéphane Chazelas Mar 20 '19 at 16:17
-
You should enjoy the DESCRIPTION and EXAMPLE USERS sections from the new `machine-id` manual page that I just put into the further reading. (-: – JdeBP Mar 21 '19 at 00:58
3
From a quick Google search:
- /etc/machine-id should be unique, and only change if the machine is reinstalled, but is provided by systemd, which many systems don't have
- /var/lib/dbus/machine-id should be unique, and should be much more widely available. The docs say it can change if the hardware configuration changes, but in practice I think it only changes if the machine is reinstalled
- you could use system-uuid, but you need to be root, and it will change if the motherboard changes
/var/lib/dbus/machine-id seems like the best method for most situations.
Further reading:
Mikel
- 56,387
- 13
- 130
- 149
-
Which one of them may be useful for licensing? And how to get mainboard UUID on linux? – user4271704 Sep 30 '17 at 16:52