Problem: ntpd
, when installed on a virtual machine running Ubuntu (I've had this on hosts with a variety of hypervisors such as KVM and VMware ESX) seem to be prone to severe clock drift. I haven't found any good method and not everyone seems to experience this.
Question: How can I prevent this? Are there any settings in /etc/ntp.conf
to force ntpd
to be more aggressive in synchronizing the time inside the VM or should I use ntpdate -b timeserver
instead inside a cron
job running every so often?
Which method is recommended to avoid leaps when using ntpdate -b
or clock drift in general inside a Ubuntu virtual machine?
Side-note: I've seen similar effects on vios (IBM hypervisor) slaves running AIX as well as on Solaris. So the problem is very real and appears to be related to hypervisors in general.
In VirtualBox at least, you can... I had time sync problems before, but tuning the Guest Additions time synchronization parameters seemed to fix it.
Here is relevant text from the manual:
I observed similar symptoms on a Linux machine running on VMware ESX. It seems that the drift (several minutes per day) was caused by having time synchronization both provided by NTP inside the VM and VMware tools. We solved our problem by disabling time synchronization in the VMware tools properties (in the VM properties in ESX). After that NTP was able to keep the clock in synch with a remote time server. If you prefer to edit the
.vmx
file manually, settools.syncTime = "0"
.Stopping NTP inside the VM and letting the tools synch the time would probably work as well, at least to correct the server drift. ESX itself can run an NTP daemon. VMware's timekeeping best practices recommend using NTP instead of VMWare Tools for time synchronization.
VMware publishes a lengthy paper on timekeeping in VMware virtual machines. The most relevant passage is the subsection “Clocksource Kernels”. The VMware KB also has troubleshooting tips for timekeeping in Linux guests.
In virtualbox you can try to modify the paravirtualisation parameter of your VM.
In the setting of your machine go to: Systeme > Acceleration
This fix the issue for me.