[systemd-devel] systemd and hardware real time clock

Lennart Poettering lennart at poettering.net
Thu Feb 9 14:52:47 UTC 2017


On Tue, 17.01.17 12:29, MichaƂ Zegan (webczat_200 at poczta.onet.pl) wrote:

> Hello.
> 
> I am aware of the fact that systemd relies on the kernel to set system
> clock from hardware clock, and that requires compiling rtc drivers into
> the kernel, not as modules.
> I am also aware that doing it othervise would mix timestamps in log entries.
> The question is: if I have rtc driver as a module anyway, how to modify
> initramfs so that system time would be set, in such a way so that it
> happens *before* journald in initramfs starts? I assume it is an
> initramfs using systemd inside of it.
> One approach would be to have an udev rule that does trigger after rtc
> appears or rtc symlink is added, this rule would start a service that
> sets the system clock, but this service would have to always run before
> journald, and that seems not possible in such a configuration, because
> if someone would unplug the rtc the service would not run?
> Another thing is to load rtc and i2c bus module where rtc is connected
> statically without udev detection, and then the hwclock service would
> always be triggered before journald without looking for rtcs appearing...

Well, you could write a tool that uses libudev but listens on the
kernel mcast group instead of the udev one, and then, as soon as the
RTC showed up would do the /dev/thing. Then, make a service of it,
make sure to use StandardOutput=null + StandardError=null, so that you
don't get an implicit dependency on journald, and order the service
before journald.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list