Dietpi: NTP error

Created on 3 Mar 2018  Β·  20Comments  Β·  Source: MichaIng/DietPi

Creating a bug report/issue:

Using username "root".

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
[ OK ] Root access verified.
───────────────────────────────────────
DietPi | 08:49 | Sat 03/03/18
───────────────────────────────────────
v6.2 | RPi 3 Model B (armv7l)
───────────────────────────────────────
IP eth0 | 192.168.0.3
───────────────────────────────────────
[ INFO ] DietPi-Drive_Manager | Checking RootFS R/W access. Please wait...
[ OK ] DietPi-Drive_Manager | RootFS R/W access.

[ INFO ] DietPi-Software | Initializing database, please wait...
[ INFO ] DietPi-Software | Reading database, please wait...
───────────────────────────────────────
DietPi | 08:49 | Sat 03/03/18
───────────────────────────────────────
v6.2 | RPi 3 Model B (armv7l)
───────────────────────────────────────
IP eth0 | 192.168.0.3
───────────────────────────────────────

Welcome to DietPi-Software

Failed to create bus connection: No such file or directory
[ INFO ] DietPi-Run_ntpd | NTPD: Waiting for completion of systemd-timesyncd (1/30)
Failed to create bus connection: No such file or directory
[ INFO ] DietPi-Run_ntpd | NTPD: Waiting for completion of systemd-timesyncd (2/30)
Failed to create bus connection: No such file or directory
[ INFO ] DietPi-Run_ntpd | NTPD: Waiting for completion of systemd-timesyncd (3/30)
Failed to create bus connection: No such file or directory
[ INFO ] DietPi-Run_ntpd | NTPD: Waiting for completion of systemd-timesyncd (4/30)
Failed to create bus connection: No such file or directory
[ INFO ] DietPi-Run_ntpd | NTPD: Waiting for completion of systemd-timesyncd (5/30)

Required Information:

  • DietPi Version | cat /DietPi/dietpi/.version? 6.2
  • SBC Device (EG: RPi 3)? RPi3
  • Power supply used (EG: 5v 1A RAVpower)? 5v
  • SD card used (EG: Sandisk ultra)?
  • Distro (EG: Jessie) | uname -a? Stretch
Enhancement Question

Most helpful comment

@Fourdee
I just tested to switch to timesyncd as well:

root@VM-Stretch:~# systemctl enable systemd-timesyncd
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service β†’ /lib/systemd/system/systemd-timesyncd.service.
root@VM-Stretch:~# systemctl start systemd-timesyncd
root@VM-Stretch:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Sat 2018-03-03 19:59:51 CET; 10s ago
           └─ ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
     Docs: man:systemd-timesyncd.service(8)
  • As you can see, the service as execution condition that ntp is not installed.
root@VM-Stretch:~# apt purge ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libbsd0 libedit2 libopts25
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  ntp*
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 1,847 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 18264 files and directories currently installed.)
Removing ntp (1:4.2.8p10+dfsg-3+deb9u1) ...
(Reading database ... 18212 files and directories currently installed.)
Purging configuration files for ntp (1:4.2.8p10+dfsg-3+deb9u1) ...
Processing triggers for systemd (232-25+deb9u1) ...
root@VM-Stretch:~# systemctl start systemd-timesyncd
root@VM-Stretch:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: active (running) since Sat 2018-03-03 20:01:04 CET; 2s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 3844 (systemd-timesyn)
   Status: "Synchronized to time server 185.207.104.70:123 (0.de.pool.ntp.org)."
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/systemd-timesyncd.service
           └─3844 /lib/systemd/systemd-timesyncd

Mar 03 20:01:04 VM-Stretch systemd[1]: Starting Network Time Synchronization...
Mar 03 20:01:04 VM-Stretch systemd[1]: Started Network Time Synchronization.
Mar 03 20:01:04 VM-Stretch systemd-timesyncd[3844]: Synchronized to time server 185.207.104.70:123 (0.de.pool.ntp.org).

So procedure on activating mode 4:

  • dietpi-software uninstall 106
  • add timesyncd config
  • _systemctl daemon-reload should not be necessary, as we adjust timesyncd config and not it's service file._
  • systemctl enable systemd-timesyncd
  • systemctl start systemd-timesyncd

I see now uninstallation should have been done actually, but as you can see it somehow was not: https://github.com/Fourdee/DietPi/blob/testing/dietpi/func/dietpi-set_software#L222-L236

I see also we use timedatectl status --no-pager which creates the same "bus missing" error message. What works instead is systemctl status systemd-timesyncd | grep 'Status: "Synchronized to time server' e.g.

Jep confirmed timedatectl need dbus, but systemctl status/is-active systemd-timesyncd can be used instead to verify status.

Actually we could even run timesyncd on demand via cron job:

  • Keep service disabled
  • Start via cron job
  • During my test, faster then I can check status afterwards, it synchronizes time successfully which can be checked via service status (see above).
  • Then stop service again to save around 4 MB RAM. No idea how 4 MB can be necessary for what this service does... I mean whole DietPi takes 1.4 MB πŸ˜†.

All 20 comments

I experienced the same problem and waiting for about 2-3 min solved the problem for the first boot. After that i got this error some times moore before i figured out to adjust the timeserver in dietpi-config and it worked fine.

Still fix this bug for first time installation pls.

I ran the command but: -bash: dietpi-config: command not found

@juliocoliveira

I ran the command but: -bash: dietpi-config: command not found

/DietPi/dietpi/dietpi-config

Networking Options: NAS/MISC > NTP mirror

Once completed, to resume setup

/DietPi/dietpi/dietpi-software

notes:

  • Load DietPi-Globals before login script?
  • Change prompt on failure to include dietpi-config as an option to change NTP mirror?
  • Dbus?
Failed to create bus connection: No such file or directory

Changed the mirror but still the Dbus error

@juliocoliveira

Changed the mirror but still the Dbus error

Thanks, we'll check that.

NTPD Mirror now functional?

you mean the NTP mirror selector? it removed the ntp package and emptied the /etc/ntp.conf
And tried to install and configure the NTP manually and got this:

root@DietPi:~# ntpd -q -g
 3 Mar 11:15:36 ntpd[6709]: ntpd [email protected] Sat Oct  7 14:29:08 UTC 2017 (1): Starting
 3 Mar 11:15:36 ntpd[6709]: Command line: ntpd -q -g
 3 Mar 11:15:36 ntpd[6709]: proto: precision = 1.458 usec (-19)
restrict default: KOD does nothing without LIMITED.
 3 Mar 11:15:36 ntpd[6709]: restrict default: KOD does nothing without LIMITED.
restrict ::: KOD does nothing without LIMITED.
 3 Mar 11:15:36 ntpd[6709]: restrict ::: KOD does nothing without LIMITED.
 3 Mar 11:15:36 ntpd[6709]: format error frequency file /etc/ntp.drift
 3 Mar 11:15:36 ntpd[6709]: unable to bind to wildcard address :: - another process may be running - EXITING

@juliocoliveira

you mean the NTP mirror selector?

Yep.

it removed the ntp package and emptied the /etc/ntp.conf

Upon selecting the following option, ntp is installed:
image

Only when selecting the following (+option 4) "Advanced options" > "Time sync mode", will NTP be removed:
image

Please can you verify "Time sync mode" current setting.

i can't fix it, i disabled the ntp.

@juliocoliveira

i can't fix it, i disabled the ntp.

Ok πŸ‘

We'll improve the error handling for v6.3, give the user more options to resolve NTPD issues on their network when it occurs:
image

@Fourdee

Override : (NOT RECOMMENDED) ....

hmm .. what does thies mean? Hard reset as synced and disable forever?
This should really be the last chance ...

