<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="setup-machine-id">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>setup-machine-id</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv><refname>setup-machine-id</refname><refpurpose>set up the machine ID</refpurpose></refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>setup-machine-id</command>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>setup-machine-id</command> stores a machine ID in various areas of volatile and non-volatile storage, creating a new machine ID if one has not already been created, correcting faulty machine IDs generated by some erroneous softwares, and creating storage files if they are missing.
See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>7</manvolnum></citerefentry> for where the volatile and non-volatile storage areas are, and the corrections for faulty machine IDs.
</para>

<para>
<command>setup-machine-id</command> also creates a host ID (again, see <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>7</manvolnum></citerefentry>) from the machine ID and stores it in various areas of storage, creating them if they are missing.
</para>

<para>
On operating systems where bind mounting is available, if <command>setup-machine-id</command> cannot write to the <filename>/etc/machine-id</filename> or the <filename>/etc/hostid</filename> files, it bind mounts the <filename>/run/machine-id</filename> or the <filename>/run/hostid</filename> files over them.
This will be the case where the root filesystem is mounted read-only at the point in the operating system bootstrap where <command>setup-machine-id</command> is run.
</para>

<refsection id="FALLBACKS" xreflabel="FALLBACKS"><title>Fallbacks</title>

<para>
<command>setup-machine-id</command> falls back to creating or restoring machine IDs as follows:
</para>

<orderedlist>
<listitem><para>
It will attempt to read the UUID from volatile storage and use that.
Thus, if the file <filename>/etc/machine-id</filename> is deleted but the system is not restarted, <command>setup-machine-id</command> can restore the existing machine ID from volatile storage.
</para></listitem>
<listitem><para>
It will attempt to read the UUID from various older locations, such as the D-Bus machine ID files and (on the BSDs) the <filename>/etc/hostid</filename> and <filename>/usr/local/etc/machine-id</filename> files.
Thus, if the file <filename>/etc/machine-id</filename> has not yet been created but the system has machine IDs from older mechanisms, <command>setup-machine-id</command> will attempt to retain the machine IDs from those mechanisms.
</para></listitem>
<listitem><para>
If it detects that it is running in a container/jail, it will use the value of the <envar>container_uuid</envar> environment variable, if it is correctly formatted.
This environment variable is a convention and is set by various jailer and container management utilities.
</para></listitem>
<listitem><para>
As a final fallback, it will create a UUID using the <citerefentry><refentrytitle>uuid_create</refentrytitle><manvolnum>3</manvolnum></citerefentry> or the <citerefentry><refentrytitle>uuid_generate</refentrytitle><manvolnum>3</manvolnum></citerefentry> library function.
</para><caution>
On FreeBSD, UUID generation with these library functions still employs, and thus reveals, MAC address information.
</caution></listitem>
</orderedlist>

<note>
Prior to version 1.40 of the toolset, <command>setup-machine-id</command> would attempt to read the SMBIOS product ID and use that as a fallback mechanism, for compatibility with what FreeBSD had done since 2007.
This made machine IDs in practice constant and correlatable even when an administrator had explicitly wiped them.
The privacy problems that this entailed far outweighed what little utility it had, and this has been removed.
</note>

</refsection>

</refsection>

<refsection id="COMPATIBILITY" xreflabel="COMPATIBILITY">
<title>Compatibility</title>

<para>
Not all other softwares support it, but <command>setup-machine-id</command> allows the <filename>/etc/machine-id</filename> file to contain further lines beyond the first one with the ID, which it will ignore when reading.
</para>

</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
