How do I manually set the system time in VirtualBox?

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?


Solution 1:

I have found a solution. Read the following material: link

Basically if you have Windows host and Ubuntu guest, do the following:

  1. 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
  2. In Windows, start a command line interpreter, go to C:\Program Files\Oracle folder and click VirtualBox to 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
  3. Paste the following command (change the VM name to your name!):

    VBoxManage setextradata "Ubuntu 12.04 32bit" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

  4. Finally, start your Ubuntu guest and set the time and date manually.

Undo

If required, to get the guest to sync time with the host again, repeat the above steps but change the final 1 to 0.

Solution 2:

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

or

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.