Can it be a option, user can set date once manually via whiptail dialog?
date 030317492018 ?
So installation or inital setup can move forward?

BTW:
Don't believe, most user will know difference between NTPD and Systemd-timesyncd (first boot up). Or will NTPD Mode : change will forward to Time Sync (NTP) dialog?
~
Ahh ... got it! πŸ˜„ /DietPi/dietpi/dietpi-config 3 1 πŸ‘

@Fourdee
I just tested to switch to timesyncd as well:

root@VM-Stretch:~# systemctl enable systemd-timesyncd
Created symlink /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service β†’ /lib/systemd/system/systemd-timesyncd.service.
root@VM-Stretch:~# systemctl start systemd-timesyncd
root@VM-Stretch:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Sat 2018-03-03 19:59:51 CET; 10s ago
           └─ ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
     Docs: man:systemd-timesyncd.service(8)
  • As you can see, the service as execution condition that ntp is not installed.
root@VM-Stretch:~# apt purge ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libbsd0 libedit2 libopts25
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  ntp*
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 1,847 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 18264 files and directories currently installed.)
Removing ntp (1:4.2.8p10+dfsg-3+deb9u1) ...
(Reading database ... 18212 files and directories currently installed.)
Purging configuration files for ntp (1:4.2.8p10+dfsg-3+deb9u1) ...
Processing triggers for systemd (232-25+deb9u1) ...
root@VM-Stretch:~# systemctl start systemd-timesyncd
root@VM-Stretch:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: active (running) since Sat 2018-03-03 20:01:04 CET; 2s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 3844 (systemd-timesyn)
   Status: "Synchronized to time server 185.207.104.70:123 (0.de.pool.ntp.org)."
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/systemd-timesyncd.service
           └─3844 /lib/systemd/systemd-timesyncd

Mar 03 20:01:04 VM-Stretch systemd[1]: Starting Network Time Synchronization...
Mar 03 20:01:04 VM-Stretch systemd[1]: Started Network Time Synchronization.
Mar 03 20:01:04 VM-Stretch systemd-timesyncd[3844]: Synchronized to time server 185.207.104.70:123 (0.de.pool.ntp.org).

So procedure on activating mode 4:

  • dietpi-software uninstall 106
  • add timesyncd config
  • _systemctl daemon-reload should not be necessary, as we adjust timesyncd config and not it's service file._
  • systemctl enable systemd-timesyncd
  • systemctl start systemd-timesyncd

I see now uninstallation should have been done actually, but as you can see it somehow was not: https://github.com/Fourdee/DietPi/blob/testing/dietpi/func/dietpi-set_software#L222-L236

I see also we use timedatectl status --no-pager which creates the same "bus missing" error message. What works instead is systemctl status systemd-timesyncd | grep 'Status: "Synchronized to time server' e.g.

Jep confirmed timedatectl need dbus, but systemctl status/is-active systemd-timesyncd can be used instead to verify status.

Actually we could even run timesyncd on demand via cron job:

  • Keep service disabled
  • Start via cron job
  • During my test, faster then I can check status afterwards, it synchronizes time successfully which can be checked via service status (see above).
  • Then stop service again to save around 4 MB RAM. No idea how 4 MB can be necessary for what this service does... I mean whole DietPi takes 1.4 MB πŸ˜†.

@k-plan

hmm .. what does thies mean? Hard reset as synced and disable forever?
This should really be the last chance ...

Yep, last resort. Basically allows the system to run with DietPi scripts, and, without updating the time.

Can it be a option, user can set date once manually via whiptail dialog?
date 030317492018 ?

πŸ‘

Yep, we could replace override with this option.

@MichaIng

So procedure on activating mode 4:
dietpi-software uninstall 106
add timesyncd config
systemctl daemon-reload should not be necessary, as we adjust timesyncd config and not it's service file.
systemctl enable systemd-timesyncd
systemctl start systemd-timesyncd
I see now uninstallation should have been done actually, but as you can see it somehow was not: https://github.com/Fourdee/DietPi/blob/testing/dietpi/func/dietpi-set_software#L222-L236

