How to disable time sync between host and guest

Discussions about using Windows guests in VirtualBox.
sirius07
Posts: 1
Joined: 29. Apr 2011, 14:00
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: win

Re: How to disable time sync between host and guest

Post 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
GladToBeMad
Posts: 1
Joined: 30. Aug 2011, 09:23
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: WinXP, Ubuntu

Re: How to disable time sync between host and guest

Post 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.
Sands
Posts: 14
Joined: 24. Jul 2009, 11:10
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Win7 Build 7232 64bit Asus P5Q3

Re: How to disable time sync between host and guest

Post by Sands »

Bump for learning about time syncing
acsfea
Posts: 2
Joined: 26. Mar 2008, 15:42

Re: How to disable time sync between host and guest

Post by acsfea »

What and where are files to be changed on a linux host?
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Re: How to disable time sync between host and guest

Post by stefan.becker »

The files are in "~/.VirtualBox" and "~/VirtualBox VMs/Name of the Guest".
Dullax
Posts: 1
Joined: 11. May 2012, 03:58

Re: How to disable time sync between host and guest

Post 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
Johnye
Posts: 4
Joined: 17. Sep 2015, 19:03

Re: How to disable time sync between host and guest

Post 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!
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to disable time sync between host and guest

Post 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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
SW-Hogo
Posts: 1
Joined: 16. Jan 2016, 13:18

Re: How to disable time sync between host and guest

Post 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
saur
Posts: 5
Joined: 30. Jun 2017, 19:23

Re: How to disable time sync between host and guest

Post 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!
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to disable time sync between host and guest

Post by socratis »

saur wrote:Any way to achieve this?
Absolutely. By reading the thread. Or the manual. Your choice really...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to disable time sync between host and guest

Post 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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to disable time sync between host and guest

Post by socratis »

I completely misread that one, my apologies. :shock:
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
TomStilo
Posts: 1
Joined: 24. Oct 2017, 11:36

Re: How to disable time sync between host and guest

Post 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:
Locked