Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
810 stars 187 forks source link

Time synchronization on ThinStation #849

Open Maksim-Garikov opened 2 months ago

Maksim-Garikov commented 2 months ago

I have added the server address for time synchronization on ThinStation. The address is added to thinstation.conf.buildtime under the NET_TIME_SERVER parameter. However, time synchronization does not automatically occur when ThinStation boots via PXE.

The issue is resolved by executing two commands: ntpdate -u ip_address hwclock --systohc Where "ip_address" is replaced by my IP address for time synchronization.

However, I need this to be automated. How can I do this? I tried doing this through /etc/rc.local, after which I rebuilt the image. I also tried creating a script in /usr/local/bin (execution permissions are added) and adding the script path to /etc/rc.local. But after building the image, time synchronization does not automatically occur.

How can I automate this?

For example, in a Linux distribution, you can add a script to /etc/init.d/ and run the command: update-rc.d ntp_sync defaults But in this case, I need to build the image, which will also include the execution of the script.

What solution is available to automate the time synchronization process when booting the image via PXE?

Thinstation commented 2 months ago

look at /build/packages/ntp/etc/init.d/ntpd

Thinstation commented 2 months ago

Try setting WAIT_FOR_TOCK=true in your conf file.

Maksim-Garikov commented 2 months ago

I tried modifying the ntpd configuration file. After building the image, I can see the addresses that were added, including those in /etc/ntp.conf. However, the time on the thin client does not match the real time.

Is the parameter "WAIT_FOR_TOCK=true" supposed to be added to the thinstation.conf.buildtime configuration file?

Thinstation commented 2 months ago

It can be. I just made it default and pushed. The way the ntpd file is written, the system time would update after 1 hour, but if WAIT_FOR_TOCK is true, it will do the update during init.

Thinstation commented 2 months ago

This is the kind of thing that only shows up when there is something wrong with the RTC or it's battery. If the RTC is working correctly/keeps good time, then the delayed update would only appear once, like when a system is new or moved to a different time zone.

Maksim-Garikov commented 1 month ago

I added the WAIT_FOR_TOCK parameter to the config. I also modified the ntpd config by adding the hwclock --systohc commands. However, after turning on the thin client, automatic time synchronization does not occur. How can I add the automatic execution of 2 commands upon startup? Is it possible to add the automatic execution of 2 commands upon startup through a parameter in the thinstation.conf.buildtime file? ntpdate -u ip_server hwclock --systohc I also tried adding the IP addresses of the time synchronization servers to the DHCP server settings, but the time still doesn't synchronize. Only after executing two commands does the time synchronization succeed, but I need to automate this process.

Thinstation commented 1 month ago

Maybe what's happening is that the ntpdate command is timing out before it can succeed. Things happen very fast during boot, and the network might not get up in time. I did some cleanup on the ntpd init process yesterday and pushed to github. I broke it out of the old autonet routine and added some hooks for networkmanager. You can now verify when and how long it ran with systemd-analyze plot.

Thinstation commented 1 month ago

I've made a few updates to the time packages of TS. I added a new ntpd package, that will use ntpd instead of ntpdate. It should update the RTC on shutdown. I also worked out the changes needed for systemd-timesyncd, but it will not write to the RTC.

rohrbachger commented 1 month ago

I had similar issues, solved it with a none professional solution. We are booting with iPXE. Windows DHCP,DNS.

But has worked for years now. I will look at your updates. CRON_JOB1='@reboot /bin/ntpdate x.x.x.x'

Another issue is, that the DNS record is not updated with the hostname in an PXE boot, because of security settings in AD. This is for remote support in local network helpfull, but only seldom needed.