You are not logged in.

#1 2012-12-04 16:06:09

ackalker
Member
Registered: 2012-11-27
Posts: 198

Chrony setup: nuts & bolts, nits and issues

After spending quite a bit of time trying to get to the bottom of how to correctly configure Chrony for synchronizing system time to NTP time sources, I would like to share what I've found with the Arch community, and ask for any comments and suggestions.

Naturally, I started out with Arch Linux's excellent as always Wiki page on Chrony.

I ended up with the following initial configuration in /etc/chrony.conf:

server 0.europe.pool.ntp.org
server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
server 3.europe.pool.ntp.org 
driftfile /etc/chrony.drift
keyfile /etc/chrony.keys
commandkey 1

After running into some trouble, I turned to the official Chrony documentation, and the Chrony FAQ, and even this article on the Kernel Discipline for NTP.

These are the problems I've run into so far, and the ways in which I (tried to) fix them, with the place for some possible documentation improvements within parentheses:

1. (Wiki) Setting the hardware RTC using

# chronyc trimrtc

didn't work, it gave the error:

513 RTC driver not running

I had to configure the 'rtcfile' option in /etc/chrony.conf to get it to work. This is actually in the Chrony FAQ. It can easily be fixed in the Wiki documentation.

2. (Wiki, config) With my hardware RTC set to UTC, I had to explicitly enable (uncomment) the "rtconutc" option in /etc/chrony.conf for the system time to use the correct time zone.
Unlike any other part of a Linux system that I know of, Chrony assumes that the RTC is set to local time, unless specified otherwise.
The comments in the config file don't (to me at least) make it clear enough that the 'rtconutc' option is not the default, and must be explicitly enabled. Otherwise, strange things can happen to the system time. This was the case for me: my clock kept jumping forward one hour on each boot until I fixed this.
This should definitely be documented on the Wiki page.

3. (timedatectl? Chrony?) Even when fully synchronized to an NTP time source,

$ timedatectl status

outputs

...
     NTP enabled: yes
NTP synchronized: no
...

I found this quite disturbing at first, and it took me a lot of research to figure this one out.
I would have expected the value of "NTP synchronized" to indicate whether system time is in fact synchronized to an NTP time source or not, but I found that, in the case of Chrony, it only indicates whether the RTC is being kept updated with the (synchronized) system time.
"NTP synchronized" will remain "no", even when fully synchronized, unless 'rtcsync' is enabled (and rtcfile is disabled!) in /etc/chrony.conf .
Note the dissimilarity between "NTP synchronized" and "rtcsync": in my view, the former deals with NTP, the latter deals with the RTC.
(In more technical detail, "NTP synchronized" only reflects  (inversely) whether or not the STA_UNSYNC flag is set in struct timex, see /usr/include/sys/timex.h, /usr/include/bits/timex.h, and the article on the Kernel Discipline linked to above.)
I'm unsure whether this issue is really a bug in Chrony, or simply an ambiguity in the output of timedatectl.

This is the final configuration in /etc/chrony.conf that I ended up with:

server 0.europe.pool.ntp.org
server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
server 3.europe.pool.ntp.org 
driftfile /etc/chrony.drift
keyfile /etc/chrony.keys
commandkey 1
! rtcfile /etc/chrony.rtc
rtcsync
rtconutc

Any comments or suggestions on this are very welcome.

Last edited by ackalker (2012-12-10 23:25:21)

Offline

#2 2013-04-14 16:42:53

bwat47
Member
Registered: 2009-10-07
Posts: 637

Re: Chrony setup: nuts & bolts, nits and issues

I've noticed that with the rtconutc option chrony tells me its an invalid command: Line 10 in configuration file [/etc/chrony.conf] contains invalid command (line test is the one with rtconutc) has the command been deprecated or something?

Offline

#3 2013-04-14 17:11:38

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 692

Re: Chrony setup: nuts & bolts, nits and issues

I always follow the wiki but I have my own brief notes about chrony. Also if you want to use trimrtc I always go to chronyc as root and then from the command line within chronyc issue a password command first and then issue the trimrtc command (through you can also issue the password in a single line command too) - here are my notes (warts and all) which may help:

For chrony need to check chrony.conf
$ cat /etc/chrony.conf|grep .|grep -v "^[#\!;%]"
server ntp.xxxx.co.uk
server ntp1.xxxx.co.uk
server ntp2.xxxx.co.uk

 
driftfile /etc/chrony.drift
keyfile /etc/chrony.keys
commandkey 1
 dumponexit
 dumpdir /var/log/chrony
cmdallow 127.0.0.1
 rtcfile /etc/chrony.rtc
 rtconutc

If any settings are missing then add them in - but change the servers as necessary.

These are the settings that work.
$ cat /etc/chrony.keys
1 mychronypass

Put whatever password you like instead of mychronypass - if the file does not exist then create it.

Issue the following command to get the system set properly (as root):
# chronyc -m "password mychronypass" online makestep
200 OK
200 OK
200 OK

To start it issue systemctl start chrony
and to make it start at boot systemctl enable chrony

To check status can run chrony as root and then
password mychronypass
tracking
trimrtc
sources

Make sure that tracking shows that it is synchronised before trying to use trimrtc

By the way during any install I always do hwclock --systohc --utc and if it is a dual boot machine with Windows I use the registry hack for Windows to be on UTC - that way I don't have issues with time on either the OSes that are booted. On machines with only arch then the hwclock command is fine anyway - but if your clock is not on UTC and you then use rtconutc for chrony then it may not like it!

Hope this helps.

Last edited by mcloaked (2013-04-14 17:15:54)


Mike C

Offline

Board footer

Powered by FluxBB