| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="systemd-machine-id-setup" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>systemd-machine-id-setup</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>systemd-machine-id-setup</refentrytitle> |
| 16 |
<manvolnum>1</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>systemd-machine-id-setup</refname> |
| 21 |
<refpurpose>Initialize the machine ID in /etc/machine-id</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<cmdsynopsis> |
| 26 |
<command>systemd-machine-id-setup</command> |
| 27 |
</cmdsynopsis> |
| 28 |
</refsynopsisdiv> |
| 29 |
|
| 30 |
<refsect1> |
| 31 |
<title>Description</title> |
| 32 |
|
| 33 |
<para><command>systemd-machine-id-setup</command> may be used by |
| 34 |
system installer tools to initialize the machine ID stored in |
| 35 |
<filename>/etc/machine-id</filename> at install time, with a |
| 36 |
provisioned or randomly generated ID. See |
| 37 |
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 38 |
for more information about this file.</para> |
| 39 |
|
| 40 |
<para>If the tool is invoked without the <option>--commit</option> |
| 41 |
switch, <filename>/etc/machine-id</filename> is initialized with a |
| 42 |
valid, new machine ID if it is missing or empty. The new machine |
| 43 |
ID will be acquired in the following fashion:</para> |
| 44 |
|
| 45 |
<orderedlist> |
| 46 |
<listitem><para>If a valid machine ID is stored in <filename>/run/machine-id</filename>, the machine ID |
| 47 |
is copied and used to initialize the machine ID in <filename>/etc/machine-id</filename>. This step is |
| 48 |
skipped if <option>--root=</option> is specified or running in a chroot environment.</para></listitem> |
| 49 |
|
| 50 |
<listitem><para>If a valid D-Bus machine ID is already configured for the system, the D-Bus machine ID |
| 51 |
is copied and used to initialize the machine ID in <filename>/etc/machine-id</filename>. |
| 52 |
</para></listitem> |
| 53 |
|
| 54 |
<listitem><para>If a valid machine ID is provided through <option>system.machine_id</option> credential, |
| 55 |
the machine ID is copied and used to initialize the machine ID in <filename>/etc/machine-id</filename>. |
| 56 |
This step is skipped if <option>--root=</option> is specified or running in a chroot environment. |
| 57 |
</para></listitem> |
| 58 |
|
| 59 |
<listitem><para>If run inside a KVM virtual machine and a UUID is configured (via the |
| 60 |
<option>-uuid</option> option), this UUID is used to initialize the machine ID. The caller must ensure |
| 61 |
that the UUID passed is sufficiently unique and is different for every booted instance of the VM. This |
| 62 |
step is skipped if <option>--root=</option> is specified or running in a chroot environment. |
| 63 |
</para></listitem> |
| 64 |
|
| 65 |
<listitem><para>Similarly, if run inside a Linux container environment and a UUID is configured for the |
| 66 |
container, this is used to initialize the machine ID. For details, see the documentation of the <ulink |
| 67 |
url="https://systemd.io/CONTAINER_INTERFACE">Container Interface</ulink>. This step is skipped if |
| 68 |
<option>--root=</option> is specified or running in a chroot environment.</para></listitem> |
| 69 |
|
| 70 |
<listitem><para>Otherwise, a new ID is randomly generated.</para></listitem> |
| 71 |
</orderedlist> |
| 72 |
|
| 73 |
<para>The <option>--commit</option> switch may be used to commit a |
| 74 |
transient machined ID to disk, making it persistent. For details, |
| 75 |
see below.</para> |
| 76 |
|
| 77 |
<para>Use |
| 78 |
<citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 79 |
to initialize the machine ID on mounted (but not booted) system |
| 80 |
images.</para> |
| 81 |
|
| 82 |
</refsect1> |
| 83 |
|
| 84 |
<refsect1> |
| 85 |
<title>Options</title> |
| 86 |
|
| 87 |
<para>The following options are understood:</para> |
| 88 |
|
| 89 |
<variablelist> |
| 90 |
|
| 91 |
<varlistentry> |
| 92 |
<term><option>--root=<replaceable>path</replaceable></option></term> |
| 93 |
<listitem><para>Takes a directory path as argument. All paths operated on will be prefixed with the |
| 94 |
given alternate <replaceable>root</replaceable> path, including the path for |
| 95 |
<filename>/etc/machine-id</filename> itself.</para> |
| 96 |
|
| 97 |
<xi:include href="version-info.xml" xpointer="v212"/></listitem> |
| 98 |
</varlistentry> |
| 99 |
|
| 100 |
<varlistentry> |
| 101 |
<term><option>--image=<replaceable>path</replaceable></option></term> |
| 102 |
<listitem><para>Takes a path to a device node or regular file as argument. This is similar to |
| 103 |
<option>--root=</option> as described above, but operates on a disk image instead of a directory |
| 104 |
tree.</para> |
| 105 |
|
| 106 |
<xi:include href="version-info.xml" xpointer="v249"/></listitem> |
| 107 |
</varlistentry> |
| 108 |
|
| 109 |
<xi:include href="standard-options.xml" xpointer="image-policy-open" /> |
| 110 |
|
| 111 |
<varlistentry> |
| 112 |
<term><option>--commit</option></term> |
| 113 |
<listitem><para>Commit a transient machine ID to disk. This |
| 114 |
command may be used to convert a transient machine ID into a |
| 115 |
persistent one. A transient machine ID file is one that was |
| 116 |
bind mounted from a memory file system (usually |
| 117 |
<literal>tmpfs</literal>) to |
| 118 |
<filename>/etc/machine-id</filename> during the early phase of |
| 119 |
the boot process. This may happen because |
| 120 |
<filename>/etc/</filename> is initially read-only and was |
| 121 |
missing a valid machine ID file at that point.</para> |
| 122 |
|
| 123 |
<para>This command will execute no operation if |
| 124 |
<filename>/etc/machine-id</filename> is not mounted from a |
| 125 |
memory file system, or if <filename>/etc/</filename> is |
| 126 |
read-only. The command will write the current transient |
| 127 |
machine ID to disk and unmount the |
| 128 |
<filename>/etc/machine-id</filename> mount point in a |
| 129 |
race-free manner to ensure that this file is always valid and |
| 130 |
accessible for other processes.</para> |
| 131 |
|
| 132 |
<para>This command is primarily used by the |
| 133 |
<citerefentry><refentrytitle>systemd-machine-id-commit.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 134 |
early boot service.</para> |
| 135 |
|
| 136 |
<xi:include href="version-info.xml" xpointer="v227"/></listitem> |
| 137 |
</varlistentry> |
| 138 |
|
| 139 |
<varlistentry> |
| 140 |
<term><option>--print</option></term> |
| 141 |
|
| 142 |
<listitem><para>Print the machine ID generated or committed after the operation is complete.</para> |
| 143 |
|
| 144 |
<xi:include href="version-info.xml" xpointer="v231"/></listitem> |
| 145 |
</varlistentry> |
| 146 |
|
| 147 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 148 |
<xi:include href="standard-options.xml" xpointer="version" /> |
| 149 |
</variablelist> |
| 150 |
|
| 151 |
</refsect1> |
| 152 |
|
| 153 |
<refsect1> |
| 154 |
<title>Exit status</title> |
| 155 |
|
| 156 |
<para>On success, 0 is returned, a non-zero failure code |
| 157 |
otherwise.</para> |
| 158 |
</refsect1> |
| 159 |
|
| 160 |
<refsect1> |
| 161 |
<title>See Also</title> |
| 162 |
<para><simplelist type="inline"> |
| 163 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 164 |
<member><citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 165 |
<member><citerefentry><refentrytitle>systemd-machine-id-commit.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 166 |
<member><citerefentry project='dbus'><refentrytitle>dbus-uuidgen</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 167 |
<member><citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 168 |
</simplelist></para> |
| 169 |
</refsect1> |
| 170 |
|
| 171 |
</refentry> |