2

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.

2 Answers 2

0

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).

7
  • I don't know how HyperV will deal with it, but inconsistencies between VM and Host time are deadly to Linux (at least on Xen and KVM), mainly when Host time changes too fast and too much (clock skew). The solution was to use the ntpd daemon on everything (hosts and VMs) to keep it from happening.
    – coredump
    Apr 13, 2011 at 12:57
  • @Coredump, I've never seen any problem like that using Hyper-V; I know Xen is a different story as you say. I've always used Hyper-V's clock sync without issues, but these were always test/dev environments, not production.
    – Chris S
    Apr 13, 2011 at 13:01
  • @Chris S, thanks for your answer, but i am not sure i understand it. or can translate this to action:). as you said, the VM is taking the Hyper-v's current time as UTC time then set it to it's EDT timezone. i think i've disabled the time sync--by disabling the integrationservice's time sync (which isn't installed), i can set NTP up, but i think this is different. the initial time is wrong. i need to somehow break the link between hyper-v and vm on reboot, or when booting up, to get the time from NTP, but i dont know how to do this.
    – jasy
    Apr 13, 2011 at 13:03
  • Hyper-V's time sync doesn't rely on the integration service, you don't need them installed for it to work. There's no way to break the time sync on reboot or initial boot. It's a VM, there's no real computer to keep time; when it's off the "machine" doesn't exist. Setting time via NTP on boot is something both ntpd and ntpdate can do at boot. See your rc.conf or equivalent for details. Also you can set your VM to recognize that the 'CMOS Clock' is in local time, see your OS's Time Zone settings for details.
    – Chris S
    Apr 13, 2011 at 13:42
  • @Chris S, thanks for your reply, sorry that i am too thick. what i taken from above is 1>the vm takes Hyper-V's time as the initial time (CMOS clock) and appends it's timezone to it 2>after boot, force ntpdate sync to the correct time through a ntpserver 3>after this using the ntpd to maintain correct timing. this process needs to repeat each time the machine is booted. my setup doesn't have a rc.conf.. were you referring to a specific link for OS's Time Zone setting? i am in the process of trying to figure out how to do above step 2 and 3. please comment if i am on the right path. many thanks
    – jasy
    Apr 13, 2011 at 15:54
0

Please see the following:

NTP time sync not working in a DOMU Centos 5.5 server

2
  • Xen and Hyper-V work very, very differently. These are pretty much different problems.
    – Chris S
    Apr 13, 2011 at 13:44
  • thanks Greg for your help. i think the problem you solved is different from mine. i am having trouble to set the correct time at boot time, i think yours is for syncing time when clock is running incorrectly (time skew/drift).
    – jasy
    Apr 13, 2011 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .