I am trying to manually set the computer's time in VirtualBox but it always resets itself to what it was before I changed it. How can I disable ntp and tell the system what time I want it to be?
I have found a solution. Read the following material: link
Basically if you have Windows host and Ubuntu guest, do the following:
- Find a name of your VM (Virtual Machine) - run VB (VirtualBox), select your VM, open settings, in 'General' tab check the name, e.g. in my case
Ubuntu 12.04 32bit
- In Windows, start a command line interpreter, go to
C:\Program Files\Oraclefolder and click
VirtualBoxto select, then holding left shift key, do a mouse right-button click and select "Open command window here" menu, the interpreter has to be running now
Paste the following command (change the VM name to your name!):
VBoxManage setextradata "Ubuntu 12.04 32bit" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
Finally, start your Ubuntu guest and set the time and date manually.
As mentioned in another answer, if you are running Ubuntu as a Guest under VirtualBox then you should be aware that the system time is automatically kept in sync by the Guest Additions (i.e., not through an option in the motherboard settings).
Your solution in that case is to disable the Guest Additions, which can be achieved by executing
sudo service vboxadd-service stop
sudo /etc/init.d/vboxadd-service stop
You can then set the time as desired (from command line using
date --set or using the system settings applet)
The VirtualBox service will be restarted at next reboot, or you can do it manually.
The only way is to set the time in the Virtualbox motherboard using the command line:
VBoxManage modifyvm <name> --biossystemtimeoffset <msec>
For example, to set back the date 1 year:
VBoxManage modifyvm <name> --biossystemtimeoffset -31536000000
Well, if you want to set arbitrary dates, first you should disable or deinstall ntp.
- To disable it, open a terminal and run
sudo update-rc.d -f ntp remove
- To deinstall it, use your favorite software management software
After that you can use the
date-command to set your system time:
date -s "17 April 2011 12:34:56" date --set="17 April 2011 12:34:56"
Both commands are equivalent. To only set the time you can use:
date +%T -s "12:34:56"
date-manpage has some more format controls. You can use them all to change the date
Click on the time & date section of the panel, then the Calendar will appear and underneath that the Time & Date Settings is there so click that.
Click on the Padlock icon and enter your password, then choose Set The Time to manually.
In the Software Center look up ntpdate and remove it, or in terminal: sudo apt-get remove ntpdate
(You may have to reboot to fully disable ntp)
Then set your date.
Based on the ".ps1" (Windows PowerShell script) example given in
I've written a regular ".bat" script file to change the clock time at which the VirtualBox's virtual machine starts.
The desired start time is set at variable "TEMPO_START_TIMESTAMP" in epoch format. You can get your desired start time epoh equivalent at "http://www.timestampconvert.com/".
The name of the VirtualBox's virtual machine to be started is needed in variable "NOME" (same nomenchature used in the ".ps1" script above).
echo off echo %time% set NOME="Windows_7_x64" set TEMPO_CS_2_MS=0 set TEMPO_S_2_MS=000 rem # Starts the VM always on the date 07/11/2014 - 11h58 rem http://www.timestampconvert.com/ set TEMPO_START_TIMESTAMP=1415361480 for /f "delims=" %%x in ('cscript /nologo toEpoch.vbs') do set epoch=%%x rem %epoch% set TEMPO_CURRENT_TIMESTAMP=%epoch% rem set TEMPO_CURRENT_TIMESTAMP=1544518714 set /A TEMPO_TEMP=(%TEMPO_START_TIMESTAMP%-%TEMPO_CURRENT_TIMESTAMP%) call set TEMPO=%TEMPO_TEMP%%TEMPO_S_2_MS% rem %TEMPO_TEMP% rem %TEMPO% c:\Progra~1\Oracle\VirtualBox\VBoxManage setextradata %NOME% "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1 c:\Progra~1\Oracle\VirtualBox\VBoxManage modifyvm %NOME% --biossystemtimeoffset %TEMPO% c:\Progra~1\Oracle\VirtualBox\VBoxManage startvm %NOME%
You'll also need the current time in epoh format, for this use the following script (save as "toEpoch.vbs", this visual basic script is called from the ".bat" script above):
WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now())
To run the virtual machine, simply execute the ".bat" script file above. No need to open the "Oracle VM VirtualBox Administration" interface.
I hope this helps.