{
    "content": [
        {
            "type": "text",
            "text": "# MACHINE-ID(5) (man)\n\n**Summary:** machine-id - Local machine ID configuration file\n\n**Synopsis:** /etc/machine-id\n\n## See Also\n\n- systemd(1)\n- systemd-machine-id-setup(1)\n- gethostid(3)\n- hostname(5)\n- machine-info(5)\n- release(5)\n- sd-id128(3)\n- sdid128getmachine(3)\n- systemd-firstboot(1)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (29 lines)\n- **INITIALIZATION** (35 lines)\n- **FIRST BOOT SEMANTICS** (19 lines)\n- **RELATION TO OSF UUIDS** (17 lines)\n- **HISTORY** (4 lines)\n- **SEE ALSO** (3 lines)\n- **NOTES** (6 lines)\n\n## Full Content\n\n### NAME\n\nmachine-id - Local machine ID configuration file\n\n### SYNOPSIS\n\n/etc/machine-id\n\n### DESCRIPTION\n\nThe /etc/machine-id file contains the unique machine ID of the local system that is set\nduring installation or boot. The machine ID is a single newline-terminated, hexadecimal,\n32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a\n16-byte/128-bit value. This ID may not be all zeros.\n\nThe machine ID is usually generated from a random source during system installation or first\nboot and stays constant for all subsequent boots. Optionally, for stateless systems, it is\ngenerated during runtime during early boot if necessary.\n\nThe machine ID may be set, for example when network booting, with the systemd.machineid=\nkernel command line parameter or by passing the option --machine-id= to systemd. An ID\nspecified in this manner has higher priority and will be used instead of the ID stored in\n/etc/machine-id.\n\nThe machine ID does not change based on local or network configuration or when hardware is\nreplaced. Due to this and its greater length, it is a more useful replacement for the\ngethostid(3) call that POSIX specifies.\n\nThis machine ID adheres to the same format and logic as the D-Bus machine ID.\n\nThis ID uniquely identifies the host. It should be considered \"confidential\", and must not be\nexposed in untrusted environments, in particular on the network. If a stable unique\nidentifier that is tied to the machine is needed for some application, the machine ID or any\npart of it must not be used directly. Instead the machine ID should be hashed with a\ncryptographic, keyed hash function, using a fixed, application-specific key. That way the ID\nwill be properly unique, and derived in a constant way from the machine ID but there will be\nno way to retrieve the original machine ID from the application-specific one. The\nsdid128getmachineappspecific(3) API provides an implementation of such an algorithm.\n\n### INITIALIZATION\n\nEach machine should have a non-empty ID in normal operation. The ID of each machine should be\nunique. To achieve those objectives, /etc/machine-id can be initialized in a few different\nways.\n\nFor normal operating system installations, where a custom image is created for a specific\nmachine, /etc/machine-id should be populated during installation.\n\nsystemd-machine-id-setup(1) may be used by installer tools to initialize the machine ID at\ninstall time, but /etc/machine-id may also be written using any other means.\n\nFor operating system images which are created once and used on multiple machines, for example\nfor containers or in the cloud, /etc/machine-id should be either missing or an empty file in\nthe generic file system image (the difference between the two options is described under\n\"First Boot Semantics\" below). An ID will be generated during boot and saved to this file if\npossible. Having an empty file in place is useful because it allows a temporary file to be\nbind-mounted over the real file, in case the image is used read-only.\n\nsystemd-firstboot(1) may be used to initialize /etc/machine-id on mounted (but not booted)\nsystem images.\n\nWhen a machine is booted with systemd(1) the ID of the machine will be established. If\nsystemd.machineid= or --machine-id= options (see first section) are specified, this value\nwill be used. Otherwise, the value in /etc/machine-id will be used. If this file is empty or\nmissing, systemd will attempt to use the D-Bus machine ID from /var/lib/dbus/machine-id, the\nvalue of the kernel command line option containeruuid, the KVM DMI productuuid or the\ndevicetree vm,uuid (on KVM systems), and finally a randomly generated UUID.\n\nAfter the machine ID is established, systemd(1) will attempt to save it to /etc/machine-id.\nIf this fails, it will attempt to bind-mount a temporary file over /etc/machine-id. It is an\nerror if the file system is read-only and does not contain a (possibly empty) /etc/machine-id\nfile.\n\nsystemd-machine-id-commit.service(8) will attempt to write the machine ID to the file system\nif /etc/machine-id or /etc/ are read-only during early boot but become writable later on.\n\n### FIRST BOOT SEMANTICS\n\n/etc/machine-id is used to decide whether a boot is the first one. The rules are as follows:\n\n1. If /etc/machine-id does not exist, this is a first boot. During early boot, systemd will\nwrite \"uninitialized\\n\" to this file and overmount a temporary file which contains the\nactual machine ID. Later (after first-boot-complete.target has been reached), the real\nmachine ID will be written to disk.\n\n2. If /etc/machine-id contains the string \"uninitialized\", a boot is also considered the\nfirst boot. The same mechanism as above applies.\n\n3. If /etc/machine-id exists and is empty, a boot is not considered the first boot.  systemd\nwill still bind-mount a file containing the actual machine-id over it and later try to\ncommit it to disk (if /etc/ is writable).\n\n4. If /etc/machine-id already contains a valid machine-id, this is not a first boot.\n\nIf by any of the above rules, a first boot is detected, units with ConditionFirstBoot=yes\nwill be run.\n\n### RELATION TO OSF UUIDS\n\nNote that the machine ID historically is not an OSF UUID as defined by RFC 4122[1], nor a\nMicrosoft GUID; however, starting with systemd v30, newly generated machine IDs do qualify as\nVariant 1 Version 4 UUIDs, as per RFC 4122.\n\nIn order to maintain compatibility with existing installations, an application requiring a\nstrictly RFC 4122 compliant UUID should decode the machine ID, and then (non-reversibly)\napply the following operations to turn it into a valid RFC 4122 Variant 1 Version 4 UUID.\nWith \"id\" being an unsigned character array:\n\n/* Set UUID version to 4 --- truly random generation */\nid[6] = (id[6] & 0x0F) | 0x40;\n/* Set the UUID variant to DCE */\nid[8] = (id[8] & 0x3F) | 0x80;\n\n(This code is inspired by \"generaterandomuuid()\" of drivers/char/random.c from the Linux\nkernel sources.)\n\n### HISTORY\n\nThe simple configuration file format of /etc/machine-id originates in the\n/var/lib/dbus/machine-id file introduced by D-Bus. In fact, this latter file might be a\nsymlink to /etc/machine-id.\n\n### SEE ALSO\n\nsystemd(1), systemd-machine-id-setup(1), gethostid(3), hostname(5), machine-info(5), os-\nrelease(5), sd-id128(3), sdid128getmachine(3), systemd-firstboot(1)\n\n### NOTES\n\n1. RFC 4122\nhttps://tools.ietf.org/html/rfc4122\n\n\n\nsystemd 249                                                                            MACHINE-ID(5)\n\n"
        }
    ],
    "structuredContent": {
        "command": "MACHINE-ID",
        "section": "5",
        "mode": "man",
        "summary": "machine-id - Local machine ID configuration file",
        "synopsis": "/etc/machine-id",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "systemd",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/systemd/1/json"
            },
            {
                "name": "systemd-machine-id-setup",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/systemd-machine-id-setup/1/json"
            },
            {
                "name": "gethostid",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/gethostid/3/json"
            },
            {
                "name": "hostname",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/hostname/5/json"
            },
            {
                "name": "machine-info",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/machine-info/5/json"
            },
            {
                "name": "release",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/release/5/json"
            },
            {
                "name": "sd-id128",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/sd-id128/3/json"
            },
            {
                "name": "sdid128getmachine",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/sdid128getmachine/3/json"
            },
            {
                "name": "systemd-firstboot",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/systemd-firstboot/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 29,
                "subsections": []
            },
            {
                "name": "INITIALIZATION",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "FIRST BOOT SEMANTICS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "RELATION TO OSF UUIDS",
                "lines": 17,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 6,
                "subsections": []
            }
        ]
    }
}