Jump down to edit 2 to see the most current information I have on this question. I am leaving everything else as a preamble explaining the situation.

I am setting up my first RPi to be a home DNS server and I decided to take the opportunity to learn how to make a cross compiler and craft a custom slimmed down linux installation from scratch that is loosely based on Linux From Scratch. Almost everything works but I ran into a system time issue that I am not sure how to even begin to track down the cause. I know RPi's do not have a RTC so I made sure to have NTPd running however the date changes randomly every second jumping around months at a time around the beginning of the UNIX epoch. I really do not have a clue where the issue is and my log files contain no useful information. My system has a custom configured 5.5.3 Rpi kernel, busybox 1.32.0 , and musl 1.2.0 and is compiled as 32 bit arm instead of aarch64 arm.

Edit 1:

Doing some digging trying to debug my problem and since busybox ntpd does not seem to be logging for some reason I ran the program without daemonizing it and this is what spit out to stderr. Also I redacted the ip address of the ntp server.

ntpd: peer <ntp server ip addr> unfit for selection: root distance 2770695.820775 too high, jitter:2267419.463899
ntpd: no valid datapoints, no peer selected

From what I can make out of the source code the issue the daemon is having is the system clock is so out of bounds and changes so rapidly that the data from the ntp server is treated as erronous.

Edit 2:

I decided to do some tests with some dummy C programs and I believe I might have misconfigured my system kernel.

The functions I tested were time(), clock_gettime() with CLOCK_REALTIME as the clockid, and gettimeofday(). I called each function multiple times and the return value of time and the tv_sec of the structs passed to gettimeofday and clock_gettime all had a random value that had no logical relation to the value produced by the previous syscall.

  • Have you completely disabled systemd-timesyncd? If not then that's the cause of your ntpd problems. – Dougie Jul 29 '20 at 1:57
  • 1
    Technically yes, my system uses sysvinit and BusyBox's mdev so I don't have any systemd software installed. – Zeno of Elea Jul 29 '20 at 2:18
  • Is that NTP server usable on an otherwise working system? – Dmitry Grigoryev Jul 29 '20 at 23:07
  • Yes. I tested it on my development rig with qemu and changed my system dates to invalid times and the daemon worked fine. – Zeno of Elea Jul 30 '20 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.