miniblog.

← Back to all posts
43
A cute systemd feature to get the system clock roughly correct: if the system time is before the compilation time of the systemd binary, it moves the clock forward to that time!

3 Comments

@wilfredh This would break reproducible builds. Suggestion: set the system clock to at least the last-modified time of the #systemd executable. Another suggestion: save the current time in a file during shutdown, and set the system clock to at least that time when starting up. Note: there needs to be a way for time travelers to disable this behavior. #Linux
@argv_minus_one @wilfredh the actually epoch we forward the clock to is controllable at build time, via SOURCE_DATE_EPOCH, which is the standard reproducible build people established. hence, systemd is perfectly reproducibly buildable.
@argv_minus_one @wilfredh systemd-timesyncd (https://www.freedesktop.org/software/systemd/man/latest/systemd-timesyncd.html) implements your second suggestion: it periodically saves the current time to a file, and systemd sets the system clock to at least that time when starting up. Using it is recommended by Fedora as a way to fix clock issues on the Raspberry Pi (which doesn't have a RTC): https://discussion.fedoraproject.org/t/dnf-system-upgrade-can-fail-on-raspberry-pi/92403