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