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

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

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.

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.

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

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

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

I ran just
vagrant plugin install vagrant-vbguest
and after this the box came up.

Related

Vagrant VMware Utility driver

First of all I'm sorry if someone already did this question, in this case please paste the link here because I didn't find anything.
I'm learning vagrant, using virtualbox i don't have problem in running VM, but if I would like to use VMware as provider. I encounter this message and I can't find a way to get out of this.
I think everything is well configured but obviously something is wrong.
When I launch vagrant up --provider=vmware_desktop, I have this error message:
Vagrant encountered an unexpected communications error with the
Vagrant VMware Utility driver. Please try to run the command
again. If this error persists, please contact support#hashicorp.com
I'm currently using Fedora 35
Operating System: Fedora Linux 35 (Workstation Edition)
Kernel: Linux 5.17.5-200.fc35.x86_64
Architecture: x86-64
I have followed this thread:
https://github.com/hashicorp/vagrant-vmware-desktop/issues/22
and someone had prepared a nice gist -- which I copied below just in case the gist link wasn't anymore.
My issue was mainly the Vagrant 2.2.19 which somehow was not ok with VMWare. 2.2.18 worked fine. Just make sure you follow the above gist step by step.
https://gist.github.com/sbailliez/f22db6434ac84eccb6d3c8833c85ad92
My issue was mainly the Vagrant 2.2.19 which somehow was not ok with VMWare. 2.2.18 worked fine. Just make sure you follow the above gist step by step.
Vagrant and VMWare Tech Preview on Apple M1 Pro
This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated
from discussions in https://github.com/hashicorp/vagrant-vmware-desktop/issues/22
Installing Rosetta
First install Rosetta if not already done, this is needed to run x86 code:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Installing Vagrant
Install Vagrant via brew or install it manually. Note that I use 2.2.18 as 2.2.19 did not work for me. (YMMV)
brew install vagrant#2.2.18
Installing VMWare Fusion Tech Preview
You will need to create an account on vmware as it needs user and key information that are user specific.
The registration process is kinda convoluted. Be careful about passwords as the password needs to be less than 20 characters and there are no error messages for this.
You can download the tech preview via the download page.
Once this is installed you will NEED to create a symlink as the vagrant vmware utility etc.. assumes that vmware is installed in a specific directory and the tech preview is installed in a different one.
ln -s /Applications/VMWare\ Fusion\ Tech\ Preview.app /Applications/VMWare\ Fusion.app
Installing Vagrant VMWare provider
It requires two steps. This is detailed in the documentation but follow the steps below:
First go to Vagrant vmware Utility and download the binary and install it. It says x86_64 but it is fine.
The direct link is:
https://releases.hashicorp.com/vagrant-vmware-utility/1.0.21/vagrant-vmware-utility_1.0.21_x86_64.dmg
It needs to be version 1.0.21
Next install the provider:
vagrant plugin install vagrant-vmware-desktop
Create a Vagrant file
Create a file Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "spox/ubuntu-arm"
config.vm.box_version = "1.0.0"
end
Run vagrant
vagrant up
and then
vagrant ssh
Hopefully this should work and you should find yourself with mostly everything working.
Troubleshooting
I have observed various issues that makes the whole experience unstable or creating conflicts.
vagrant 2.2.19 is broken
I have had issues trying to run vagrant 2.2.19. Use 2.2.18
vagrant-vmware provider forwarded ports bound
If you declare forwarding port on your box, for some reasons the provider persists them and keeps it bound in LISTEN state even after you do a vagrant halt.
You can check this using something like:
sudo lsof -i -P | grep LISTEN | grep 'vagrant-v'
You can see the ports are stored in:
cat /opt/vagrant-vmware-desktop/settings/portforwarding.json
To stop the provider use:
sudo launchctl unload -w /Library/LaunchDaemons/com.vagrant.vagrant-vmware-utility.plist
To start it again, use load instead of unload.
nfs exports conflicts
If your vagrant box uses nfs, it seems to pollute the /etc/exports file with duplicate or stale entries over time which will cause vagrant to get angry at you at some point. You may need to prune the entries. It seems related to vagrant#11418
I encountered this same issue you had with the architecture compatibility while trying to set up VM on my Mac M1. Found my solution in this GitHub thread
I just added this lines to the Vagrantfile
config.vm.provider :vmware_desktop do |v|
v.vmx["ethernet0.pcislotnumber"] = "160"
end

Vagrant command doesn't work without Sudo

I have installed homestead with Vagrant in my MacOS. I have installed all with Virtual Box, but when i try to use vagrant command in my terminal for running Virtual Machine appear this error:
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.
I try with sudo vagrant up and it work but is not the best choice.
Anyone can help me?
There's a screenshot of the terminal Error:
Terminal Error with command vagrant up and vagrant ssh.
Try deleting .vagrant directory
rm -r .vagrant
I suspect you copied or moved project folder from one place to another.
Alternatively you need to update the creator_uid file in .vagrant/. Check out this blog post.

Installing Virtual box for kong Vagrant set up

