【问题标题】:Keep vboxadd-service running on a guest vm without syncing the time with the host?保持 vboxadd-service 在来宾 vm 上运行而不与主机同步时间?
【发布时间】:2017-08-16 20:28:32
【问题描述】:

我的 VirtualBox 来宾中的 vboxadd-service 必须运行才能从以下 VagrantFile 代码 sn-p 获取 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 正在运行...您可以运行此命令并获取:

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

但如果它没有运行,你会得到:

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 运行?有没有办法在不与主机同步时间的情况下保持服务运行?

【问题讨论】:

    标签: vagrant virtualbox vagrant-plugin


    【解决方案1】:

    这似乎有效:

    # 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\)/\1 --disable-timesync \2/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/\0 $4/}'  /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
    

    【讨论】:

      猜你喜欢
      • 2020-09-28
      • 2018-08-30
      • 2017-09-03
      • 2018-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多