首页 文章

Vagrant错误:无法挂载VirtualBox共享文件夹(访客添加,vboxsf)

提问于
浏览
33

问题

我在Windows 10上安装了Vagrant,因此我可以在虚拟机中创建个人本地开发环境 . 我读到的关于Vagrant的一切都说我甚至可以通过NAT端口转发来启动多个系统并测试它们之间的通信 . 但首先,我只是希望在与其余部分相距太远之前创建一个开发环境虚拟机 .

我按照SitePoint教程安装了VirtualBox,Vagrant,PuTTy和PuTTYGen:https://www.sitepoint.com/getting-started-vagrant-windows/ . 接下来,我在C:驱动器上创建了一个vagrant项目文件夹,做了 vagrant init ,删除了 Vagrantfile ,最后删除了 vagrant init ubuntu/trusty64 . 然后我做了 vagrant up ,但是该过程因错误而失败:

Vagrant无法挂载VirtualBox共享文件夹 . 这通常是因为文件系统“vboxsf”不可用 . 该文件系统通过VirtualBox Guest Additions和内核模块提供 . 请验证这些客人添加内容是否已在guest虚拟机中正确安装 . 这不是Vagrant中的错误,通常是由错误的Vagrant框引起的 . 对于上下文,尝试的命令是:mount -t vboxsf -o uid = 1000,gid = 1000 vagrant / vagrant命令的错误输出是::没有这样的文件或目录

这是我的Windows命令行的屏幕截图:

Screenshot of Vagrant/VirtualBox error

这是一个文本版本:

C:\vagrant\sitepoint-test-2017-02-05>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160602.0.0'. The latest is version '20170202.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: sitepoint-test-2017-02-05_default_1486399403587_55255
==> default: Clearing any previously set forwarded ports...
==> 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: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/vagrant/sitepoint-test-2017-02-05
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

: No such file or directory

我的设置

OS: Microsoft Windows [Version 10.0.14393]
VirtualBox Version: 4.3.10 r93012
GuestAdditions Version: ???
Vagrant Version: 1.9.1 (Latest)
PuTTy Version: 0.67
PuTTYGen Version: 0.67

已安装插件和扩展程序

Vagrant:
- vagrant-share (1.1.6, system)
- vagrant-vbguest (0.13.0)

我已经尝试过了

This post似乎是我研究中最有希望的 .

不幸的是,提供的解决方案和提供的任何链接都没有解决问题 . 我已经尝试了很多东西,但我不是系统管理员(我猜这是你需要对此进行故障排除的技能组合) . 特别令人不安的是,2013/2014年的许多“解决方案”最近被证明不再有效 . 这些解决方案谈论与符号链接无法正常工作,安装像vagrant-vbguest这样的插件,以及关于vbox添加不匹配的东西 . 我并不是真的了解所有这些,但我尽我所能 . 这是我尝试过的尚未解决的问题:

我的问题

  • 我怀疑问题出在VirtualBox上,而不是Vagrant . 这是真的?

  • 如何解决此问题,以便继续学习本教程?

  • 自2014年左右以来,在Stack Overflow上回答的Vagrant问题似乎有了大幅下降 . 这是什么原因? Vagrant / VirtualBox不再被视为“最佳实践”吗?是否有更好的解决方案,因此用户忽略了流浪问题?

同样,我不是系统管理员,但我技术精湛,可以遵循技术指导 .

10 回答

  • 11
    vagrant plugin install vagrant-vbguest
    

    这对我不起作用,它似乎与vagrant 1.9.2不兼容,我卸载了最新版本的虚拟盒(5.1.16)并安装了最新版本的vagrant 1.9.2和宅基地的5.1.12版本 . 这个对我有用 .

  • 2

    VirtualBox 5.1.18解决了这个问题 .

  • 2

    您可以降级VirtualBox或编辑文件中的行:在我的设置中,这是第206行:C:\ HashiCorp \ Vagrant \ embedded \ gems \ gems \ vagrant-1.9.2 \ lib \ vagrant \ util \ platform.rb在我的主机上 .

    我这样做了,它在Windows 10上运行良好!我想添加我对206行所做的事情:

    在编辑之前:“\?\”path.gsub(“/”,“\”)

    编辑后:path.gsub(“/”,“\”)

  • 3

    Guest Additions与VirtualBox的版本不兼容 . 自动更新VirtualBox Guest Additions将解决可能相关的问题:

    vagrant plugin install vagrant-vbguest

    我用这些堆栈解决了这个问题:

    • Windows 10

    • Oracle VirtualBox 5.1.16

    • Vagrant 1.9.2

    • config.vm.box = "hashicorp/precise64"

  • 7

    可能有多种原因:

    • guest虚拟机添加的版本与VirtualBox的版本不匹配,为此您可以通过运行 vagrant plugin install vagrant-vbguest 来更新guest虚拟机添加的版本

    • 你在Windows上遇到了一个带有NFS的流浪者错误:应该修复,所以可能会尝试更新到最新版本的Vagrant和VirtualBox

    • 在这个github问题https://github.com/fideloper/Vaprobash/issues/92中,有两件事你可以测试:使用winnfsd插件(https://github.com/winnfsd/vagrant-winnfsd)或尝试配置没有NFS的默认挂载

    我有同样的问题,而且只是客人添加不是最新的......

    UDPATE :Vagrant上的错误在Windows上使用NFS(第2点)已在5.1.18版本中修复,在5.1.20版本中重新出现,并在5.2版本中再次修复 .

  • 1

    从5.1.16降级到Virtual Box 5.1.14可以正常工作 .

  • 7

    我正在使用Vagrant 1.9.4和VirtualBox 5.1.20 . 没有解决方案帮助了我 .

    我终于通过禁用来宾添加的自动更新解决了这个问题:

    Vagrant.configure("2") do |config|
        config.vbguest.auto_update = false
        [...]
    end
    

    它真的知道实际问题是什么,但我认为它与此有关:https://www.virtualbox.org/ticket/16670

  • 22

    Virtualbox 5.1.20中也有回归

    流浪者问题:https://github.com/mitchellh/vagrant/issues/8502

    Virtualbox问题:https://www.virtualbox.org/ticket/16670#comment:4

    现在的修复是回到Virtualbox 5.1.18,它在哪里工作 .

  • 28

    它是Vbox中的错误 . 有一个解决方案可以修复 .

    登录Vbox guest虚拟机:默认密码为(vagrant / vagrant)

    su
    ln -sf /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
    mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
    

    关掉

    从本地计算机cmd提示符运行cmd:

    vagrant up
    

    它会工作 .

  • 3

    我有类似的问题,如果它不匹配则检查 Headers 然后在命令下运行

    CentOS:sudo yum update && sudo yum -y install kernel-headers kernel-devel

    流浪汉重新加载

    这个对我有用 .

相关问题