ntpd and Re: [ltp] getting correct time on a laptop (IBM ThinkPad T23)

Martin Steigerwald linux-thinkpad@linux-thinkpad.org
Mon, 26 Jun 2006 07:36:36 +0200


Am Montag 26 Juni 2006 00:13 schrieb Florian Reitmeir:
> On Son, 25 Jun 2006, Martin Steigerwald wrote:
> > Am Sonntag 25 Juni 2006 20:06 schrieb George Yanos:
> > > I've been reading along on this thread and have a question.  What
> > > is the reason NOT to use ntpd by itself.  It seems to keep my
> > > laptop perfectly in sync with my time server, which keeps itself
> > > perfectly in sync with USNO.
> >
> > my laptop is without network connections for several days sometimes
> > and the hardware clock is very inaccurate. I did not record it
> > exactly, but 5 minutes off in 1-2 days is easily possible.
> >
> > Chrony records that inaccuracy even without network access - as good
> > as it can estimate it - and adjusts its the clock accordingly.
>
> i hope it common knowdledge that the linux kernel doesn't use the
> hardware clock to measure time.

Hello Florian,

on start it copies the hardware clock time to the system clock... when the 
hardware clock has been inaccurate, it uses an inaccurate time to begin 
with. Chrony accomodates for this situation when it is working properly.

Also chrony makes sure the hardware clock is synchron with system clock 
when rtcfile is defined. If it can access NTP servers and is switched 
online, it synchronizes system clock time with NTP time.

Actually this is what I want. One solution to get the time right,no matter 
what. (Given that the inaccuracy of the hardware clock is quite 
predictable, I think it will become inaccurate again when the laptop is 
without net for a really long time, but it should accomodate for a few 
days without network access quite accurately.)

> the kernel uses one of the timer to measure time, and time should
> always go forward and never jump backward. (ntpdate via cron is a
> really good way to crash filesystems/databases ...)

I know that software may misbehave on such time changes, but how could a 
filesystem crash? The integrity of a filesystem IMHO should never depend 
on a working clock. Do you have any details on this?

> - ntpd is a finetuning tool, its not designed to make large adjustments

Chrony seems to do a larger adjustment, when it is started - to accomodate 
for the inaccuracy of the hardware clock... but when its running it does 
small adjustments as well.

> - adjtimex is the tool to get really broken hardware in shape..

adjtimex seems to need quite some manual interaction aka "adjtimex -h 
pool.ntp.org" to get it at least approximately right. Chrony seems to do 
a better job, when I work around its limitations (doesn't detect 
automatically whether NTP servers are accessible).

> so in your case, first..
> - test the bios time, is it working correct? (read it, turn the laptop
> off, read it again.. )

Well its not working accurately. Probably I didn't tell it clearly yet, 
but my observations have been that time is inaccurate after the laptop 
has been switched off for a while. 

I know I should replace the CMOS battery, but until I manage to do that I 
still want to have correct time on that notebook.

> - if its not the bios time, then correct which hwclock/adjtimex your
> timer, so openntp/ntpd/chrony can work.

Chrony cannot work with adjtimex as it has this functionality implemented.

Anyway I think I have something working right now... still needs some more 
testing. If it works, I post a HOWTO about it.

Regards,
-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7