2

Inspired by "FeeBSD KDE. Could not start d-bus. can you call qdbus?":

I am using FreeBSD/TrueOS/DragonFly BSD and have some software from Ports that when run complains about a missing /etc/machine-id file. I do not see any such file in /etc.

What is this file? Should I have it? How do I make it, if yes?

2
  • I think you should report the bug, this needs to be fixed.
    – thecarpy
    Commented Oct 4, 2017 at 13:01
  • I think the OpenBSD port warns you to create that file when you install whatever it is that wants that
    – thrig
    Commented Oct 4, 2017 at 14:51

2 Answers 2

3

The /etc/machine-id file is not a standard part of any BSD. It is a systemd-ism that has begun to leak into softwares that are in Ports. Usually, the absence of this file is benign, because (so far) there are still older non-systemd-specific mechanisms that most such softwares fall back upon.

Softwares look here for a machine ID, a 128-bit number that uniquely identifies this installation of the operating system, consistently across system restarts and (mostly) independent from hardware changes.

One such software is D-Bus. It too has a notion of a machine ID. Historically, on FreeBSD/TrueOS/DragonFly BSD this has been found in the /var/db/dbus/machine-id file. Whilst D-Bus has in recent years been altered to look at /etc/machine-id for preference, it should still fall back to looking at the older file.

The operating system does not come with or create such a file out of the box. But you can of course make one.

  • Obtain the and install the nosh toolset and run the setup-machine-id tool as the superuser. This will make /etc/machine-id, reading an existing ID out of the D-Bus files if it can. (Use version 1.36 of the toolkit or later to avoid a bug here.)

    You do not need to run this every bootstrap, as once created the /etc/machine-id file just sits there for the lifetime of your system; but if you wire it into your system bootstrap, it will also ensure that you have a /run/machine-id file and a kern.hostuuid kernel variable all containing this same ID. It also uses/updates /etc/hostid.

  • Move the D-Bus file into the systemd location and then symbolically link the former to the latter:
    mv -i /var/db/dbus/machine-id /etc/ && ln -s /etc/machine-id /var/db/dbus/
    Note that making the symbolic link in the other direction breaks any softwares that expect /etc/machine-id to be usable before /var is mounted. Again, these are systemd semantics for this file that you might find creeping into softwares that are in Ports.
  • Just make one by hand with a new machine ID generated by something like uuidgen (whose output you will have to massage) or dbus-uuidgen. If you already have D-Bus installed, and a D-Bus machine ID file present, this is an inferior approach as it will result in softwares that (first) look in the systemd location seeing a different machine ID to softwares that (first) look in the D-Bus location.

Yes, strictly speaking this should be /usr/local/etc/machine-id per BSD conventions, but remember that we are talking about softwares that are looking at /etc/machine-id in the first place because they are erroneously systemd-specific. They will not have been patched to look at a non-systemd location for this file, either.

Further reading

0

On FreeBDS 12 there is no nosh package. Instead, just run dbus-uuidgen --ensure and copy the generated id: cp /var/lib/dbus/machine-id /etc/machine-id. Then startkde starts plasma kde.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .