通过在 VirtualBox 中手动将 Guest Additions VBoxGuestAdditions.iso
文件挂载为 CD-ROM 解决了该问题。
尽管如此,Vagrant 盒子可能无法通过 VirtualBox 提供程序同步共享文件夹,而是使用rsync
相同的文件夹。
这可以通过在配置中Vagrantfile
显式设置提供程序类型来更新VirtualBox
。
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
在此之后vagrant reload
,共享文件夹同步应该按预期工作。
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:
https://www.virtualbox.org/manual/ch04.html#sharedfolders
This option can be disabled globally with an environment variable:
VAGRANT_DISABLE_VBOXSYMLINKCREATE=1
or on a per folder basis within the Vagrantfile:
config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/hemanik/vm/
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
不确定它是否能够找到来宾添加default: Checking for guest additions in VM...
,或者之前对来宾添加的调整是否生效,但共享文件夹同步按预期工作。
只是为了更新,重新安装了 Vagrant,当前的工作版本如下:
- 流浪版本:
2.2.10
- 虚拟机版本:
6.0.24 r139119