Search code examples
vagrantvagrant-windowsvagrant-plugin

Vagrant was unable to mount VirtualBox shared folders. ERROR: INVALID ARGUMENT


I know that other people during the years had met similar problems (like this ) however in my case the guest addition is installed (0.30.0 version) and I tried to reinstall it a lot of times.

I work on Windows10 and those are the version of VirtualBox and Virtual Machine.

Virtualbox on your host claims:   5.2.8

VBoxService inside the vm claims: 6.1.22

This is the code of the problem:

 default: /vagrant => C:/Users/XXXX XXXX/Documents/src
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,_netdev vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: Invalid argument

I never found the error Invalid argument in similar cases so my question is if this need a particular procedure.

Thank you very much


Solution

  • Had the same exact error as you after making my second vagrant project - specifically after changing my public_network setting.

    mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
    The error output from the command was:
    /sbin/mount.vboxsf: mounting failed with the error: Invalid argument
    

    At I also tried several solutions from people's answers like the one mentioned here and updated my VirtualBox.

    I'm not really sure how mine works but here's what I did:

    I logged into the VM (vagrant ssh) and installed the guest additions manually

    cd /opt
    sudo wget -c 
    http://download.virtualbox.org/virtualbox/6.1.26/VBoxGuestAdditions_6.1.26.iso O VBoxGuestAdditions_6.1.26.iso
    

    And then tried:

    sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
    sudo sh /mnt/VBoxLinuxAdditions.run
    

    But I got an error saying something like permission denied or no directory.

    So I reload vagrant (vagrant reload), but the error still occurred. However, I still continued trying something else, so I thought maybe I should install the vbguest plugin and did this:

    vagrant plugin install vagrant-vbguest
    

    That removed the error for me after reload but when I logged into vagrant again, I still can't see my shared folders so I halted my vb and run provision:

    vagrant up --provision
    

    Then I got a message which said that there was an error while executing VBoxManage so on and so forth. So I paused all running machine in my VB, closed all running VB apps in my desktop, and run the command:

    vagrant destroy
    

    After recreating vagrant vagrant up, everything miraculously worked! I can now navigate to my shared folders' directory.

    I'm still in the process of learning vagrant so I can't really explain what actually happened in my machine but I hope this can somehow be of help to you or to someone who have the same issue.