Timesync on HyperV with CentOS 6.2
Solution 1:
I've had this issue in the past and corrected it by tweaking the startup switches (notsc divider=10) and ntp settings:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.6.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=/dev/VolGroup00/LogVol00 hda=noprobe hdb=noprobe notsc divider=10
initrd /initrd-2.6.18-164.6.1.el5.img
title CentOS (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-164.el5.img
Sample ntp.conf:
tinker panic 0
restrict 127.0.0.1
restrict default kod nomodify notrap
server 0.vmware.pool.ntp.org
server 1.vmware.pool.ntp.org
server 2.vmware.pool.ntp.org
driftfile /var/lib/ntp/drift
Source:
Correcting Linux Clock Drift on Hyper-V on Server 2008 R2
http://hardanswers.net/correct-clock-drift-in-centos-hyper-v
Solution 2:
Hyper-V Linux guest clock drift under load is sadly quite common (clock drift in unsynchronised VMs is somewhat unavoidable). See Linux clock loses 10 minutes every week and Hyper-V Machine drifts time all over, even with NTP for other posts talking about it. Anecdotal evidence I've seen says the following:
-
The Hyper-V host's clock is only used to set the Linux guest's clock on startup with current kernels (up to and including at least mainline 3.16 kernels or integration services 3.5). If you are using such Linux kernels, it does not matter what options you set in Hyper-V Manager nor will it matter that
current_clocksource
ishyperv_clocksource
- your clock will drift after boot and won't be corrected unless you run one of the synchronisation programs below. There is a lot of complicated Windows oriented and conflicting information surrounding this topic and oft repeated terms like "pluggable time source" to understand. -
ntpd
is unable to correct the amount drift that can occur in a Linux Hyper-V guest and you will either have to use regular brute force ntpdate synchronisations (bad) or an ntp service such aschrony
(better) to correct large clock drifts.