Nice πŸ‘ I'll take a look.

@MichaIng

Had to change the detection of completion of timesync:

systemctl status systemd-timesyncd -l | grep -ci -m1 'Synchronized to time server'

The downside is, if the log entries truncate in systemd, our check for successful sync, will fail.

We need a better way of detecting its completion. as timedatectl status cannot be used without dbus.

We may need to install dbus along side systemd-timesyncd

Setting high, to prevent me getting side tracked with other tickets :)

@Fourdee

We may need to install dbus along side systemd-timesyncd

Jep thought the same. Actually everything _could_ be managed without dbus:

  • timedatectl set-ntp true does nothing more than:
    systemctl enable systemd-timesyncd && systemctl start systemd-timesyncd
  • timedatectl status can be replaced as you mentioned.
    You could use systemctl status systemd-timesyncd | grep -q 'Status: "Synchronized to time server' which will high likely not be truncated as it is not part of log but left aligned service info. But service must be started (running) for this to show up. Actually is there any truncate possible, if output is not done to terminal, but into variable or file?

But if already systemd-timesyncd is used, then users might expect timedatectl to work, which does not without dbus and would lead to bug reports. Thus jep: We should install dbus along with NTP mode 4 (timesyncd).


To reduce mess with NTP, we could find a reliable way to use timesyncd as oneshot as well to replace NTP completely. I was playing around a bid and there are some possibilities:

  • Keep service disabled, start on our boot script after network was verified and verify successful timesync as above, which took always less than 1 second on my tests, thus way faster than NTP. Then stop service again, redo steps regularly via cron (or systemd timer?) and on manual checks, if chosen.
  • Keep service enabled to allow automated start by systemd during early boot. Just stop it after success verification within our boot script. I am not sure if this is beneficial if e.g. DHCP to start first anyway. timesyncd seems to benefit especially in combination with systemd-networkd, but this is another topic and on my VM I did not manage yet to get it run with it's internal DHCP client enabled πŸ˜‰.

@MichaIng

We should install dbus along with NTP mode 4 (timesyncd).

Agree πŸ‘

To reduce mess with NTP, we could find a reliable way to use timesyncd as oneshot as well to replace NTP completely.

Yep, would be nice to remove NTP, however, I remember a while back systemd-timesync took nearly 2/3X longer to sync than NTP in my tests. May be a configuration issue (the old one), but yep, I'll look at removing NTP and switching to systemd-timesync if its viable.
But then, dbus installed by default, larger image (1MB, not too bad)


🈴 30-60 seconds to sync on RPi with systemd
🈯️ 8 seconds ntpd

🈴 Spawns another BG process systemd-timedated, which if stopped after systemd-timesyncd, resets timedatectl status.
🈴 Dbus additional pre-req

@MichaIng

Ok, will leave NTP in for now (due to https://github.com/Fourdee/DietPi/issues/1580#issuecomment-370569005), i did make all the changes in a new branch to test:
https://github.com/Fourdee/DietPi/commit/29e7f53443ed0337301582cf31626dc19d7aafa9

Worth mentioning softwares like OpenMediaVault depends on NTP, No NTP, no OMV

I fightinhg right now to keep OMV & NTP, but it fails because it waits for timesyncd completion..frustrating.

@ShinobiWPS
No big problem, just set dietpi-config > Advanced Options > Time sync mode > 0 Custom and DietPi will work flawlessly with NTP. It does not check successful time sync state though, but expects NTP to do it's job successfully.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fourdee picture Fourdee  Β·  3Comments

pgferr picture pgferr  Β·  3Comments

and09 picture and09  Β·  3Comments

Fourdee picture Fourdee  Β·  3Comments

Fourdee picture Fourdee  Β·  3Comments