{"id":4398,"date":"2022-12-20T17:49:10","date_gmt":"2022-12-20T20:49:10","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/machineid-man5\/"},"modified":"2022-12-20T17:49:10","modified_gmt":"2022-12-20T20:49:10","slug":"machineid-man5","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/machineid-man5\/","title":{"rendered":"MACHINE&minus;ID (man5)"},"content":{"rendered":"<h1 align=\"center\">MACHINE\u2212ID<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#INITIALIZATION\">INITIALIZATION<\/a><br \/> <a href=\"#RELATION TO OSF UUIDS\">RELATION TO OSF UUIDS<\/a><br \/> <a href=\"#HISTORY\">HISTORY<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">machine-id \u2212 Local machine ID configuration file<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">\/etc\/machine\u2212id<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The \/etc\/machine\u2212id file contains the unique machine ID of the local system that is set during installation or boot. The machine ID is a single newline\u2212terminated, hexadecimal, 32\u2212character, lowercase ID. When decoded from hexadecimal, this corresponds to a 16\u2212byte\/128\u2212bit value. This ID may not be all zeros.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The machine ID is usually generated from a random source during system installation or first boot and stays constant for all subsequent boots. Optionally, for stateless systems, it is generated during runtime during early boot if necessary.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The machine ID may be set, for example when network booting, with the <i>systemd.machine_id=<\/i> kernel command line parameter or by passing the option <b>\u2212\u2212machine\u2212id=<\/b> to systemd. An ID specified in this manner has higher priority and will be used instead of the ID stored in \/etc\/machine\u2212id.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The machine ID does not change based on local or network configuration or when hardware is replaced. Due to this and its greater length, it is a more useful replacement for the <b>gethostid<\/b>(3) call that POSIX specifies.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This machine ID adheres to the same format and logic as the D\u2212Bus machine ID.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This ID uniquely identifies the host. It should be considered &#8220;confidential&#8221;, and must not be exposed in untrusted environments, in particular on the network. If a stable unique identifier that is tied to the machine is needed for some application, the machine ID or any part of it must not be used directly. Instead the machine ID should be hashed with a cryptographic, keyed hash function, using a fixed, application\u2212specific key. That way the ID will be properly unique, and derived in a constant way from the machine ID but there will be no way to retrieve the original machine ID from the application\u2212specific one. The <b>sd_id128_get_machine_app_specific<\/b>(3) API provides an implementation of such an algorithm.<\/p>\n<h2>INITIALIZATION <a name=\"INITIALIZATION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Each machine should have a non\u2212empty ID in normal operation. The ID of each machine should be unique. To achieve those objectives, \/etc\/machine\u2212id can be initialized in a few different ways.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For normal operating system installations, where a custom image is created for a specific machine, \/etc\/machine\u2212id should be populated during installation.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>systemd-machine-id-setup<\/b>(1) may be used by installer tools to initialize the machine ID at install time, but \/etc\/machine\u2212id may also be written using any other means.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For operating system images which are created once and used on multiple machines, for example for containers or in the cloud, \/etc\/machine\u2212id should be an empty file in the generic file system image. An ID will be generated during boot and saved to this file if possible. Having an empty file in place is useful because it allows a temporary file to be bind\u2212mounted over the real file, in case the image is used read\u2212only.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>systemd-firstboot<\/b>(1) may be used to initialize \/etc\/machine\u2212id on mounted (but not booted) system images.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When a machine is booted with <b>systemd<\/b>(1) the ID of the machine will be established. If <i>systemd.machine_id=<\/i> or <b>\u2212\u2212machine\u2212id=<\/b> options (see first section) are specified, this value will be used. Otherwise, the value in \/etc\/machine\u2212id will be used. If this file is empty or missing, systemd will attempt to use the D\u2212Bus machine ID from \/var\/lib\/dbus\/machine\u2212id, the value of the kernel command line option <i>container_uuid<\/i>, the KVM DMI product_uuid or the devicetree vm,uuid (on KVM systems), and finally a randomly generated UUID.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">After the machine ID is established, <b>systemd<\/b>(1) will attempt to save it to \/etc\/machine\u2212id. If this fails, it will attempt to bind\u2212mount a temporary file over \/etc\/machine\u2212id. It is an error if the file system is read\u2212only and does not contain a (possibly empty) \/etc\/machine\u2212id file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>systemd-machine-id-commit.service<\/b>(8) will attempt to write the machine ID to the file system if \/etc\/machine\u2212id or \/etc are read\u2212only during early boot but become writable later on.<\/p>\n<h2>RELATION TO OSF UUIDS <a name=\"RELATION TO OSF UUIDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that the machine ID historically is not an OSF UUID as defined by <b><font color=\"#0000FF\">RFC 4122<\/font><\/b> <small><font color=\"#000000\">[1]<\/font><\/small> <font color=\"#000000\">, nor a Microsoft GUID; however, starting with systemd v30, newly generated machine IDs do qualify as v4 UUIDs.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">In order to maintain compatibility with existing installations, an application requiring a UUID should decode the machine ID, and then apply the following operations to turn it into a valid OSF v4 UUID. With &#8220;id&#8221; being an unsigned character array:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">\/* Set UUID version to 4 \u2212\u2212\u2212 truly random generation bodies\/ usr\/ <br \/> id[6] = (id[6] &#038; 0x0F) | 0x40; <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Set the UUID variant to DCE bodies\/ usr\/ <br \/> id[8] = (id[8] &#038; 0x3F) | 0x80;<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">(This code is inspired by &#8220;generate_random_uuid()&#8221; of drivers\/char\/random.c from the Linux kernel sources.)<\/font><\/p>\n<h2>HISTORY <a name=\"HISTORY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">The simple configuration file format of \/etc\/machine\u2212id originates in the \/var\/lib\/dbus\/machine\u2212id file introduced by D\u2212Bus. In fact, this latter file might be a symlink to \/etc\/machine\u2212id.<\/font><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>systemd<\/b>(1), <b>systemd-machine-id-setup<\/b>(1), <b>gethostid<\/b>(3), <b>hostname<\/b>(5), <b>machine-info<\/b>(5), <b>os-release<\/b>(5), <b>sd-id128<\/b>(3), <b>sd_id128_get_machine<\/b>(3), <b>systemd-firstboot<\/b>(1)<\/font><\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">1.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">RFC 4122<\/font><\/p>\n<\/td>\n<td width=\"71%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/tools.ietf.org\/html\/rfc4122<\/font><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  machine-id \u2212 Local machine ID configuration file <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[959],"tags":[961,1399,1291],"class_list":["post-4398","post","type-post","status-publish","format-standard","hentry","category-5-formatos-de-ficheros","tag-961","tag-machine-id","tag-man5"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4398"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4398\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}