]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/machine-id.xml
Merge pull request #4395 from s-urbaniak/rw-support
[thirdparty/systemd.git] / man / machine-id.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="machine-id">
25 <refentryinfo>
26 <title>machine-id</title>
27 <productname>systemd</productname>
28
29 <authorgroup>
30 <author>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
35 </author>
36 </authorgroup>
37 </refentryinfo>
38
39 <refmeta>
40 <refentrytitle>machine-id</refentrytitle>
41 <manvolnum>5</manvolnum>
42 </refmeta>
43
44 <refnamediv>
45 <refname>machine-id</refname>
46 <refpurpose>Local machine ID configuration file</refpurpose>
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <para><filename>/etc/machine-id</filename></para>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para>The <filename>/etc/machine-id</filename> file contains the unique machine ID of the local
57 system that is set during installation. The machine ID is a single newline-terminated,
58 hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a
59 16-byte/128-bit value.</para>
60
61 <para>The machine ID is usually generated from a random source
62 during system installation and stays constant for all subsequent
63 boots. Optionally, for stateless systems, it is generated during
64 runtime at early boot if it is found to be empty.</para>
65
66 <para>The machine ID does not change based on local or network configuration or when hardware is
67 replaced. Due to this and its greater length, it is a more useful replacement for the
68 <citerefentry project='man-pages'><refentrytitle>gethostid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
69 call that POSIX specifies.</para>
70
71 <para>This machine ID adheres to the same format and logic as the
72 D-Bus machine ID.</para>
73
74 <para>This ID uniquely identifies the host. It should be considered "confidential", and must not
75 be exposed in untrusted environments, in particular on the network. If a stable unique
76 identifier that is tied to the machine is needed for some application, the machine ID or any
77 part of it must not be used directly. Instead the machine ID should be hashed with a
78 cryptographic, keyed hash function, using a fixed, application-specific key. That way the ID
79 will be properly unique, and derived in a constant way from the machine ID but there will be no
80 way to retrieve the original machine ID from the application-specific one.</para>
81
82 <para>The
83 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>
84 tool may be used by installer tools to initialize the machine ID
85 at install time. Use
86 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
87 to initialize it on mounted (but not booted) system images.</para>
88
89 <para>The machine-id may also be set, for example when network
90 booting, by setting the <varname>systemd.machine_id=</varname>
91 kernel command line parameter or passing the option
92 <option>--machine-id=</option> to systemd. A machine-id may not
93 be set to all zeros.</para>
94 </refsect1>
95
96 <refsect1>
97 <title>Relation to OSF UUIDs</title>
98
99 <para>Note that the machine ID historically is not an OSF UUID as
100 defined by <ulink url="https://tools.ietf.org/html/rfc4122">RFC
101 4122</ulink>, nor a Microsoft GUID; however, starting with systemd
102 v30, newly generated machine IDs do qualify as v4 UUIDs.</para>
103
104 <para>In order to maintain compatibility with existing
105 installations, an application requiring a UUID should decode the
106 machine ID, and then apply the following operations to turn it
107 into a valid OSF v4 UUID. With <literal>id</literal> being an
108 unsigned character array:</para>
109
110 <programlisting>/* Set UUID version to 4 --- truly random generation */
111 id[6] = (id[6] &amp; 0x0F) | 0x40;
112 /* Set the UUID variant to DCE */
113 id[8] = (id[8] &amp; 0x3F) | 0x80;</programlisting>
114
115 <para>(This code is inspired by
116 <literal>generate_random_uuid()</literal> of
117 <filename>drivers/char/random.c</filename> from the Linux kernel
118 sources.)</para>
119
120 </refsect1>
121
122 <refsect1>
123 <title>History</title>
124
125 <para>The simple configuration file format of
126 <filename>/etc/machine-id</filename> originates in the
127 <filename>/var/lib/dbus/machine-id</filename> file introduced by
128 D-Bus. In fact, this latter file might be a symlink to
129 <filename>/etc/machine-id</filename>.</para>
130 </refsect1>
131
132 <refsect1>
133 <title>See Also</title>
134 <para>
135 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
137 <citerefentry project='man-pages'><refentrytitle>gethostid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
142 <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
144 </para>
145 </refsect1>
146
147 </refentry>