I’ve been running VirtualBox for a couple of years now but lately I’ve been having problems with the time synchronization between my 32-bit Windows XP guest and my 64-bit Ubuntu Linux 10.04 host in VirtualBox 3.2.12. Frequently, I’ve noticed that the guest’s clock has been as much as 15 or even 20 minutes slower than the host’s clock.
This magnitude of clock drift can be problematic for many types of programs and use cases. For example, some of my appointment reminders have appeared 15 minutes too late, nearly causing me to miss appointments!
After trolling through the VirtualBox forums for several minutes, I noticed that several other users have had the same VirtualBox slow time problem. Multiple solutions were suggested but many of them didn’t seem to work. At times like this, it’s helpful to go back to the basics and read the “fine” manual (RTFM). In particular, I found this section to be very helpful: Tuning the Guest Additions time synchronization parameters.
There are a number of tunable parameters for time synchronization but I found
--timesync-set-threshold to be the most useful for fixing the time drift. Here’s the description from the manual:
The absolute drift threshold, given as milliseconds where to start setting the time instead of trying to smoothly adjust it. The default is 20 minutes.
Remarkably, the default is a whopping 20 minutes! No wonder my reminders have been popping up so late.
To fix the time sync clock drift, you just need to set
--timesync-set-threshold to a smaller value. How small? That’s up to you. It really depends on how much you can afford your clock to be off. For me, I decided to use 15000 milliseconds (15 seconds). For you, maybe it will be 60000 milliseconds (1 minute). I’m not sure if there are any side-effects if you set the threshold too low.
To set the threshold to 15 seconds, run the following command on the VirtualBox host:
VBoxManage guestproperty set “the name of your guest VM” “/VirtualBox/GuestAdd/VBoxService/–timesync-set-threshold” 15000
Don’t forget to replace “the name of your guest VM” with the name of your VM. Note that I did not have to run the command as
sudo but your mileage may vary.
If the above command doesn’t seem to work, try power cycling your VirtualBox guest. That did the trick for me.
If you ever want to see the current value of
--timesync-set-threshold simply run this command on the VirtualBox host:
VBoxManage guestproperty get “the name of your guest VM” “/VirtualBox/GuestAdd/VBoxService/–timesync-set-threshold”
If you try my technique to fix a slow clock in VirtualBox, please leave a comment here to let me know if it worked for you.