Again Ubuntu is NOT keeping accurate Time and date in Virtualbox

Asked by Snooper

Again Ubuntu is NOT keeping accurate Time and date in Virtualbox

WHEN IS THIS EVER GOING TO BE FIXED? WHEN?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu ubuntu-docs Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

To be able to help you we need the output of the following commands when executed on your Ubuntu system:

uname -a
lsb_release -crid
timedatectl status
sudo hwclock --set --date="`LANG=C date`"
timedatectl status
systemctl status vboxadd-service

(Remark: you have to press the "q" button after the last command to go back to the command prompt.)

Only with that information from your system we can tell you what to do that your Ubuntu system will always show the correct date and time.

Revision history for this message
Bernard Stafford (bernard010) said :
#2

https://www.virtualbox.org/manual/UserManual.html

9.11. Fine Tuning Timers and Time Synchronization
9.11.1. Configuring the Guest Time Stamp Counter (TSC) to Reflect Guest Execution

By default, Oracle VM VirtualBox keeps all sources of time visible to the guest synchronized to a single time source, the monotonic host time. This reflects the assumptions of many guest operating systems, which expect all time sources to reflect "wall clock" time. In special circumstances it may be useful however to make the time stamp counter (TSC) in the guest reflect the time actually spent executing the guest.

This special TSC handling mode can be enabled on a per-VM basis, and for best results must be used only in combination with hardware virtualization. To enable this mode use the following command:

$ VBoxManage setextradata VM-name "VBoxInternal/TM/TSCTiedToExecution" 1

To revert to the default TSC handling mode use:

$ VBoxManage setextradata VM-name "VBoxInternal/TM/TSCTiedToExecution"

Note that if you use the special TSC handling mode with a guest operating system which is very strict about the consistency of time sources you may get a warning or error message about the timing inconsistency. It may also cause clocks to become unreliable with some guest operating systems depending on how they use the TSC.
9.11.2. Accelerate or Slow Down the Guest Clock

For certain purposes it can be useful to accelerate or to slow down the virtual guest clock. This can be achieved as follows:

$ VBoxManage setextradata VM-name "VBoxInternal/TM/WarpDrivePercentage" 200

The above example will double the speed of the guest clock while

$ VBoxManage setextradata VM-name "VBoxInternal/TM/WarpDrivePercentage" 50

will halve the speed of the guest clock. Note that changing the rate of the virtual clock can confuse the guest and can even lead to abnormal guest behavior. For instance, a higher clock rate means shorter timeouts for virtual devices with the result that a slightly increased response time of a virtual device due to an increased host load can cause guest failures. Note further that any time synchronization mechanism will frequently try to resynchronize the guest clock with the reference clock, which is the host clock if the Oracle VM VirtualBox Guest Additions are active. Therefore any time synchronization should be disabled if the rate of the guest clock is changed as described above. See Section 9.11.3, “Tuning the Guest Additions Time Synchronization Parameters”.
9.11.3. Tuning the Guest Additions Time Synchronization Parameters

The Oracle VM VirtualBox Guest Additions ensure that the guest's system time is synchronized with the host time. There are several parameters which can be tuned. The parameters can be set for a specific VM using the following command:

$ VBoxManage guestproperty set VM-name "/VirtualBox/GuestAdd/VBoxService/property" value

property is one of the following:

--timesync-interval

    Specifies the interval at which to synchronize the time with the host. The default is 10000 ms (10 seconds).
--timesync-min-adjust

    The minimum absolute drift value measured in milliseconds to make adjustments for. The default is 1000 ms on OS/2 and 100 ms elsewhere.
--timesync-latency-factor

    The factor to multiply the time query latency with to calculate the dynamic minimum adjust time. The default is 8 times, which means as follows:

    Measure the time it takes to determine the host time, the guest has to contact the VM host service which may take some time. Multiply this value by 8 and do an adjustment only if the time difference between host and guest is bigger than this value. Do not do any time adjustment otherwise.
--timesync-max-latency

    The max host timer query latency to accept. The default is 250 ms.
--timesync-set-threshold

    The absolute drift threshold, given as milliseconds where to start setting the time instead of trying to smoothly adjust it. The default is 20 minutes.
--timesync-set-start

    Set the time when starting the time sync service.
--timesync-set-on-restore 0|1

    Set the time after the VM was restored from a saved state when passing 1 as parameter. This is the default. Disable by passing 0. In the latter case, the time will be adjusted smoothly, which can take a long time.

All these parameters can be specified as command line parameters to VBoxService as well.
9.11.4. Disabling the Guest Additions Time Synchronization

Once installed and started, the Oracle VM VirtualBox Guest Additions will try to synchronize the guest time with the host time. This can be prevented by forbidding the guest service from reading the host clock:

$ VBoxManage setextradata VM-name "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

Or cron an NTP time sync every half hour or so

Can you help with this problem?

Provide an answer of your own, or ask Snooper for more information if necessary.

To post a message you must log in.