On 2016-07-27 19:54, Michał Zegan wrote:
> Hello.
> 
> There is, it seems, a problem with the hardware clock. That is, the
> systemd does not care about it. Neither systemd nor udev rules set the
> system time using the hardware clock.

Strictly speaking, systemd does at bootup what hwclock used to do with
usual hwclock --hctosys or hwclock --systz, but not at shutdown
(anymore, though that can be trivially readded as well). See for details:

https://lists.freedesktop.org/archives/systemd-devel/2011-May/002526.html

> From what I know, if the clock is a cmos rtc, the kernel always sets
> time during bootup. In any other case, it should do this anyway if it is
> configured to do so during compilation, but only when appropriate rtc
> support is compiled into the kernel. So, userspace does not have to.
> The problem is that there are cases when the rtc is not a cmos one, and
> the driver is compiled as a module. This is a specific case because the
> kernel will not restore the time, and systemd does not do this either.
> The thing that restores the time is ntp synchronization and that is not
> related to the hardware clock.

Hmmm, in such case you could maybe use a service similar to what systemd
had in v27 and earlier versions:

[Unit]
DefaultDependencies=no
Before=sysinit.target shutdown.target
Conflicts=shutdown.target
# maybe also some of (depending on what you're planning to do):
Wants=time-sync.target
Before=udev.service time-sync.target
After=systemd-modules-load.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=<hwclock or something else you need>

And make sure to add remaining dependencies (for example you could load
related rtc modules through systemd-modules-load.service as in example
above - or - use udev with TAG+= / SYSTEMD_WANTS+= ; using static
modules seems to be more sensible - and allows you to order correctly
against udev.service and time-sync.target).


_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to