Advertisement
zmatt

machine-id and first boot notes

Sep 2nd, 2021 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. if /etc/machine-id does not exist and we're not still in initramfs then
  2. systemd will enter "first boot" mode.
  3. in this case /etc may not be mounted read-only or boot will fail.
  4. first boot mode is not triggered if /etc/machine-id exists but is empty/invalid.
  5.  
  6. new in v247: if /etc/machine-id exists but contains the string "uninitialized"
  7. then it is treated as if it were missing and first boot mode is entered.
  8.  
  9.  
  10. --- obtaining machine id ---
  11.  
  12. systemd checks the following, in decreasing order of priority:
  13. systemd cmdline option '--machine-id'
  14. kernel parameter 'systemd.machine_id'
  15. file '/etc/machine-id'
  16. file '/var/lib/dbus/machine-id' (unless this is a symlink)
  17. env variable 'container_uuid' if running in a container
  18. file '/sys/class/dmi/id/product_uuid' if running in a KVM container
  19. file '/sys/firmware/devicetree/base/vm,uuid' if running in a KVM container
  20. until it finds a _valid_ uuid.
  21. if none is found, a new random uuid is generated.
  22.  
  23.  
  24. --- writing machine id ---
  25.  
  26. systemd will try to save the machine id to /etc/machine-id, unless it was
  27. obtained from there. if this fails then systemd will save it to /run/machine-id
  28. instead and it then bind-mounts this on top of /etc/machine-id. this is called
  29. a "transient machine id" since it was not saved to persistent storage.
  30.  
  31. new in v247: in first boot mode the string "uninitialized" will be written to
  32. /etc/machine-id and a transient machine id will be used until boot is complete
  33. at which point systemd-machine-id-commit.service will make the machine id
  34. presistent. this ensures that if the first boot does not complete (e.g. power failure)
  35. then first boot mode will be entered again on the next boot.
  36.  
  37.  
  38. ---- first boot mode ---
  39.  
  40. /run/systemd/first-boot will be created (as empty file).
  41. it will be unlinked again when the (first) boot is finished.
  42.  
  43. ConditionFirstBoot for unit files will evaluate to true.
  44. new in v246: this can be overridden using kernel parameter 'systemd.condition-first-boot'.
  45.  
  46. systemd will perform the equivalent of:
  47. systemctl --system --preset-mode=enable-only preset-all
  48.  
  49. When seeding the kernel entropy pool from the seed file '/usr/lib/systemd/random-seed', the
  50. 'user.random-seed-creditable' xattr on the seed file will be ignored hence the entropy pool
  51. will only be credited if SYSTEMD_RANDOM_SEED_CREDIT=forced.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement