Page 2 of 2

Re: How to disable time sync between host and guest

Posted: 29. Apr 2011, 14:45
by sirius07
Hi folks, had the same problem, still synching...
Solution which works for me:
put this (now wellknown) line

Code: Select all

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>
into "both" xml-files (VirtualBox.xml & nameofthemachine.vbox), restarting vbox manager gui and my machine.
Now, only onetimesyching at startup of guest, i can change time of guest and it don't change anymore 8)
Even a restart of the guest will hold the "wrong" time, as long as you don't shut down the guest.
Host: win xp
guest: w2k

Re: How to disable time sync between host and guest

Posted: 30. Aug 2011, 09:27
by GladToBeMad
VirtualBoxService.exe --disable-timesync works for me flawlessly. But one should be careful, after installation of a new Guest Additions this command line must be set again.

Re: How to disable time sync between host and guest

Posted: 13. Jan 2012, 01:55
by Sands
Bump for learning about time syncing

Re: How to disable time sync between host and guest

Posted: 29. Jan 2012, 05:01
by acsfea
What and where are files to be changed on a linux host?

Re: How to disable time sync between host and guest

Posted: 29. Jan 2012, 09:09
by stefan.becker
The files are in "~/.VirtualBox" and "~/VirtualBox VMs/Name of the Guest".

Re: How to disable time sync between host and guest

Posted: 11. May 2012, 04:01
by Dullax
The last post worked for me - I directly went to the XML and added the line above. Guest Additions have been installed and still did not need the service to be stopped. :D

Re: How to disable time sync between host and guest

Posted: 23. Sep 2015, 14:42
by Johnye
I know this is an old topic, but as msa.operations said (5 years ago) it's still the 1st result on Google when searching for "VirtualBox disable time synchronization".

After "upgrading" from Virtual PC 2007 to VirtuaBox v5.0.4 I bumped into the same problems:

1. VirtualPC disables time synchronization if the following code is manually added between mouse and video in the guest's config file (.VMC):

Code: Select all

<components>
	<host_time_sync>
		<enabled type="boolean">false</enabled>
	</host_time_sync>
</components>
VirtualBox does the same by either not installing Guest Additions (not recommended) or by running the following line everytime Guest Additions are installed / updated:

Code: Select all

VBoxManage setextradata "GuestName" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
2. VirtualPC automatically saves the guest's current date/time in the .VMC file so it's loaded again on next startup. The line is similar to this:

Code: Select all

<time_bytes type="bytes">21001900110005310715</time_bytes>
VirtualBox doesn't support this (that I know of, please correct me if I'm wrong), but there is a workaround for XP Professional and possibly other versions of Windows. VirtualBox normally uses the host's time when the guest is started, so the workaround uses a batch file to save current date/time to a text file inside the guest during shutdown, then loads it again during login, which is enough for me. This is how it's done:
- double click on the clock, go to "Internet Time" tab and disable online time synchronization;
- create the file C:\datetime.cmd inside the virtual machine;
- paste the following code inside:

Code: Select all

@echo off
setlocal enabledelayedexpansion

if /i [%1]==[save] (
  for /f %%a in ('date /t') do set "ldt=%%a"
  for /f %%a in ('time /t') do set "ldt=!ldt! %%a"
  echo !ldt! > C:\datetime.txt
)

if /i [%1]==[load] (
  set /p ldt=<C:\datetime.txt
  for /f "tokens=1*" %%a in ("!ldt!") do (
    date %%a
    time %%b
  )
)
- Open policy editor (Start > Run > gpedit.msc);
- Navigate to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown);
- Add "C:\datetime.cmd save" on Shutdown and "C:\datetime.cmd load" on Startup.

Now Windows XP saves the date and time to C:\datetime.txt on shutdown and reloads it on startup. This is what was added to the registry with the previous commands, maybe it will work for XP Home and other versions of Windows that don't have Policy Editor, just copy/paste the lines to a .reg file and try them.
Warning: Please manually check the keys of your registry. If you already have a Startup\0\0, Startup Startup\0\1, etc please change the last number in the line below to an unused one so it doesn't overlap an existing script. The same applies to Shutdown\0\0, Startup Startup\0\1, etc

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="c:\\datetime.cmd"
"Parameters"="save"
"ExecTime"=hex(b):df,07,09,00,02,00,16,00,0a,00,03,00,09,00,6b,02

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0]
"Script"="C:\\datetime.cmd"
"Parameters"="load"
"ExecTime"=hex(b):df,07,09,00,03,00,17,00,0a,00,35,00,1f,00,e0,02

Have fun!

Re: How to disable time sync between host and guest

Posted: 24. Sep 2015, 18:01
by socratis
You might have missed Andre's answer back from 08.08.2008:
Andre.Ziegler wrote:The only chance to set back the Date in VirtualBox is to run the following command:

Code: Select all

VBoxManage modifyvm <name> -biossystemtimeoffset -<milliseconds>
More information on the user manual Chapter 8.8.1.

Re: How to disable time sync between host and guest

Posted: 16. Jan 2016, 13:26
by SW-Hogo
This Script works for me

Source: superuser com\questions\742924\is-it-possible-to-get-a-virtualbox-vm-always-start-from-same-time-if-so-how

-------------------------------------------------------------------

Code: Select all

$vbox_path="C:\Program Files\Oracle\VirtualBox"
$vm_name="LinuxMint"
$start_utc=1451610000

#DO NOT CHANGE ANYTHING BELOW THIS LINE
$now_utc_ms=[int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalMilliseconds
$dif_utc_ms=$start_utc * 1000 - $now_utc_ms
Write-Host "START UTC:" $start_utc*1000 " DIF UTC:" $dif_utc_ms " NEW UTC:" $now_utc_ms
cd $vbox_path
.\VBoxManage setextradata $vm_name "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"
.\VBoxManage setextradata $vm_name "VBoxInternal/TM/TSCTiedToExecution" 1
.\VBoxManage.exe modifyvm $vm_name --biossystemtimeoffset $dif_utc_ms
.\VBoxManage.exe startvm $vm_name
Start-Sleep -s 5

Re: How to disable time sync between host and guest

Posted: 30. Jun 2017, 19:24
by saur
Hi everyone,

now it's 2017, and another person has found this thread on Google.

I'm running a Windows host with Linux guest, and want the guest to keep the correct time, while the host is stuck in the past.

Any way to achieve this?

Thanks!

Re: How to disable time sync between host and guest

Posted: 30. Jun 2017, 19:53
by socratis
saur wrote:Any way to achieve this?
Absolutely. By reading the thread. Or the manual. Your choice really...

Re: How to disable time sync between host and guest

Posted: 30. Jun 2017, 20:50
by Perryg
Actually this seems to be the reverse of what people so far have wanted to do ( Host stay in past and guest stay in the present ). The only way that might work is to disable the time sync as stated and then try to use NTP in the guest.

Re: How to disable time sync between host and guest

Posted: 30. Jun 2017, 21:01
by socratis
I completely misread that one, my apologies. :shock:

Re: How to disable time sync between host and guest

Posted: 24. Oct 2017, 18:47
by TomStilo
I did anything but it hasn't any effect.

The XXX.vbox file contains this:
<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/config/GetHostTimeDisabled" value="1"/>

The guest (Win7) get the date&time from host (Win10).
(The time sync service is disabled in Win7, the ntp set to false IP)
WHY????? :?: :!: :mrgreen: