cloud-init clean truncate machine-id instead of deleting
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
I don't know how to re-open a bug [1] so I create a new one. The fix mentioned in [1] is not ideal. If you just remove the file /etc/machine-id (e. g. 'cloud-init clean --machine-id') it won't be regenerated during startup but error messages are displayed (here in Ubuntu 20.04):
---snip---
Jan 9 14:49:48 control-4 kernel: [ 3.482774] systemd[1]: System cannot boot: Missing /etc/machine-id and /etc is mounted read-only.
Jan 9 14:49:48 control-4 kernel: [ 3.484066] systemd[1]: Booting up is supported only when:
Jan 9 14:49:48 control-4 kernel: [ 3.485226] systemd[1]: 1) /etc/machine-id exists and is populated.
Jan 9 14:49:48 control-4 kernel: [ 3.485861] systemd[1]: 2) /etc/machine-id exists and is empty.
Jan 9 14:49:48 control-4 kernel: [ 3.486569] systemd[1]: 3) /etc/machine-id is missing and /etc is writable.
Jan 9 14:49:48 control-4 kernel: [ 4.247850] systemd[1]: Failed to populate /etc with preset unit settings, ignoring: Read-only file system
---snip---
If you just truncate the files (I truncated both /etc/machine-id and /var/lib/
root@control-4:~# truncate -s0 /etc/machine-id /var/lib/
I haven't tested many scenarios (maybe it's sufficient to truncate only one file /etc/machine-id) but this change might help a bit when creating VM images.
[1] https:/
Discussions are already happening for this. Please see LP: #1999680