Skip to content

Commit

Permalink
feat: Use timesyncd with recovery clock file
Browse files Browse the repository at this point in the history
Replaced ntpd with sytemd timesyncd. This allows to use a recovery clock
file to have a more accurate system time during boot up.
This greatly helps with log file timestamps. Otherwise they always start
in 2019 and journal logs get all messed up until time synchronization is
available.

The recovery clock file is updated 2min after boot up, thereafter every
5 minutes and before shutdown. Whenever timesyncd receives a time update
the file is updated as well internally by timesyncd.

More information: https://wiki.archlinux.org/index.php/Systemd-timesyncd
  • Loading branch information
zehnm committed Sep 8, 2020
1 parent 4dffcb5 commit 36ceb7e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
11 changes: 11 additions & 0 deletions overlay/etc/systemd/system/shutdown-clock-file.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Final clock file update before shutdown
RequiresMountsFor=/

[Service]
ExecStop=/etc/update_clock_file.sh
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
9 changes: 9 additions & 0 deletions overlay/etc/systemd/system/update-clock-file.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[Unit]
Description=Run clock file update script
RefuseManualStart=no
RefuseManualStop=no

[Service]
Type=oneshot
ExecStart=/etc/update_clock_file.sh
9 changes: 9 additions & 0 deletions overlay/etc/systemd/system/update-clock-file.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Clock file update timer

[Timer]
OnBootSec=120
OnUnitActiveSec=300

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions overlay/etc/update_clock_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /usr/bin/env sh
touch /var/lib/systemd/timesync/clock
1 change: 0 additions & 1 deletion overlay/opt/yio/scripts/firstrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ then
#--------------------
# Do some setup with services
#--------------------
systemctl disable systemd-timesyncd.service
systemctl disable dhcpcd.service
systemctl disable lighttpd.service

Expand Down
2 changes: 1 addition & 1 deletion rpi0/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ BR2_PACKAGE_IW=y
BR2_PACKAGE_LIGHTTPD=y
BR2_PACKAGE_LIGHTTPD_PCRE=y
BR2_PACKAGE_NTP=y
# BR2_PACKAGE_NTP_NTPD is not set
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
BR2_PACKAGE_WPA_SUPPLICANT_WIFI_DISPLAY=y
Expand All @@ -105,7 +106,6 @@ BR2_PACKAGE_BASH=y
# BR2_PACKAGE_SYSTEMD_HWDB is not set
# BR2_PACKAGE_SYSTEMD_MYHOSTNAME is not set
BR2_PACKAGE_SYSTEMD_RFKILL=y
# BR2_PACKAGE_SYSTEMD_TIMESYNCD is not set
BR2_PACKAGE_UTIL_LINUX_KILL=y
BR2_PACKAGE_UTIL_LINUX_RFKILL=y
BR2_PACKAGE_NANO=y
Expand Down

0 comments on commit 36ceb7e

Please sign in to comment.