Carlo Cumino
Carlo Cumino

Reputation: 45

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

Upvotes: 1

Views: 8470

Answers (7)

M3RS
M3RS

Reputation: 7550

On the host run:

vagrant plugin install vagrant-vbguest

Afterwards make sure to (exit the VM if up and) run

vagrant reload

The first command installs a Vagrant plugin which automatically installs the host's VirtualBox Guest Additions on the guest system. If you're lucky, no additional configuration is needed. Otherwise, there is more on config here.

Upvotes: 0

PHZ.fi-Pharazon
PHZ.fi-Pharazon

Reputation: 2103

I ran just

vagrant plugin install vagrant-vbguest

and after this the box came up.

Upvotes: 0

I have the issue i Ubuntu 20.04 and simply download a more recent version of VirtualBox, then extract the GuestAditions ISO and installed it

Upvotes: 0

user3168237
user3168237

Reputation:

Finally got it working the following way (this related answer was of great help along with Paul_Z's answer in this same question).

Step 1: Make sure VirtualBox Guest Additions Software is installed.

If this solved your Issue, then great! If not, continue on to step 2.

Step 2: Read the VirtualBox Guest Additions installation output carefully.

(If no longer possible, you can rerun the setup by using cd to go to

/opt/VBoxGuestAdditions-*your-version-number-here*/init/

and then run:

sudo ./vboxadd setup)

Step 3:

Install the needed dependencies with the distribution's package manager that the error message shows. (In my particular case, it mentioned that the system couldn't perform kernel module builds because gcc make and perl were not present in the system).

Step 4:

Rerun the VirtualBox Guest Additions setup by going to

/opt/VBoxGuestAdditions-*your-version-number-here*/init/

and then run:

sudo ./vboxadd setup

(If more dependencies are requested, go back to step 3)

Step 5: Reboot

Step 6 (Optional): Add user to vboxsf group so that it is able to access the shared folder if needed. (As explained in this answer).

sudo usermod -G vboxsf -a your_user_name

Upvotes: 0

Kaji Rafiqul Islam
Kaji Rafiqul Islam

Reputation: 107

Step 1: open virtual box then right click on installation machine then ->close->power off. Step 2: then run below command

vagrant halt vagrant upenter image description here

Upvotes: 0

Semb
Semb

Reputation: 166

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.

Upvotes: 2

Paul Z
Paul Z

Reputation: 31

Just had a similar problem after an update - was getting the same:

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

What I found in virtualbox startup was the message:

VirtualBox Guest Additions: Kernel headers not found for target kernel
5.4.0-81-generic. Please install them and execute
  /sbin/rcvboxadd setup

Used "vagrant ssh" to access the virtualbox command line and ran:

sudo apt-get install linux-headers-$(uname -r)

After that restarted vagrant:

vagrant halt

vagrant up

Then it actually built the VirtualBox Guest Additions properly and mounted my shared folders.

Upvotes: 3

Related Questions