You are not logged in.

#1 2017-10-08 01:48:37

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

chronyd & network initialisation

I'm setting up a new Arch install and have been checking the wiki for new recommendations. Among others, I found that chrony is now recommended rather than systemd's own synchronisation or ntp. In the past, I've used ntp. (I've never used the systemd built-in service.)

Following the instructions, I set my ntp servers as 'offline' because I do not necessarily have a connection on boot. I then configured a hook for netctl to tell chrony a connection is available when it configures an internet device.

However, on boot, chrony remains inactive.

# chronyc  activity
200 OK
0 sources online
4 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

I think this is because the chronyd.service 'wants' the network target, so isn't activated until after the network is up. I'm guessing that netctl has done its thing by then and the hooks telling chrony to go online have fired off into the void.

Removing the commented and blank lines, /etc/chrony.conf contains

server 0.pool.ntp.org offline
server 1.pool.ntp.org offline
server 2.pool.ntp.org offline
server 3.pool.ntp.org offline
 
maxupdateskew 5
minsources 2
driftfile /var/lib/chrony/drift
logchange 0.5
hwtimestamp *
rtconutc
rtcsync

/etc/netctl/hooks/chrony-dispatcher contains

#!/bin/sh -
# ref.: https://github.com/bertptrs/netctl-dispatcher-chrony/blob/master/chrony-dispatcher
# ref.: https://wiki.archlinux.org/index.php/Netctl#Using_hooks

# Hooks to toggle chrony online state
ExecUpPost="/usr/bin/chronyc online"
ExecDownPre="/usr/bin/chronyc offline"

If I start a chronyc session and say online, then the servers come online without issue.

# chronyc
chrony version 3.2
Copyright (C) 1997-2003, 2007, 2009-2017 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
you are welcome to redistribute it under certain conditions.  See the
GNU General Public License version 2 for details.

chronyc> online
200 OK
chronyc> exit
# chronyc activity 
200 OK
4 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

What is the best way to ensure that chrony takes them online when a connection is available at boot? Is the recommendation to use 'offline' only applicable if the machine never has an internet connection at boot? Should I be using 'iburst' rather than 'offline'?

I'm wondering whether it might be better to use 'iburst' or 'auto_offline' in chrony.conf and then 'online' and 'offline' in the netctl hook. Or some other combination of these.

I'm going to try 'iburst' in the conf and keeping the hook for netctl, to see what that does ...

Last edited by cfr (2017-10-08 02:42:42)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#2 2017-10-08 07:50:27

adesh
Member
Registered: 2016-10-05
Posts: 167

Re: chronyd & network initialisation

chronyd.service must be active before network is available, otherwise commands in network-dispatcher hook will have no effect.

Also, this is how I set chrony to offline mode:

chronyc -m offline dump writertc

Offline

#3 2017-10-08 22:01:48

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: chronyd & network initialisation

adesh wrote:

chronyd.service must be active before network is available, otherwise commands in network-dispatcher hook will have no effect.

Thanks. But the service file 'wants' the network.target, so how can chrony's service be started first? Have I misunderstood how the 'wants' works? Or are you using a custom service file rather than the packaged one?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2017-10-09 05:45:20

adesh
Member
Registered: 2016-10-05
Posts: 167

Re: chronyd & network initialisation

I think there is a difference between network.target and actual network/internet connection. I don't fully understand systemd, I may be wrong, but below is how I use chrony:

Chrony is enabled to start during the startup sequence. Like your setup, it's told that default mode is offline. Then I establish an ppp connection using wvdial. And the script in ppp/ip-up.d instructs chronyd service that network connection is available to online. On system suspend (actually resume), ip-down.d script updates the service of network status again.
When I resume from I have to manually connect to Internet (earlier it used to happen automatically by a uev rule, but some upgrade broke it so now automatic connection works at boot only). And all this time chronyd.service is running like hell.

Last edited by adesh (2017-10-09 05:48:28)

Offline

Board footer

Powered by FluxBB