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">
7 This file is part of systemd.
9 Copyright 2010 Lennart Poettering
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.
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.
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/>.
25 <refentry id="machine-id">
27 <title>machine-id</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>machine-id</refentrytitle>
42 <manvolnum>5</manvolnum>
46 <refname>machine-id</refname>
47 <refpurpose>Local machine ID configuration file</refpurpose>
51 <para><filename>/etc/machine-id</filename></para>
55 <title>Description</title>
57 <para>The <filename>/etc/machine-id</filename> file
58 contains the unique machine ID of the local system
59 that is set during installation. The machine ID is a
60 single newline-terminated, hexadecimal, 32-character,
61 lowercase machine ID string. When decoded from
62 hexadecimal, this corresponds with a 16-byte/128-bit
65 <para>The machine ID is usually generated from a
66 random source during system installation and stays
67 constant for all subsequent boots. Optionally, for
68 stateless systems, it is generated during runtime at
69 boot if it is found to be empty.</para>
71 <para>The machine ID does not change based on user
72 configuration or when hardware is replaced.</para>
74 <para>This machine ID adheres to the same format and
75 logic as the D-Bus machine ID.</para>
77 <para>Programs may use this ID to identify the host
78 with a globally unique ID in the network, which does
79 not change even if the local network configuration
80 changes. Due to this and its greater length, it is
81 a more useful replacement for the
82 <citerefentry><refentrytitle>gethostid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
83 call that POSIX specifies.</para>
86 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>
87 tool may be used by installer tools to initialize the
88 machine ID at install time.</para>
92 <title>Relation to OSF UUIDs</title>
94 <para>Note that the machine ID historically is not an
95 OSF UUID as defined by <ulink
96 url="https://tools.ietf.org/html/rfc4122">RFC
97 4122</ulink>, nor a Microsoft GUID; however, starting with
98 systemd v30, newly generated machine IDs do
99 qualify as v4 UUIDs.</para>
101 <para>In order to maintain compatibility with existing
102 installations, an application requiring a UUID should
103 decode the machine ID, and then apply the following
104 operations to turn it into a valid OSF v4 UUID. With
105 <literal>id</literal> being an unsigned character
108 <programlisting>/* Set UUID version to 4 --- truly random generation */
109 id[6] = (id[6] & 0x0F) | 0x40;
110 /* Set the UUID variant to DCE */
111 id[8] = (id[8] & 0x3F) | 0x80;</programlisting>
113 <para>(This code is inspired by
114 <literal>generate_random_uuid()</literal> of
115 <filename>drivers/char/random.c</filename> from the
116 Linux kernel sources.)</para>
121 <title>History</title>
123 <para>The simple configuration file format of
124 <filename>/etc/machine-id</filename> originates in the
125 <filename>/var/lib/dbus/machine-id</filename> file
126 introduced by D-Bus. In fact, this latter file might be a
128 <varname>/etc/machine-id</varname>.</para>
132 <title>See Also</title>
134 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
135 <citerefentry><refentrytitle>systemd-machine-id-setup</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
136 <citerefentry><refentrytitle>gethostid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
137 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
138 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
139 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>