Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Linux system clock does not sync to hardware clock on Hyper-V

Background:

  • You are running Linux on Hyper-V guest VM.
  • Your host machine has scheduled downtime (i.e. is not 24/7 system).

Problem:

When you booted up the host machine, the system clock of guest VM (Linux) will be set to the time you had shutted down the host machine last time.

Time Synchronization option on Hyper-V Manager console doesn't make the situation better.

Solution:

You should sync the system clock with ntpdate, or run hwclock --hctosys periodically with cron:

*/5     *       *       *       *       hwclock --hctosys