{
    "mode": "info",
    "parameter": "MACHINE-ID",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/MACHINE-ID/json",
    "generated": "2026-07-05T11:45:56Z",
    "synopsis": "/etc/machine-id",
    "sections": {
        "NAME": {
            "content": "machine-id - Local machine ID configuration file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "/etc/machine-id\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The /etc/machine-id file contains the unique machine ID of the local\nsystem that is set during installation or boot. The machine ID is a\nsingle newline-terminated, hexadecimal, 32-character, lowercase ID.\nWhen decoded from hexadecimal, this corresponds to a 16-byte/128-bit\nvalue. This ID may not be all zeros.\n\nThe machine ID is usually generated from a random source during system\ninstallation or first boot and stays constant for all subsequent boots.\nOptionally, for stateless systems, it is generated during runtime\nduring early boot if necessary.\n\nThe machine ID may be set, for example when network booting, with the\nsystemd.machineid= kernel command line parameter or by passing the\noption --machine-id= to systemd. An ID specified in this manner has\nhigher 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\nor when hardware is replaced. Due to this and its greater length, it is\na more useful replacement for the gethostid(3) call that POSIX\nspecifies.\n\nThis machine ID adheres to the same format and logic as the D-Bus\nmachine ID.\n\nThis ID uniquely identifies the host. It should be considered\n\"confidential\", and must not be exposed in untrusted environments, in\nparticular on the network. If a stable unique identifier that is tied\nto 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\nhashed with a cryptographic, keyed hash function, using a fixed,\napplication-specific key. That way the ID will be properly unique, and\nderived in a constant way from the machine ID but there will be no way\nto retrieve the original machine ID from the application-specific one.\nThe sdid128getmachineappspecific(3) API provides an implementation\nof such an algorithm.\n",
            "subsections": []
        },
        "INITIALIZATION": {
            "content": "Each machine should have a non-empty ID in normal operation. The ID of\neach machine should be unique. To achieve those objectives,\n/etc/machine-id can be initialized in a few different ways.\n\nFor normal operating system installations, where a custom image is\ncreated for a specific machine, /etc/machine-id should be populated\nduring installation.\n\nsystemd-machine-id-setup(1) may be used by installer tools to\ninitialize the machine ID at install time, but /etc/machine-id may also\nbe written using any other means.\n\nFor operating system images which are created once and used on multiple\nmachines, for example for containers or in the cloud, /etc/machine-id\nshould be either missing or an empty file in the generic file system\nimage (the difference between the two options is described under \"First\nBoot Semantics\" below). An ID will be generated during boot and saved\nto this file if possible. Having an empty file in place is useful\nbecause it allows a temporary file to be bind-mounted over the real\nfile, in case the image is used read-only.\n\nsystemd-firstboot(1) may be used to initialize /etc/machine-id on\nmounted (but not booted) system images.\n\nWhen a machine is booted with systemd(1) the ID of the machine will be\nestablished. If systemd.machineid= or --machine-id= options (see first\nsection) are specified, this value will be used. Otherwise, the value\nin /etc/machine-id will be used. If this file is empty or missing,\nsystemd will attempt to use the D-Bus machine ID from\n/var/lib/dbus/machine-id, the value of the kernel command line option\ncontaineruuid, the KVM DMI productuuid or the devicetree vm,uuid (on\nKVM systems), and finally a randomly generated UUID.\n\nAfter the machine ID is established, systemd(1) will attempt to save it\nto /etc/machine-id. If this fails, it will attempt to bind-mount a\ntemporary file over /etc/machine-id. It is an error if the file system\nis 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\nID to the file system if /etc/machine-id or /etc/ are read-only during\nearly boot but become writable later on.\n",
            "subsections": []
        },
        "FIRST BOOT SEMANTICS": {
            "content": "/etc/machine-id is used to decide whether a boot is the first one. The\nrules are as follows:\n\n1. If /etc/machine-id does not exist, this is a first boot. During\nearly boot, systemd will write \"uninitialized\\n\" to this file and\novermount a temporary file which contains the actual machine ID.\nLater (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\nalso considered the first boot. The same mechanism as above\napplies.\n\n3. If /etc/machine-id exists and is empty, a boot is not considered\nthe first boot.  systemd will still bind-mount a file containing\nthe actual machine-id over it and later try to commit it to disk\n(if /etc/ is writable).\n\n4. If /etc/machine-id already contains a valid machine-id, this is not\na first boot.\n\nIf by any of the above rules, a first boot is detected, units with\nConditionFirstBoot=yes will be run.\n",
            "subsections": []
        },
        "RELATION TO OSF UUIDS": {
            "content": "Note that the machine ID historically is not an OSF UUID as defined by\nRFC 4122[1], nor a Microsoft GUID; however, starting with systemd v30,\nnewly generated machine IDs do qualify as Variant 1 Version 4 UUIDs, as\nper RFC 4122.\n\nIn order to maintain compatibility with existing installations, an\napplication requiring a strictly RFC 4122 compliant UUID should decode\nthe machine ID, and then (non-reversibly) apply the following\noperations 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\ndrivers/char/random.c from the Linux kernel sources.)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The simple configuration file format of /etc/machine-id originates in\nthe /var/lib/dbus/machine-id file introduced by D-Bus. In fact, this\nlatter file might be a symlink to /etc/machine-id.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "systemd(1), systemd-machine-id-setup(1), gethostid(3), hostname(5),\nmachine-info(5), os-release(5), sd-id128(3), sdid128getmachine(3),\nsystemd-firstboot(1)\n",
            "subsections": []
        },
        "NOTES": {
            "content": "1. RFC 4122\nhttps://tools.ietf.org/html/rfc4122\n\nsystemd 249                                                      MACHINE-ID(5)",
            "subsections": []
        }
    },
    "summary": "machine-id - Local machine ID configuration file",
    "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": "os-release",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/os-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"
        }
    ]
}