How to use systemd-firstboot.service?
I am a bit surprised you didn't have this script in place from simply installing systemd, but (in general) I think the answer is that you should put it into /etc/systemd/system
.
In this situation (since you are doing all this to try and get a machine-id, in order to make journald work), I guess I might replace the ConditionFirstBoot with a check for the file you care about,/etc/machine-id
.
So I would probably re-write the Unit section as:
[Unit]
Description=First Boot Wizard
Documentation=man:systemd-firstboot(1)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=systemd-sysusers.service sysinit.target shutdown.target
ConditionPathIsReadWrite=/etc
ConditionPathExists=!/etc/machine-id
That being said, if it was possible to ship a more recent systemd with your image (I am not good on Debian, so I couldn't find anywhere to check what the latest supported version was), that might be worth looking into - systemd 215 has a few issues that have since been fixed (https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=systemd).
Related videos on Youtube
Velkan
Updated on September 18, 2022Comments
-
Velkan over 1 year
I'm making an image of Debian Jessie. On boot the system has no
/etc/machine-id
file. This causes some problems with the journald that doesn't start.I've found that in the systemd repo:
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=First Boot Wizard Documentation=man:systemd-firstboot(1) DefaultDependencies=no Conflicts=shutdown.target After=systemd-remount-fs.service Before=systemd-sysusers.service sysinit.target shutdown.target ConditionPathIsReadWrite=/etc ConditionFirstBoot=yes [Service] Type=oneshot RemainAfterExit=yes ExecStart=@rootbindir@/systemd-firstboot --prompt-locale --prompt-timezone --prompt-root-password StandardOutput=tty StandardInput=tty StandardError=tty
Where it should be placed so it'll run?
In systemd 215 the ConditionFirstBoot is not available. How to deal with that?
-
kkm over 4 yearsJust a note to verify twice that the proposed solution would work. When I started imaging systemd-controlled OS (based on Debian 10, IIRC, when he still was Sid) a couple years ago, my first impulse was delete the /etc/machine-id right before imaging, among other personality erasure tasks. The effect was quite dramatic: the system flatly refused to boot and went into recovery mode (a brick if you are deploying a cloud vm). The fix was truncate but keep the file (
: > /etc/machine-id
). Maybe this is not even true anymore, but I learnt to treat this file with a great respect and awe ever since.