SYSTEMD-MACHINE-ID-SETUP(1)

๐Ÿ’– SYSTEMD-MACHINE-ID-SETUP(1) ๐Ÿ’–

okay bestie, this is systemd-machine-id-setup from the systemd manual โ€” the lil glow-up artist that gives your machine its one true ID โœจ


๐ŸŒธ NAME ๐ŸŒธ

systemd-machine-id-setup โ€” initialize the machine ID in /etc/machine-id


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

systemd-machine-id-setup

โœจ DESCRIPTION โœจ

so like, systemd-machine-id-setup is the tool your system installer besties call to set up the machine ID living in /etc/machine-id at install time โ€” either with a provisioned ID or a freshly randomized one ๐ŸŽฒ. wanna know more about that file? go read machine-id(5), it spills all the tea ๐Ÿ’….

If you run the tool without the --commit switch, /etc/machine-id gets initialized with a valid, brand-new machine ID if it's missing or empty. and how does it pick that new ID? glad you asked, here's the whole lineup:

  1. If there's a valid machine ID chillin' in /run/machine-id, it gets copied over and used to initialize the machine ID in /etc/machine-id. โš ๏ธ this step is skipped if --root= is specified, or if you're running in a chroot environment.
  2. If a valid D-Bus machine ID is already configured for the system, that D-Bus machine ID gets copied and used to initialize the machine ID in /etc/machine-id.
  3. If a valid machine ID is provided through the system.machine_id credential, that machine ID gets copied and used to initialize the machine ID in /etc/machine-id. โš ๏ธ skipped if --root= is specified or running in a chroot environment.
  4. If you're running inside a KVM virtual machine and a UUID is configured (via the -uuid option), that UUID is used to initialize the machine ID. heads up tho: the caller has to make sure the UUID they pass is sufficiently unique and different for every single booted instance of the VM ๐Ÿ‘‘. โš ๏ธ skipped if --root= is specified or running in a chroot environment.
  5. Same vibe for Linux containers: if you're in a container environment and a UUID is configured for the container, that gets used to initialize the machine ID. for the deets, check the Container Interface docs (linked down in NOTES ๐Ÿซถ). โš ๏ธ skipped if --root= is specified or running in a chroot environment.
  6. and if literally none of that applies? a brand-new ID gets randomly generated. iconic. ๐Ÿฆ‹

The --commit switch is the glow-up button: it commits a transient machine ID to disk and makes it persistent. more on that below ๐Ÿ‘‡

also, if you're initializing the machine ID on a mounted (but not booted) system image, use systemd-firstboot(1) instead ๐Ÿ’–


๐Ÿ’… OPTIONS ๐Ÿ’…

here's everything this baby understands:

  • --root=path โ€” takes a directory path as its argument. every path it operates on gets prefixed with that alternate root path you gave it โ€” including the path for /etc/machine-id itself. ๐Ÿ 

Added in version 212.

  • --image=path โ€” takes a path to a device node or regular file as argument. it's basically --root= but for a disk image instead of a directory tree ๐Ÿ’พ.

Added in version 249.

  • --image-policy=policy โ€” takes an image policy string as argument, as per systemd.image-policy(7). the policy gets enforced when operating on the disk image specified via --image=, see above. if you don't specify one, it defaults to the "*" policy, i.e. all recognized file systems in the image are used ๐ŸŒˆ.
  • --commit โ€” commit a transient machine ID to disk ๐Ÿซถ. this command can convert a transient machine ID into a persistent one. a transient machine ID file is one that was bind mounted from a memory file system (usually "tmpfs") to /etc/machine-id during the early phase of the boot process โ€” which can happen because /etc/ was initially read-only and was missing a valid machine ID file at that point ๐Ÿ˜ญ.

This command will execute no operation if /etc/machine-id is not mounted from a memory file system, or if /etc/ is read-only. otherwise, it writes the current transient machine ID to disk and unmounts the /etc/machine-id mount point in a race-free manner, so that this file is always valid and accessible for other processes ๐Ÿ‘‘.

This command is primarily used by the systemd-machine-id-commit.service(8) early boot service.

Added in version 227.

  • --print โ€” print the machine ID that was generated or committed, after the operation is complete ๐Ÿ–จ๏ธโœจ.

Added in version 231.

  • -h, --help โ€” print a short help text and exit. classic.
  • --version โ€” print a short version string and exit. also classic.

๐Ÿ”ฅ EXIT STATUS ๐Ÿ”ฅ

On success, 0 is returned. otherwise you get a non-zero failure code ๐Ÿ˜ญ.


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

systemd(1), machine-id(5), systemd-machine-id-commit.service(8), dbus-uuidgen(1), systemd-firstboot(1)


๐Ÿ“ NOTES ๐Ÿ“

  1. Container Interface https://systemd.io/CONTAINER_INTERFACE

and that's the whole page bestie, no cap ๐Ÿ’– this was systemd version 262.1's SYSTEMD-MACHINE-ID-SETUP(1) โ€” go forth and give your machine an identity, main character energy only ๐Ÿ‘‘โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from
  • arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms