Issues mounting a shared folder in virtualbox - macos

I'm trying to create a shared folder between MacOS (Host) and Debian (Guest) in virtualbox. I've completed the steps of installing guest additions, creating a shared folder called "share" and a folder in debian called "sf", but when I try to run
sudo mount -t vboxsf share ~/sf
I get the error
mount: realpath /Users/USERNAME/sf: No such file or directory
I'm under the impression the second path is meant to be the directory in Debian. This also happens when I remove the ~/.

Looks like you are trying to run this command from your OSX shell. Is that possibly the case?
If yes, switch to your shell on the Debian guest. Also make sure the directory ~/sf actually does exist before you run the mount command.
Hope this helps.

Related

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
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.

Vagrant up does not work with VMWare provider

I'm using Vagrant on the latest Linux Mint. It works fine with VirtualBox, however with VMWare it fails with this error: sudo helper setuid-wrapper must run as root.
The very few discussions about this issue I found on the net suggested to symlink ~/.vagrant.d to an not encrypted disk. This is what I tried, but unfortunately without any success at all. I also created symlinks for ~/vmware and ~/.vmware, but again without success.
Has anyone come across this error and found a solution?
Thank you very much.
This is still an issue today (Vagrant 1.9.3/Ubuntu 17.04/VMWare Workstation 12.5.5) if using an encrypted homedir. For me, the easiest solution was just to move the vagrant directory onto a non-encrypted filesystem as the OP suggested:
sudo mkdir /vagrant
sudo mv ~/.vagrant.d/ /vagrant/
ln -s /vagrant/.vagrant.d/ ~/.vagrant.d
Running in debug mode I can see the command its trying to run as root exists within the directory I moved:
INFO subprocess: Starting process: ["/home/geoff/.vagrant.d/gems/2.2.5/gems/vagrant-vmware-workstation-4.0.18/bin/vagrant_vmware_desktop_sudo_helper_wrapper_linux_amd64", "prune-forwarded-ports", "/tmp/vagrant-sudo-helper20170422-15385-brgg1q"]
And sure enough after vagrant up the VM now runs. Putting everything under /vagrant like this is a bit of a bodge and you would need to figure out something more elegant if you have more then one user, perhaps /vagrant/$USER. The directory I chose isn't Linux FHS compliant either but who cares ;-)
I wish this worked out the box but perhaps this will help someone

vagrant ash: sudo: not found

When starting my vagrant box with a small 15MB Busybox image, the first time I get an error during the phase
Mounting shared folders...
It seems vagrant is trying something with sudo, which isn't istalled. I get this error:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
Stdout from the command:
Stderr from the command:
ash: sudo: not found
It works so far, I can login as root with the password vagrant, but I guess this is not perfect?
This is my setup: https://github.com/rubo77/ffnord-example/blob/pyddhcpd/Vagrantfile
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
config.ssh.shell = 'ash'
(0..9).each do |i|
config.vm.define "gc-node0#{i}" do |node|
end
end
By default vagrant share/sync the directory /vagrant (guest) with the current project directory, the one containing the Vagrantfile (host), more directories can be shared using config.vm.synced_folder, I don't know if the default /vagrant can be disabled.
If you aren't using the shared directories feature then the missing sudo isn't a problem.
If your filesystem is writeable you can create the /vagrant directory once, so on next up vagrant shouldn't try to sudo mkdir again;
but assuming you're using VirtualBox (I don't know about others emulator behavior/architecture) you'll face another problem, shared directories require the kernel modules vboxsf and vboxguest (from VirtualBox Guest Additions) to be built (against the running kernel sources) and loaded (insmod), and the command mount.vboxsf to be built and installed in /sbin, plus your busybox require the option mount helpers enabled because vagrant use mount -t vboxsf and not mount.vboxsf directly, when vagrant try to mount the shared directories and those requirements aren't matched there is a long timeout before failing with error (a minute/two or more).
Notice that busybox (current stable) support sudo, is just disabled by default.
If you're building the buildroot yourself from sources I can tell that the shared feature works (I managed to get an image with busybox to work as vagrant expect), if you're using some pre-built kernel/busybox... may be a problem, you have to find matching binaries for vboxsf, vboxguest, mount.vboxsf and if the mount helpers option is disabled in your busybox you need to find a workaround (perhaps modifying vagrant to use mount.vboxsf).

Mounting a symlinked folder in vagrant & virtualbox

Okay, so here is my problem:
I use vagrant with VirtualBox. The host is Windows 8.1, the guest is Ubuntu (64bit). I am trying to use a symlinked windows folder created by
mklink /j somefolder someotherfolder
as synced folder in Vagrant. In my Vagrantfile I have
# disable the default synced folder
config.vm.synced_folder ".", "/vagrant", disabled: true
# sync my desired folder
config.vm.synced_folder "./somefolder", "/vagrant"
Unfortunately this does not work, but gives the following error:
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`
vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
Before you ask: Guest additions are installed, and mounting regular folders works flawlessly.
Is there a way to use symlinked directories as synced folders in vagrant with vbox?
Thanks for your help!
I was having a similar issue. I couldn't get Symlinks working with vagrant but a Hardlink Clone did. I was trying to have my Dev folder in sync with Google Drive but did not want to relocate the folder.
My Solution: Hardlink Clone
Download and install Linkshell for windows (and the listed prerequisite package) [ direct Link to actual file I downloaded | direct link to prerequisite package I downloaded ] Direct link good for Windows XP64,
Windows Vista64,
Windows Server ,
2003/2008/20012 64bit,
Windows 7/8/10 64bit
Right click on source folder (in my case the one I copied to Google drive) and select pick link source
In location where you want your "symlink", right click and select Drop as -> Hardlink Clone
Thats what it took for me to get it working with vagrant. I originally tried as symbolic link without success.
Cut the folder to where you need it from the VM, after that create the junction (or symlink) at the original location.

Developing on Windows -> Deploying on a Virtual Machine?

Is there an easy way to integrate with VirtualBox such that I could develop under the host, Windows, and deploy and run scripts via a mounted folder in a guest linux system?
I'm looking to develop for Linux under Windows, kind of.
You can use VirtualBox's Shared Folders feature to enable your Ubuntu virtual machine to mount a directory of your Windows host. However, you're likey to be deal with some impedance mismatches like different line endings. I hope that is the least of your worries.
You might want to check out vagrant http://vagrantup.com/
It provides a nice and easy system to create a VM from a template in Virtual Box, and will automatically mount the project folder in the guest VM. The config can also easily be included in your project so others can use it.
I develop in PHP. And I use Debian as guest OS, and Win7 as host OS.
You can done automaticly mount share folder by:
new a file in /etc/init.d/ named mnt_win_sf, than you edit it:
It must has the same info head with /etc/init.d/apache2. And you need just one line of command:
mount -t vboxsf share_folder_name mount_point
We also need to excute this script before apache2, so we edit /etc/init.d/apache2. In the Require Start line, add mnt_win_sf
update them by:
sudo update-rc.d mnt_win_sf defaults
sudo update-rc.d apache2 defaults

Resources