Bug#785445: Bug#785419: linux-image-4.0.0-1-armmp: with 2 RTC devices -- need way to chose which one sets system clock on boot

Rick Thomas rbthomas at pobox.com
Sat May 16 21:19:16 BST 2015


On May 16, 2015, at 12:58 PM, Rick Thomas <rbthomas at pobox.com> wrote:

> 
> On May 16, 2015, at 6:02 AM, Ben Hutchings <ben at decadent.org.uk> wrote:
> 
>> This is not implemented directly by the init system.  util-linux
>> installs the script/lib/udev/hwclock-set and a udev rule that runs it
>> for each RTC device.  However, the hwclock-set script does nothing if
>> systemd is running.
> 
> curiouser and curiouser…
> 
> Looking at the code in /lib/udev/hwclock-set, I can’t see that it would would ever do anything useful (except by chance) in the case like mine where there are two rtc devices, only one of which should actually be used to set system time at boot.
> 
> In particular, it goes to some effort to source /etc/default/rcS and /etc/default/hwclock, but it pays no attention to the HCTOSYS_DEVICE parameter.
> 
> It appears to set the system time from each RTC device in turn as it discovers them.  So system time ends up set by the last RTC to be discovered.  If the right one happens to be last, that’s good.  But that’s not guaranteed.

Looking further, I find that what I said is not quite true.  hwclock-set only gets called for /dev/rtc0, i.e. the *first* one to be discovered.  This happens in /lib/udev/rules.d/85-hwclock.rules.  There is provision in /lib/udev/rules.d/50-udev-default.rules to swing the /dev/rtc symlink to the device that has ATTR{hctosys}==“1”, but that doesn’t fix the problem at hand, because the symlink is not used anywhere in hwclock-set.

Fascinating!
Rick



More information about the Pkg-systemd-maintainers mailing list