I am trying to set up vagrant for kong. I have installed VirtualBox and vagrant. But when i run 'vgrant up' i encounter the below issue:
Bringing machine 'default' up with 'virtualbox' provider...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["list", "hostonlyifs"]
Stderr: VBoxManage: error: Failed to create the VirtualBox object!
VBoxManage: error: Code NS_ERROR_FACTORY_NOT_REGISTERED (0x80040154) - Class not registered (extended info not available)
I have searched for this error with no much luck.
I am using centos 7.4 and the kernel version is 3.10.0-693.21.1.el7.x86_64.
I have downloaded the relevant gcc, devel and dkms. In short followed the link https://tecadmin.net/install-oracle-virtualbox-on-centos-redhat-and-fedora/
Any tip is appreciated.
Thanks
Dinah
This is most likely a problem with your VirtualBox install, not Vagrant. To confirm this, you should receive the same error when running: VBoxManage list vms
A common reason for this error are when /tmp is full or has the incorrect permissions.
To check if /tmp is full try df -h
To fix permissions on /tmp if they're incorrect, try sudo chmod ug-s /tmp && sudo rm -rf /tmp/.vbox*
Apparently we were trying this on a VM. And Vagrant tries to spin up another VM. So having a VM spun within a VM is causing the issue.

Vagrant laravel/homestead shared folders not mounting after 2.1.0 update

I have scoured the internet up and down for this issue and always consider asking here a last resort. That being said if this has been asked and solved before please point me in the right direction.
I am using Virtualbox 5.1.22 on macOS Sierra 10.12.5 with vagrant version 1.9.6
Yesterday I upgraded my homestead box from version 2.0.0 to 2.1.0. I only upgraded after running vagrant up and it did its thing and was fine until I come in today and turn my machine one and try booting up the vagrant machine again. I get the following error at the end of the normal stuff:
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=900,gid=900 vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
I have tried vagrant reload, vagrant halt and then vagrant up, restarting the machine and re-running, vagrant reload --provision
Any help is greatly appreciated.
Thanks.
EDIT: Why the downvote? This seems like a perfectly reasonable question?
The box comes with VirtualBox Guest Addition for a given version of VirtualBox, which is not the one you're running on your host.
what you need to do is update the Guest Additions in your guest VM to the same version of VirtualBox that you run on your host machine.
The easy way as mentioned in my comments is to use the vagrant vbguest plugin, it will compare the version from your host and guest software and will automatically aligned if needed. I find it pretty convenient and there are options to disable the update if you need.
In case you do not want to run an additional plugin, you can make the update on the guest VM manually.
You will need to download the Guest Addition for the same version of your VirtualBox (5.1.22 in your case) and follow the instructions to install
So I found and installed this: https://github.com/dotless-de/vagrant-vbguest
I have no idea why I need a plugin now when it was working just fine before updating but hey...it works.

Error after `vagrant halt; vagrant up`

I am setting up a Ubuntu 15.04 VM on Win7 using Vagrant 1.7.4 and VBox 5.0.0.
On the first vagrant up I can ssh into the machine using vagrant putty and everything is setup correctly and works. When I run vagrant halt, the VM shuts down gracefully without error messages.
However, when I try to restart the VM using vagrant up; vagrant putty, the machine is in a strange state. For example, the default synced folder /vagrant is empty, even though the second vagrant up call prints this message:
default: /vagrant => C:/Users/ArneUser/numecs/dev_env
Also, this vagrant up call prints the following message in PowerShell:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
Stdout from the command:
Stderr from the command:
stdin: is not a tty
bash: line 2: /sbin/initctl: No such file or directory
I am running a really basic setup just to test for this error, so I don't think the mistake is in my provisioning script. Some pointers in the right direction would be appreciated.
Open VirtualBox GUI and turn off machine manually, then run again the vagrant up command.
That solved the problem in my case :)
/vagrant is empty
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
From these two lines I suspect that MOUNTPOINT should be /vagrant but its due to /vagrant being empty that SSH is now working.
I've seen similar issues because of Virtualbox 5.
Try to downgrade Virtualbox to 4.3.x and ensure you have the latest Vagrant (1.7.4).
https://github.com/mitchellh/vagrant/issues/5572
Initctl is part of the Upstart init daemon. As far as I'm aware Ubuntu 15.04 is the first version of Ubuntu to abandon Upstart in favor of SystemD, so /sbin/initctl isn't expected to exist in your operating system. I believe this would need to be something that is fixed in the box you're using.
The point of "/sbin/initctl emit ..." is to notify other Upstart units that the vagrant shared folder has been mounted and is available for read/write operations. Since upstart is no longer in use it may be safe to assume that there is no need for this call. It's a rather crude hack, but you could make an empty script at /sbin/initctl. This should allow the vagrant startup process to continue properly and provision your box.
In my case it seems as Marc Young suggested that by opening Virtualbox GUI, the virtual machine itself seems to be hung. I saw these error messages on the virtual box console:
Thus it seems to not to be Vagrant related problem, but the virtual machine (Linux Kernel) itself seems to be hung.

Resources