I have a VM with Oracle Linux 5.5 where the BIOS clock (also known as hardware clock or RTC) is wrong after boot.
What I did:
- boot the guest Linux VM with the boot parameter
init=/bin/sh - check time with
hwclock -ror simplydateas the sys time is initialized from RTC
Result:
Time is wrong, about a day in past.
According to references below, Hyper-V sets the VM RTC on boot to current host time.
But in my case this is not happening. Why?
It seems the last set clock value is saved/remembered instead of setting the current correct time. More exactly:
- if I store into RTC a date in past (like Jan 1), the on next boot the value will read as Apr 16 (today is Apr 18)
- if I store into RTC a date in future (like Jul 7), the on next boot the value will read as Jul 7
Is maybe the initramdisk interfering? I tried to bypass it too, but it seems it is required to mount the root fs.
The VM is running Oracle Linux 5.5 (based on Redhat Enterprise Linux 5.5).
References:
Microsoft blog "Time Synchronization in Hyper-V" https://learn.microsoft.com/en-us/archive/blogs/virtual_pc_guy/time-synchronization-in-hyper-v
whenever you start a virtual machine we take the time from the management operating system and put this into the real-time clock of the virtual machine.
serverfault answer at Completely disable Date and Time sync in a Hyper-V VM
Hyper-V guests always synchronize time with the host on BIOS level during boot.