3

I have Gentoo installed as guest OS. I have hardware clock synced with host system, but the clock of OS tend to be wrong after suspend.

The only solution I find out is run hwclock -s frequently via cron.

Any better method?

leafduo
  • 31
  • 1
  • 4

4 Answers4

3

VMware tools might do this for you, but Gentoo is not in the guest compatibility list so it may not work, or may take a lot of effort to get working.

You could use ntp to keep the clock up to date, or schedule ntpdate to run. I am not sure if these are better methods than hwclock -s.

One thing you may want to avoid is a method that simply changes the clock time - that will result in cron jobs being skipped. ntp speeds up the clock to get to the correct time. ntpdate changes the clock time.

dunxd
  • 9,482
  • 21
  • 80
  • 117
  • For me, the only difference between `ntpdate` and `hwclock -s` is that `ntpdate` requires network, because the host is ntp-synced. But ntpd takes a long time to catch up after suspend for a day. :-( – leafduo Jul 23 '11 at 05:57
  • And, skipping cron jobs is not critical for me, this host is used for developing only. – leafduo Jul 23 '11 at 05:58
0
$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource
kvm-clock tsc hpet acpi_pm 

$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc

Can't rely on TSC http://en.wikipedia.org/wiki/Time_Stamp_Counter

Try hpet or acpi_pm

Plus kernel command line option clocksource=hpet (set inside boot loader configuration.)

See Documentation/kernel-parameters.txt in Linux source.

  • I don't have kvm-clock as an available clocksource, why? – leafduo Sep 09 '11 at 08:05
  • Last night I had just gotten in bed when the thought that timesource was the issue. I had to write it down or I'd forget. My only Gentoo-on-VMware fusion VM guest is miles away. I edited my comment this morning taking out some KVM-specific stuff. I am pretty KVM-centric. –  Sep 09 '11 at 11:16
  • kvm-clock would only work if you were using KVM not VMware Fusion. –  Sep 09 '11 at 11:17
0

I built a new Gentoo VM guest on VMware Fusion 3.1.3 on another Macbook and installed open-vm-tools which is in portage. I had to unmask two packages but they built OK.

The /usr/bin/vmtoolsd process keeps the guest clock in sync with the host clock. It does some other housekeeping too. Admittedly it may take a short while for it to bring the clock into sync but it does it for me.

To get accelerated I/O etc. you want to activate these kernel options too:

  • VMWARE_PVSCSI
  • VMXNET3
  • VMWARE_BALLOON

They don't require a "tools" package as the upstream kernel contains those drivers by default now. The open-vm-tools-kmod package contains additional driver modules. My config file is visible in this gist:

https://gist.github.com/1209749

I didn't actually read this wiki entry, I just installed the packages and configured the startup scripts and kernel options myself but it might be useful:

http://www.gentoo-wiki.info/HOWTO_Install_VMware_Tools_in_Gentoo

0

Though the question is quite old, here's another preferable solution to the problem:

  1. emerge app-emulation/open-vm-tools
  2. make sure that "/usr/bin/vmtoolsd" is running as root (no init script provided by now)
  3. enable automatic time sync via "vmware-toolbox-cmd timesync enable". The status can be checked via "vmware-toolbox-cmd timesync status"

This way, the clock of the guest will always match the host's clock, even if the VM is suspended. Other methods like running ntpd or ntpdate failed for me. And, yes, the clock will jump and cron jobs might be skipped ;)

Jannis
  • 101
  • 1