Ensure that cmdline has no other time/clock related parameters, but only "clock=pit".
To check/modify:
- open the file /etc/default/grub
/etc/default/grub
- find the line with text GRUB_CMDLINE_LINUX_DEFAULT
GRUB_CMDLINE_LINUX_DEFAULT
- ensure all is correct there, clocksource=pit set and NO other timer/clock related parameters existing
clocksource=pit
- save file if changed
- run "update-grub" to re-generate grub.cfg
update-grub"
- run "apt-get install ntp"
- stop the service by command "service ntp stop"
- backup the file /etc/ntp.conf and replace the content as shown below:
/etc/ntp.conf
tinker panic 0 tos maxdist 16 driftfile /var/lib/ntp/ntp.drift server 172.30.66.8 iburst preferserver 0.au.pool.ntp.org iburstserver 1.au.pool.ntp.org iburstserver 0.oceania.pool.ntp.org iburst restrict -4 default kod notrap nomodifyrestrict -6 default kod notrap nomodify restrict 127.0.0.1restrict ::1
tinker panic 0
tos maxdist 16
driftfile /var/lib/ntp/ntp.drift
server 172.30.66.8 iburst preferserver 0.au.pool.ntp.org iburstserver 1.au.pool.ntp.org iburstserver 0.oceania.pool.ntp.org iburst
server 172.30.66.8 iburst prefer
server 0.au.pool.ntp.org iburst
server 1.au.pool.ntp.org iburst
server 0.oceania.pool.ntp.org iburst
restrict -4 default kod notrap nomodifyrestrict -6 default kod notrap nomodify
restrict -4 default kod notrap nomodify
restrict -6 default kod notrap nomodify
restrict 127.0.0.1restrict ::1
restrict 127.0.0.1
restrict ::1
- start the service "service ntp start"
Set ntp to start automatically after boot
update-rc.d ntp enable
If it is the fresh Ubuntu install, jump to step 6.
If your Ubuntu setup has the time drift fix applied earlier from our different article, do additional steps as below.
- open the file /etc/rc.local
/etc/rc.local
- remove the string sh /etc/clocksync/clocksync.sh &
/etc/clocksync/clocksync.sh &
- save the file
- uninstall adjtimex by "apt-get purge adjtimex"
adjtimex
- if the file /etc/adjtime exists, edit it, remove all lines with digits and replace word UTC by LOCAL
/etc/adjtime
- if existing, remove /var/lib/ntp/ntp.drift
/var/lib/ntp/ntp.drift
Set the ntp.conf file
# nano /etc/ntp.conf
It should read like this (if it does not please change it to the below accordingly):
tinker panic 0tos maxdist 16driftfile /var/lib/ntp/ntp.driftserver 172.30.66.8 iburst prefer minpoll 3server 0.au.pool.ntp.org iburstserver 1.au.pool.ntp.org iburstserver 0.oceania.pool.ntp.org iburstrestrict -4 default kod notrap nomodifyrestrict -6 default kod notrap nomodifyrestrict 127.0.0.1restrict ::1
CTRL-O to save
Sync the time
# ntpd -gq
Reinstall adjtimex
# apt-get install adjtimex
This stops NTP, forces it to sync the clock (to “prime the pump”), sleeps for 100 seconds, forces a second clock sync, and restarts NTP. It produces output like this:
# /etc/init.d/ntp stop ; ntpd -q ; sleep 100s ; ntpd -q; /etc/init.d/ntp start
Stopping NTP server: ntpd.ntpd: time set +12.262938sntpd: time set +2.603381s <— drift per 100sStarting NTP server: ntpd.
If the second time set is +2.60 then run this command (these don't have to be exact):
# adjtimex -t 10260
If the second time set is -2.60 then run this command (these don't have to be exact):
# adjtimex -t 9740
Stopping NTP server: ntpd.ntpd: time set +3.044932sntpd: time set -2.659021sStarting NTP server: ntpd
Most likely this will now report for example 2.6 in the other direction. This is normal. Now return the adjtimex to the default value:
# adjtimex -t 10000
Then reprime again:
You should now see an output like this:
* Stopping NTP server ntpd [ OK ]ntpd: time set -2.653074sntpd: time slew -0.006406s* Starting NTP server ntpd [ OK ]
Note that it now reports time slew (as it's only a very minor amount out). This is great.
You can now type:
# watch ntpq -p
This should report the current status of the NTP servers and you should see the jitter falling down to below 3 on the 172.31.66.5 server. Your time is now sync'd correctly.