Experiencing synced_folder virtualbox failure
- Dominant language
- Ruby
- Stars
- 27.2k
- Forks
- 4.4k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
### Vagrant version
2.2.15
### Host operating system
Windows 10
### Guest operating system
Redhat 7.9 with Virtualbox 6.1.20 guest tools installed
### Vagrantfile
```ruby
Vagrant.configure("2") do |config|
config.vm.box = "my-redhat-base-box"
#This is just the redhat set up as described in creating a box with the guest additions of virtualbox 6.1.20 installed.
end
```
*This worked 100% fine prior to yesterday!*
The only change to my system I can think of is I installed cygwin.
### Debug output
https://gist.github.com/esend7881/54feff06cf7e22d8fc013c733cc78f2a#file-vagrant-up-debug-synced-folder-problem
### Expected behavior
Prior to yesterday, `vagrant up` booted up and the folder shared just fine. No complaints. Now it is not working.
### Actual behavior
```
ERROR vagrant: 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: shared folder '/home/vagrant' was not found (check VM settings / spelling)
```
This error doesn't make sense for the following reasons:
1. There is a `/home/vagrant` folder as part of the base box.
2. I have installed the guest additions.
Here is my running `vagrant up`, getting a failure, then running `vagrant ssh` and showing that `/home/vagrant/` exists and virtualbox guest tools are installed:
```.sh
λ vagrant destroy -f && vagrant up
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'MYSYS-0.0.1'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: test-infrastructure_default_1619556384614_13066
==> 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: Connection reset. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/esender/Documents/MYSYS/workspace/test-infrastructure
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: shared folder '/home/vagrant' was not found (check VM settings / spelling)
```
Now logging in:
```.sh
λ vagrant ssh
Last login: Tue Apr 27 09:10:58 2021 from gateway
[13:50:56Tue Apr 27] vagrant:MYSYS ~>$ ll -lah /home/vagrant/
total 24K
drwx------. 6 vagrant vagrant 204 Apr 27 09:11 .
drwxr-xr-x. 3 root root 21 Feb 5 08:44 ..
-rw-------. 1 vagrant vagrant 707 Apr 27 09:23 .bash_history
-rw-r--r--. 1 vagrant vagrant 18 Aug 21 2019 .bash_logout
-rw-r--r--. 1 vagrant vagrant 193 Aug 21 2019 .bash_profile
-rw-r--r--. 1 vagrant vagrant 261 Apr 27 08:44 .bashrc
-rw-------. 1 vagrant vagrant 48 Apr 27 09:11 .lesshst
-rw-r--r--. 1 vagrant vagrant 382 Apr 27 09:10 nacmconfig.xml
drwx------. 2 vagrant vagrant 39 Apr 27 09:10 .netopeer2-cli
drwxrw----. 3 vagrant vagrant 19 Feb 5 09:02 .pki
drwx------. 2 vagrant vagrant 90 Apr 27 09:10 .ssh
drwxrwxr-x. 4 vagrant vagrant 49 Apr 27 08:44 tests-snapshot
lrwxrwxrwx. 1 root root 14 Apr 27 08:44 vagrant -> /home/vagrant/
[13:51:01Tue Apr 27] vagrant:MYSYS ~>$ ls -lah /vagrant/
total 0
drwxr-xr-x. 2 root root 6 Apr 27 08:43 .
dr-xr-xr-x. 18 root root 239 Apr 27 08:43 ..
[13:54:37Tue Apr 27] vagrant:MYSYS ~>$ sudo vbox-uninstall-guest-additions
Removing installed version 6.1.20 of VirtualBox Guest Additions...
#Note: I am only running this command to prove that 6.1.20 is actually installed.
```
Notice oddly that in the `/home/vagrant` folder, there is a symlink in there `vagrant -> /home/vagrant/`. I do not know how/why that appeared there. Also the actual `/vagrant` folder is empty when it should have the contents of my calling folder.
### Steps to reproduce
I have not been able to trace root cause for this. I have updated to the latest Virtualbox 6.1.20 and Vagrant is at the latest version of 2.2.15. It is odd, sometimes, on first run `vagrant up` does work. However subsequent runs of `vagrant up` always causes the problem to surface.
For now, I am using `rsync` instead of the default type (`virtualbox`) method of syncing folders, but `rsync` is not a long term solution since it is one way. I do need the `/vagrant` folder to be synchronized between the guest and host.
I can modify the base box, make changes to the guest tools or something, etc. Let me know if you have ideas. But as I said, one of the main puzzling things here is that this probably occurred after using that same base box for months with no modification (previously it was using Virtualbox 6.1.16 though I updated to 6.1.20 as a troubleshooting measure here).
Beyond this, on my Windows host machine, I have installed Cygwin and its on my `PATH` variable. Though I have tested removing it from my `PATH` variable to no avail.
### References
N/A
Contributor guide
Research direction
Start with the linked debug output and the Vagrantfile, then compare the failing `vagrant up` sequence with the guest state shown through `vagrant ssh`. Investigate why the VirtualBox shared-folder mount reports `/home/vagrant` as missing despite the directory existing. Done means repeated `vagrant up` runs mount `/vagrant` with two-way synchronization restored.
Written by the indexing model from the issue text.
Assessment
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100