1

It seems that having the time update when resuming a VirtualBox VM from a paused state is not possible.

I've reached this conclusion after reading online for a few days and trying many different things, but notably putting tinker panic 0 in the [/etc/ntp.conf] file. I restarted the ntpd service afterwards and then proceeded to test it by pausing the machine state for a few minutes and then resuming. The time picked up where it left off (and didn't sync).

Many people have asked this question before but they seem to all morph into some, ever-so-slightly, different variation.

My Guest in the VM: CentOS Linux release 7.3.1611

[root@CentOS7 ~]# systemctl list-unit-files ntpd*
UNIT FILE       STATE
ntpd.service    enabled

Just in case anyone is wondering, I did disable the chrony services so there wouldn't be any conflicts because I prefer NTPD due to available documentation.

[root@CentOS7 ~]# systemctl list-unit-files chron*
UNIT FILE              STATE
chrony-dnssrv@.service static
chrony-wait.service    disabled
chronyd.service        disabled
chrony-dnssrv@.timer   disabled

Anyone have any last suggestions before I consider a cronjob? While definitely not optimal it would at least work.

== Change of strategy - attempting to use Guest additions to sync time from host ==

So I followed advice to install the Guest Additions iso in VirtualBox. Surprisingly ran into a problem there.

Unable to insert the virtual optical disk C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the machine Centos.

Could not mount the media/drive 'C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso' (VERR_PDM_MEDIA_LOCKED).

Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}
Callee: IMachine {b2547866-a0a1-4391-8b86-6952d82efaa0}

The fix to that was to launch my Centos desktop GUI where I saw the ISO. I right-clicked, clicked "Open with run software" and it installed successfully. It is still not synching the time though, even after disabling ntpd.

So I found this thread: https://www.virtualbox.org/ticket/15179

Start the VBoxService process with verbose output on a terminal:

/usr/sbin/VBoxService -fvvv

This resulted in:

00:00:00.010360 timesync vgsvcTimeSyncWorker: Host:    2017-02-11T21:39:17.257000000Z    (MinAdjust: 100 ms)
00:00:00.010428 timesync vgsvcTimeSyncWorker: Guest: - 2017-02-11T21:30:01.781953000Z => 555 475 047 000 ns drift
00:00:00.010491 timesync vgsvcTimeSyncAdjust: adjtime by 555 475 047 000 ns

but it didn't actually adjust the time, or maybe that means it's adjusting it in nanoseconds which will take FOREVER. Hmmm...

As a last resort I tried:

/usr/sbin/VBoxService -fvvv --timesync-set-on-restore 1

I think I've wasted enough time on this. I'll try a cronjob with ntpd -g.

  • Do you make use of iburst in your /etc/ntp.conf? E.g. server 0.centos.pool.ntp.org iburst. – Thomas Feb 11 '17 at 17:39
  • Yes, iburst is specified – Adrian Feb 11 '17 at 18:11
  • From here it seems installing the guest additions in the VM from VirtualBox solves the issue. – Thomas Feb 11 '17 at 18:24
  • Whenever you have an ntp question you should put the putput of ntpq -pcrv in your question. And like any other question it helps if you include the ntp logs... – dfc Feb 12 '17 at 15:48
0

It is possible to sync time from the host using VirtualBox Guest Additions, which came with my VirtualBox 5.1.14. See my edited question with more info about working through the errors while trying to install Guest Additions.

The Grand Finale of my answer: I tried to make it a systemctl service but it kept throwing errors so I put this in my .bashrc file:

/usr/sbin/VBoxService --timesync-set-on-restore 1 --timesync-set-threshold 5000 > /dev/null

It works very well and does what it's supposed to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.