在不与主机同步时间的情况下,在来宾虚拟机上保留 vboxadd-service 运行?

Keep vboxadd-service running on a guest vm without syncing the time with the host?

我的 VirtualBox 来宾中的 vboxadd-service 必须 运行 从以下 VagrantFile 代码片段中获取 ip,否则 vagrant hostupdater 命令将不起作用正如预期的那样:

  config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
      if vm.id
         `VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/2/V4/IP"`.split()[1]
      end
  end

关闭 vboxadd-service 时生成的 /etc/hosts 文件:

## vagrant-hostmanager-start                                                                            

value   bareOSdirector

value   webserver

value   bareOSremoteSD

## vagrant-hostmanager-end  

这是因为...

如果 vboxadd-service 是 运行ning...你可以 运行 这个命令并得到:

VBoxManage guestproperty get "turnkey_lamp_packer_test_webserver_1502906374188_41719" "/VirtualBox/GuestInfo/Net/2/V4/IP"
Value: 10.0.3.8

但如果它不是 运行ning,你会得到:

VBoxManage guestproperty get "turnkey_lamp_packer_test_webserver_1502906374188_41719" "/VirtualBox/GuestInfo/Net/2/V4/IP"
No value set!

但是为了让我能够轻松地更改我的虚拟机之间的时间以进行测试...vboxadd-service 不能 运行 在来宾虚拟机上运行,​​或者否则,当我使用 sudo date -s 命令更改时间时,时间将与主机同步。

除了每次启动和停止服务之外,如何在忽略时间同步的情况下保持 vboxadd-service 运行ning?有没有办法在不与主机同步时间的情况下保持服务 运行ning?

这似乎有效:

# On the host...
VBoxManage setextradata "vm-name" "/VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

# On the guest(s)...
sudo sed -i.bak 's/\(daemon $binary\) \(--pidfile $PIDFILE > \/dev\/null\)/ --disable-timesync /g' /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service && rm /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service.bak
sudo sed -i.bak '0,/start-stop-daemon --start --exec $1 -- $2 $3/{s/start-stop-daemon --start --exec $1 -- $2 $3/[=11=] /}'  /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service && rm /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service.bak 
sudo systemctl daemon-reload
sudo systemctl restart vboxadd-service
sudo rm /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service