Solved Problem with NTPD and date/time at FreeBSD 10.1

Hi,

Haven't got this problem before so decided to ask community. I have a fresh set-up of 10.1 under XenServer environment. Have set-up clock to local timezone. NTPD tries to adjust time automatically, but the difference is 3 hours is greater than sanity limit, so I have to run: ntpdate pool.ntp.org maually. It goes OK and my time is correct... until the next reboot! Even if I do reboot immediately -- my clock goes back to UTC and everything have to start over again! I have triple checked timezone settings -- everything seems to be correct. Why does system revert to -3 hrs after each reboot?

Thanks,
Vadim.
 
Hi,
Can you set the date manually with the ntpd service off? Something like date 1432. That will set time 2:32 P.M. without a date change. Also see man date.
 
Hi,
Can you set the date manually with the ntpd service off? Something like date 1432. That will set time 2:32 P.M. without a date change. Also see man date.

Yes I can do it. But how it affects reboot? There is no problem setting up the date/time. The problem is that after reboot time is reverted back for 3 hrs. At the same time my timezone is not in UTC.
 
Probably because your BIOS/hardware clock is not being updated by NTP. From the ntpd(8) manual:

Code:
Most operating systems and hardware of today incorporate a time-of-year
  (TOY) chip to maintain the time during periods when the power is off.
  When the machine is booted, the chip is used to initialize the operating
  system time.  After the machine has synchronized to a NTP server, the
  operating system corrects the chip from time to time.  In case there is
  no TOY chip or for some reason its time is more than 1000s from the
  server time, ntpd assumes something must be terribly wrong and the only
  reliable action is for the operator to intervene and set the clock by
  hand.  This causes ntpd to exit with a panic message to the system log.
  The -g option overrides this check and the clock will be set to the
  server time regardless of the chip time.

And date will update the hardware clock. From the date manual:

Code:
The date utility displays the date and time read from the kernel clock.
  When used to set the date and time, both the kernel clock and the hard-
  ware clock are updated.
 
I would say even more - I switched off NTPD and time is still reverted after reboot. So there is somewhere something that makes my system think it is in UTC zone ignoring timezone settings.
 
I am not entirely sure if this affects the host but if your XenServer environment is set to UTC you might want to set your local time to UTC as well.

Edit: I am actually pretty sure that you need to run tzsetup and answer "YES" in the question: Is this machine's CMOS clock set to UTC?
 
I am not entirely sure if this affects the host but if your XenServer environment is set to UTC you might want to set your local time to UTC as well.

I thought about this as well. But my XenServer host (dom0) has local time. I have also created guest VM without guest-utilities so VM has no ability to syncronize time with host (as I guess) unless it is done on kernel-level. So it should be FreeBSD local issue only.

I have checked sysctl settings for adjkerntz and machdep.adjkerntz = -10800 (-3h), but it suppose to be so, because adjkerntz should set UTC witch is -3h for my timezone.
It is really strange (for me) that ntpdate "sees" timezone and updates time correctly, but system does not "remember" this setting after correct time has been set up.
 
I still think that you should give it a try. For some reason, your "BIOS" reports that it is set in UTC to your FreeBSD guest.
 
I still think that you should give it a try. For some reason, your "BIOS" reports that it is set in UTC to your FreeBSD guest.

Experiments with XenServer host shows it has influence on FreeBSD guest even without guest-utilities installed. Particularly this issue : http://www.varrow.com/news/article/172/xenserver-guest-vm-time-issue/ also applied to FreeBSD guest. Initially I have timeoffset=0 (means guest got clock from host in UTC). Changing this value to timeoffset=3 changes guest clock to correct value. Since it is not possible for guest to change host's clock I need somehow to keep this difference at VM guest. Is it possible for FreeBSD to have UTC BIOS clock while working localy with any timezone guest has set up for?
 
Is it possible for FreeBSD to have UTC BIOS clock while working localy with any timezone guest has set up for?

I am not sure I understand your question. In all my servers I have the time set to UTC in BIOS. Try running tzsetup, answer yes when asked, Is this machine's CMOS clock set to UTC and then choose your timezone.
 
I am not sure I understand your question. In all my servers I have the time set to UTC in BIOS. Try running tzsetup, answer yes when asked, Is this machine's CMOS clock set to UTC and then choose your timezone.

This worked for me also. I have noticed that /etc/wall_cmos_clock file has disappeared and after reboot my clock is set to local timezone. Now it seems everything works as it should be. Thank you gkontos!
 
Back
Top