Skip to content
/

Correcting time drift with CentOS on Hyper-V

I was having trouble with the clock in my Linux Hyper-V VM’s. The time was constantly drifting forward. Using NTP (Network Time Protocol) only slowed the drift a bit down but often the NTP service gave up after several days.

I tried a lot of NTP configurations, but basically the local clock was just unreliable. Even using rdate every 10 minutes was already showing backwards jumps of several seconds. As one of my VM’s is running dovecot this really was a problem because dovecot hates time moving backwards.

I finally found the solution posted by Mat Mirabito in his blogpost Linux (specifically CentOS running trixbox) gains excessive time on system clock.

Edit your grub.conf and add the following to the kernel line:

divider=10 clocksource=acpi_pm

After this it works like… clockwork :)

9 Comments

  1. /

    Thanks for the entry, helped me with my 2 virtual DNS in Hyper-V

    • /

      I'm glad I could help :)

      It took me a year before finding a solution and I hope this post will prevent others from having such a long frustrating time.

  2. /

    I added like below but now solved.

    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
    divider=10 clocksource=acpi_pm

    is it correct?

  3. /

    @Ken Kim:

    No, the divider part should be added on the end of the line starting with "kernel".

    title CentOS (2.6.18-164.el5)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup00/LogVol00 divider=10 clocksource=acpi_pm
    initrd /initrd-2.6.18-164.el5.img

  4. /

    Did you keep the time synchronization service in hyper-v for that machine?

    Also I have 2 kernel lines, should I add it to both?

  5. /

    Hello, thanks for the tip.
    But I think you'll have to do it again in case of kernel/grub update.
    I was looking for something more permanent but I couln't find anything now.

  6. /

    Try using Linux Integration Services v3.2.
    You don't need to compile those to every kernel version, and it's not requireing the kernel line adjustments in the grub file. At least for my VM running CentOS 6.2.

    http://www.microsoft.com/en-us/download/details.aspx?id=28188

Trackbacks and Pingbacks

  1. Microsoft releases Linux Integration Services for Hyper-V 2.1 Beta | Michaël's coding thoughts
  2. Tonys Tech Blog» Blog Archive » Hyper-V Centos VM date time clock gains hours even with ntp

Leave a comment