johang / sd-card-images

Scripts to build bootable SD card images with Debian for various single-board computers
https://sd-card-images.johang.se
GNU General Public License v3.0
151 stars 33 forks source link

systemd-timesyncd is not installed by default #29

Closed deftdawg closed 1 year ago

deftdawg commented 1 year ago

First, thanks for making these images, I'm trying to use it to build an Octoprint server on an old PCDuino3 nano.

It boots perfectly and seems to run reasonably well, but it seems NTP does come up on start and sync the time. The lack of synced time creates issues with SSL certificate validations which impacts the ability to download packages including ntpdate.

I can manually set the date by copying it from another machine

# Time Synced machine
date +%s # copy time from a synced machine

# On the PCduino - set the time to something close
date -s "$(date -d @1670738614)"

After ntpdate is installed, I can manually sync time by using ntpdate tick.utoronto.ca , obviously it would be far better if the images automatically synced their time.

johang commented 1 year ago

By default it uses NTP servers returned by the DHCP server. You need to either configure your DHCP server or configure Debian.

deftdawg commented 1 year ago

What package is responsible for that in the image so I can investigate further?

Is it networkmanager? I couldn't find anything with dpkg --get-selections | grep ntp

deftdawg commented 1 year ago

Reading up on it a bit more, I guess this is possibly supposed to be handled by systemd's systemd-timesyncd.service unit...

Looks like it's not working for me, maybe the lack of /etc/systemd/timesyncd.conf is the issue?

root@octo-et4:/etc/systemd# timedatectl show-timesync --all
Failed to parse bus message: No route to host
root@octo-et4:/etc/systemd# timedatectl status
               Local time: Tue 2022-12-06 15:32:18 EST
           Universal time: Tue 2022-12-06 20:32:18 UTC
                 RTC time: Tue 1965-07-20 06:36:28
                Time zone: America/Toronto (EST, -0500)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: no
root@octo-et4:/etc/systemd# timedatectl show  
Timezone=America/Toronto
LocalRTC=no
CanNTP=no
NTP=no
NTPSynchronized=no
TimeUSec=Tue 2022-12-06 15:32:26 EST
RTCTimeUSec=--- XXXX-XX-XX XX:XX:XX
deftdawg commented 1 year ago

systemd-timesyncd wasn't installed by default, adding systemd-timesyncd fixed it instantly:

apt install systemd-timesyncd
peterbmckinley commented 1 year ago

Please note you cannot install or update anything, including systemd-timesyncd, on any of these images until you manually bring system time close to current after installation using the following command (example for just now, modify as required):

date --set="9 JAN 2023 22:48:00"

AFTER you do

apt update && apt full-upgrade

you can install with

apt install systemd-timesyncd

Hope this helps