KVM guests and synhronizing clock

I was launching a couple of Ubuntu 14.04 KVM guests and I ve noticed that time was wrong. OK I thought, a simple ntpdate command and ntp service enabled will fix the issue. Made a reboot of the guest host and show that the time was ok. Then I destroyed the guest and when I checked the time it was wrong. This can’t be right, I thought, and started researching what might be the issue. What I found is that KVM guests should always consider their hardware clock in UTC time while my guests configuration was in local time.

In order to fix the hardware clock on Ubuntu systems you need to edit file /etc/default/rcS and change the line

UTC=no

to

UTC=yes

then execute the following commands

 # service ntp stop
# ntpdate -u pool.ntp.org
# service ntp start

bonus command on how to see what time is on your hardware clock

 # hwclock --show

Links
http://sophiedogg.com/kvm-clocks-and-time-zone-settings/
http://serverfault.com/questions/469598/kvm-guest-time-shift-on-host-reboot
http://stackoverflow.com/questions/26005056/synchronizing-clock-time-in-host-and-guest-under-kvm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s