LinuxCommandLibrary

systemd-machine-id-setup

Initialize or update the machine ID

TLDR

Print the generated or committed machine ID

$ systemd-machine-id-setup --print
copy

Specify an image policy
$ systemd-machine-id-setup --image-policy [your_policy]
copy

Display the output as JSON
$ sudo systemd-machine-id-setup --json pretty
copy

Operate on a disk image instead of a directory tree
$ systemd-machine-id-setup --image /[path/to/image]
copy

SYNOPSIS

systemd-machine-id-setup [OPTIONS...]

PARAMETERS

-h, --help
    Show a help message and exit.

--version
    Show package version information and exit.

--commit
    Write a new machine ID to /etc/machine-id. This is the default action if no other action-specific options like --template are provided.

--root=PATH
    Operate on an alternate root directory specified by PATH instead of the real root directory. Useful for chroot or container environments.

--force
    Force the generation and writing of a new machine ID, even if /etc/machine-id already exists and contains a valid ID. This will overwrite the existing ID without prompting.

--dry-run
    Perform a trial run without actually writing any changes to disk. It shows what actions would be taken.

--template
    Generate a new random machine ID and print it to standard output. This ID is not written to /etc/machine-id or any other file.

DESCRIPTION

The systemd-machine-id-setup command is a utility provided by systemd to manage the unique machine ID of a system. This ID is stored in the /etc/machine-id file and serves as a stable, unique identifier for the host. It's crucial for various system services like D-Bus, the systemd journal, and DHCP clients that rely on a consistent host identifier.

If the /etc/machine-id file is missing or empty, this command can be used to generate a new, random 32-character hexadecimal ID and write it to the file. It ensures that each system installation has a distinct identity, which is important for network services and logging aggregation. Typically, this setup happens automatically during the operating system installation or first boot through tools like systemd-firstboot(1), but it can be manually invoked if the ID needs to be regenerated or if the file was inadvertently deleted.

CAVEATS

Care should be taken when regenerating the machine ID on an already running system, especially if it's integrated with services or monitoring systems that rely on the existing ID. While regenerating is safe for most services, some distributed systems might require re-registration or configuration changes. It's generally recommended to set the machine ID once during installation and avoid changing it unless absolutely necessary. Using --force will overwrite any existing ID without warning.

THE /ETC/MACHINE-ID FILE

This file contains a 32-character hexadecimal string that uniquely identifies the host. It should be kept consistent across reboots and is used by various system components for stable identification. If the file is empty or missing, systemd-machine-id-setup or other systemd tools will typically generate a new one during early boot.

MACHINE ID AND PRIVACY

While the machine ID provides unique identification for system services, it does not contain any personally identifiable information and is generated randomly. It's a local identifier and not designed for external tracking, though it could potentially be used in conjunction with other data for such purposes if exposed externally.

HISTORY

The systemd-machine-id-setup command is an integral part of the systemd initialization system, which largely replaced the traditional SysVinit in many Linux distributions. The concept of a unique machine ID (/etc/machine-id) became central with systemd's design for better host identification, especially for journaling and networking. This command was introduced as part of the broader systemd suite to ensure the proper and consistent setup of this critical system identifier, simplifying boot-time configuration and system-level unique identification.

SEE ALSO

machine-id(5), systemd-firstboot(1), systemd(1), dbus-uuidgen(1)

Copied to clipboard