Linux – time / timezone of Linux VM on Hyper-V

centoshyper-vhyper-v-server-2008-r2linuxtimezone

HI there
I installed a CentOS VM on Hyper-V server and am quite confused on the time settings.
my Hyper-V is set to (UTC-05:00) Eastern Time (US&Canada), and when installed the CentOS VM, on TimeZone selection, I chose System clock uses UTC and America/New York.
everything looks alright except the clock is showing (UTC-05:00-04:00) EDT.

I am new to Hyper-V and Linux VM, but i think what happens is the Linux VM takes the Hyper-V host time literally as UTC, since i choose America/New York timezone, it does the UTC-4 (with daylight saving), so the clock is 4 hours behind. I am not sure how to fix this. i reset the clock but when rebooted the VM starts with the wrong time again..

how should this work? do i have to set the Hyper-V server to "real" UTC time? this doesn't seem right, and i am hoping i am missing something simple. i didn't find anything related to this yet, so any help/insight is much appreciated. i wouldn't think this is a new problem?

also i disabled the time synchrnization integration service as i haven't installed the integration service on the guest yet.
Thanks for your help.

Best Answer

Windows (and Hyper-V by extension) keep the "CMOS Clock" (even on VMs) in local time, not UTC. Most *nix platforms keep it in UTC then display it in local time.

By default Hyper-V will set the clock of the VM, which in this case will set the VMs clock to your local time (EST/EDT). The *nix VM will need to be set to recognize this, as it's not the default (usually).

Alternately, you can disable Hyper-V's time sync, and have the *nix client sync it's own clock via NTP or similar. This will lead to occasional clock irregularities because the VM's clock isn't an independent piece of hardware, it's software running on the host (and isn't perfect; this isn't a problem unless your application requires a high precision clock).

Edit:
I don't know Linux, got this from someone else: For CentOS edit /etc/sysconfig/clock to include these lines:

UTC=false
ZONE="America/New York"

There may be other lines in the file, not sure what they should be. Enable Hyper-V's Time Sync, and the VM should have the correct time (as long as the host does).