Overview
In virtual environments CPU processing is shared between the virtual machines, typically this uses a method called time slicing; Each virtual machine is allocated a period of time where the core’s will be free to use, during that period other machines are actually just waiting for their time slice. This generally is a fast process, to fast for us humans to notice.
However Linux machines use the CPU to keep track of time, this is find for dedicated servers where the CPU is dedicated therefore a cycle always takes a specific amount of time. However in the virtual environment where a cycles processing time varies this calculation is no longer accurate. As a result this causes what’s know as time drift, where the clock is not kept synchronized.
How To
The easiest fix is change the way in which the system keeps track of time, you do this by editing the kernel boot options as shown below.
Take care as an error’s will prevent your system from booting.
Make a backup should anything go wrong.
cp /grub/grub.conf /grub/grub.conf.backup
Open the file to make the required changes.
nano /grub/grub.conf
Add the following text to the kernel line.
If the OS is 32 Bit:
divider=10 clocksource=acpi_pm
Or if the OS is 64 Bit:
notsc divider=10
Finally save the file, and reboot the server.
reboot
6 comments On Linux (CentOS) Hyper-V time drift
Cool, helped me a lot!
i don’t have /grub/grub.conf:
# cat /etc/redhat-release
CentOS release 5.5 (Final)
# cd /grub
-bash: cd: /grub: No such file or directory
nevermind I found it under /boot 🙂
Yeh it can also be under – /boot/grub/grub.conf
I did that and now it’s exactly 7 hours behind… at least it’s on the right minute. Timezone seems correct. Still digging.
If it’s right on the minuet really does sound like time zone’s.
Is your host server’s time correct?