How to catch up vmware clock to accurate time after a virtual machine pause/un-pause

‹ Light Vader | Using Docker in Mac OSX with VMWare Fusion and docker-machine ›

When you pause a VMWare Fusion virtual machine on a Mac OSX host and resume it after a long time, your system clock will sometimes be behind. ntpd won't catch the clock up if it's too far behind. One manual solution is to run ntpdate in the guest operating system once the virtual machine unpauses:

sudo ntpdate

Another approach which I am currently trying, is to set your clocksource to use acpi_pm instead of tsc. You can check which clocksources you have available with:

% cat /sys/devices/system/clocksource/clocksource0/available_clocksource
tsc hpet acpi_pm

And you can check which one you're currently using with:

% cat /sys/devices/system/clocksource/clocksource0/current_clocksource

Changing the default can be done with the kernel command line. In Ubuntu 14.04, this can be done by:

  • Edit /etc/default/grub
  • Add these parameters to GRUB_CMDLINE_LINUX:
    GRUB_CMDLINE_LINUX="divider=10 clocksource=acpi_pm"
  • divider=10 is supposed to reduce the load that the virtual machine puts on the host operating system by increasing time slices from the normal value of 1ms to the more coarse-grained value of 10ms.  It may not actually be necessary for this to work.
  • Run sudo update-grub
Subscribe to All Posts - Wesley Tanaka