Tuning ntpd
Charly's Column – ntpd
Charly Kühnast, sys admin columnist for 15 years, is searching for lost microseconds.
Time is the topic I'm focusing on right now. On the one hand, I am of course happy to be celebrating the 25th anniversary of Linux Magazine and the fact that I have been allowed to contribute this column for more than 15 years. On the other hand, I am currently working on configuring my time servers. In the last issue [1], I briefly touched on the topic when we looked at ntpviz
, the statistics visualization tool for the Network Time Protocol daemon (ntpd
).
How to tune the time server for maximum accuracy using quite simple means was the topic in the October 2017 issue [2]. (Is it really already two years ago? How time flies.) At the time, I picked up a high-precision pulse per second (PPS) signal from GPS satellites. This allowed me to line up ticks received locally or from remote time servers to achieve microsecond accuracy on my server. Apart from scientific applications, nobody really needs that, but it's cool, so it was done.
When I tackled this configuration back in 2017, it was still by a fairly circuitous route. Feeding the PPS signal to ntpd
required additional software, which I found on GitHub. It's easier today. The two daemons involved, gpsd
and ntpd
, work hand in hand on my Debian 10 – and without any extra software.
I only have to tell the GPS daemon in the /etc/default/gpsd
configuration file where to find the GPS hardware. In my case, it is connected to a USB port, so I need the following line:
DEVICES="/dev/ttyUSB0"
Also the ntpd
configuration file is quickly completed with Listing 1. Lines 1 to 4 probably already exist in the file. It is important that one of them ends with the prefer
keyword. Lines 6 and 7 include the GPS time signal, but only for statistics. The noselect
keyword prevents it from actually being included in the calculations, because it is not very accurate. Lines 9 to 11, on the other hand, provide accuracy and bridge the gap to the PPS signal, which announces the beginning of a new second with high precision.
Listing 1
/etc/ntp.conf
01 server 0.de.pool.ntp.org prefer 02 server 1.de.pool.ntp.org iburst 03 server 2.de.pool.ntp.org iburst 04 server 3.de.pool.ntp.org iburst 05 06 server 127.127.28.0 minpoll4 noselect 07 fudge 127.127.28.0 refid GPS 08 09 server 127.127.22.0 minpoll 4 maxpoll 4 10 fudge 127.127.22.0 flag3 1 refid PPS 11 tos mindist 0.2
A Little Crazy
This allows my time signal to fluctuate by only a few millionths of a second (Figure 1). By the way, the deflections in the right part of the graph were caused by me frivolously moving the GPS antenna on the window sill.
Of course, my experiments did not go as smoothly as the story thus far suggests. In the first attempt, my time signal was no more accurate than before, whatever I did. After tearing my hair out for a couple of hours, it turned out that you can buy some GPS hardware that simply ignores the PPS signal. This realization cost me half an afternoon – it seemed to drag on endlessly if you ask me. On the other hand, time flies – but not always, apparently.
Infos
- "Charly's Column – ntpviz" by Charly Kühnast, Linux Magazine, issue 228, November 2019, p. 26
- "Charly's Column – Precision Timekeeping" by Charly Kühnast, Linux Magazine, issue 203, October 2017, http://www.linux-magazine.com/Issues/2017/203/Charly-s-Column-Precise-Timekeeping/(language)/eng-US
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.