Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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.

share|improve this answer
    
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 5:57
    
And, skipping cron jobs is not critical for me, this host is used for developing only. –  leafduo Jul 23 '11 at 5:58
add comment
$ 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.

share|improve this answer
    
I don't have kvm-clock as an available clocksource, why? –  leafduo Sep 9 '11 at 8: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. –  user67717 Sep 9 '11 at 11:16
    
kvm-clock would only work if you were using KVM not VMware Fusion. –  user67717 Sep 9 '11 at 11:17
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.