Linux command
systemd-machine-id-setup 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Initialize
sudo systemd-machine-id-setup
sudo systemd-machine-id-setup --print
Commit
sudo systemd-machine-id-setup --commit
Operate
sudo systemd-machine-id-setup --root /[path/to/root]
Operate
sudo systemd-machine-id-setup --image /[path/to/image]
说明
systemd-machine-id-setup initializes the machine ID stored in /etc/machine-id. It is intended for use by system installer tools at install time, or when /etc/machine-id is empty or missing. When invoked without --commit, the tool initializes the machine ID using the first available source in this order: 1. A valid ID from /run/machine-id 2. An existing D-Bus machine ID 3. A machine ID from the system.machine_id credential 4. A UUID from the KVM virtual machine configuration 5. A UUID from the container environment configuration 6. A newly generated random ID as a fallback The --commit option is used to convert a transient machine ID (mounted into memory during early boot) into a persistent one written to disk.
参数
- Print the machine ID after the setup operation completes
- --commit
- Commit a transient machine ID to persistent disk storage. Has no effect if /etc/machine-id is not mounted from memory or if /etc/ is read-only. Primarily used by systemd-machine-id-commit.service
- --root _path_
- Operate on the specified root directory instead of the real root. All paths including /etc/machine-id are prefixed with the given path
- --image _path_
- Operate on the specified disk image (device node or regular file) instead of a directory tree
- --image-policy _policy_
- Specify an image mounting policy string when using --image. Defaults to the "*" policy (all recognized file systems are used)
- -h, --help
- Show brief help and exit
- --version
- Show version information and exit
FAQ
What is the systemd-machine-id-setup command used for?
systemd-machine-id-setup initializes the machine ID stored in /etc/machine-id. It is intended for use by system installer tools at install time, or when /etc/machine-id is empty or missing. When invoked without --commit, the tool initializes the machine ID using the first available source in this order: 1. A valid ID from /run/machine-id 2. An existing D-Bus machine ID 3. A machine ID from the system.machine_id credential 4. A UUID from the KVM virtual machine configuration 5. A UUID from the container environment configuration 6. A newly generated random ID as a fallback The --commit option is used to convert a transient machine ID (mounted into memory during early boot) into a persistent one written to disk.
How do I run a basic systemd-machine-id-setup example?
Run `sudo systemd-machine-id-setup` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --print do in systemd-machine-id-setup?
Print the machine ID after the setup operation completes