2

I have a VirtualBox VM running an x86_64 Ubuntu 22.04. Whenever i try changing the date to a previous date (in my case 5 days ago), the date always reverts back to the current date a few seconds later.

Here's what i've done:

I disabled both network connections in the VM so it won't sync.
In the settings panel, i disabled all sync'ing.

I've tried:

  • changing the date in the settings panel
  • sudo date +%d --set="21"
  • sudo date -s "5 days ago"
  • sudo timedatectl set-time 2022-04-21
  • systemctl stop time-sync.target
  • systemctl stop time-set.target

I've seen mentions of the hardware clock, but i get this:

hwclock --show
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method. 

so i assume the VM isn't emulating one. I have no running processes or installed packages that match "*ntp*".

What is restoring my date?

Rebooting didn't help.

(FYI i have a Windows VM that has a similar behavior, also with network disconnected.)

Edit 1

I noticed this in /var/log/syslog after changing time:

Apr 26 14:18:36 myvm kernel: [ 5336.382332] 13:18:36.743879 timesync vgsvcTimeSyncWorker: Radical guest time change: 432 002 205 702 000ns (GuestNow=1 650 979 116 743 855 000 ns GuestLast=1 650 547 114 538 153 000 ns fSetTimeLastLoop=true )

followed by a bunch of anacron jobs, none apparently related to time...

Edit 2

This answer suggests that indeed VirtualBox is forcing the date, but disabling this, even with reboots, didn't help; the date always reverts.

vesperto
  • 194

2 Answers2

0

The command mentioned:

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

must be run with the VM shut down, otherwise it won't take effect. You can double-check by searching for GetHostTimeDisabled in the .vbox XML file of the VM (usually in C:\Users\your.username\VirtualBox VMs\YourVM\YourVM.vbox in a windows host).

vesperto
  • 194
0

You need to run two commands with the VM shut down.

The first is:

VBoxManage setextradata "Virtual Machine" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

For the second command, calculate first the number of milliseconds between your chosen date and the present.

For example, for the date 2003-06-06, open PowerShell and enter:

([datetime]"06/06/2003" - [datetime]::Now)

Keep the TotalMilliseconds value and enter the following command:

VBoxManage modifyvm "Virtual Machine" --biossystemtimeoffset <TotalMilliseconds-value>

Source: How to set the BIOS date in VirtualBox.

harrymc
  • 498,455