Wednesday, July 4, 2012

Fix VirtualBox Time Sync

Today I needed to do some testing on a VirtualBox VM to ensure that our software handles crossing over midnight correctly, this meant that I either needed to change the time on my VM or wait until midnight to do my testing (yeah that's not going to happen).

That's no problem you might say, ah but you'd be wrong for if you change the time and wait a few seconds then the time will reset itself. Once again I hear you say "no problem, disable 'synchronisation with the Internet time server" and once again you'd be wrong and the reason for this is that VirtualBox syncs the time between your Host and Guest machines.
To prevent this from happening you need to stop your VM and run the following command:

vboxmanage setextradata "VMs Name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Just replace VMs Name with the registered name (how it appears in VirtualBox) of your VM and voilà problem solved.

Note: If that doesn't work you can also modify the vbox file of your VM manually. Open the file with your favourite text editor and add the following line

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>

under the <ExtraData> element.

No comments: