]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/machine-id.xml
Merge pull request #4861 from keszybz/dissect-tweaks
[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 be exposed in
75 untrusted environments, in particular on the network. If a stable unique identifier that is tied to the machine is
76 needed for some application, the machine ID or any part of it must not be used directly. Instead the machine ID
77 should be hashed with a cryptographic, keyed hash function, using a fixed, application-specific key. That way the
78 ID will be properly unique, and derived in a constant way from the machine ID but there will be no way to retrieve
79 the original machine ID from the application-specific one. The
80 <citerefentry><refentrytitle>sd_id128_get_machine_app_specific</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81 API provides an implementation of such an algorithm.</para>
82
83 <para>The
84 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>
85 tool may be used by installer tools to initialize the machine ID
86 at install time. Use
87 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
88 to initialize it on mounted (but not booted) system images.</para>
89
90 <para>The machine-id may also be set, for example when network
91 booting, by setting the <varname>systemd.machine_id=</varname>
92 kernel command line parameter or passing the option
93 <option>--machine-id=</option> to systemd. A machine-id may not
94 be set to all zeros.</para>
95 </refsect1>
96
97 <refsect1>
98 <title>Relation to OSF UUIDs</title>
99
100 <para>Note that the machine ID historically is not an OSF UUID as
101 defined by <ulink url="https://tools.ietf.org/html/rfc4122">RFC
102 4122</ulink>, nor a Microsoft GUID; however, starting with systemd
103 v30, newly generated machine IDs do qualify as v4 UUIDs.</para>
104
105 <para>In order to maintain compatibility with existing
106 installations, an application requiring a UUID should decode the
107 machine ID, and then apply the following operations to turn it
108 into a valid OSF v4 UUID. With <literal>id</literal> being an
109 unsigned character array:</para>
110
111 <programlisting>/* Set UUID version to 4 --- truly random generation */
112 id[6] = (id[6] &amp; 0x0F) | 0x40;
113 /* Set the UUID variant to DCE */
114 id[8] = (id[8] &amp; 0x3F) | 0x80;</programlisting>
115
116 <para>(This code is inspired by
117 <literal>generate_random_uuid()</literal> of
118 <filename>drivers/char/random.c</filename> from the Linux kernel
119 sources.)</para>
120
121 </refsect1>
122
123 <refsect1>
124 <title>History</title>
125
126 <para>The simple configuration file format of
127 <filename>/etc/machine-id</filename> originates in the
128 <filename>/var/lib/dbus/machine-id</filename> file introduced by
129 D-Bus. In fact, this latter file might be a symlink to
130 <filename>/etc/machine-id</filename>.</para>
131 </refsect1>
132
133 <refsect1>
134 <title>See Also</title>
135 <para>
136 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
138 <citerefentry project='man-pages'><refentrytitle>gethostid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
142 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
144 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
145 </para>
146 </refsect1>
147
148 </refentry>