I'm using VirtualBox with OS X as host and CentOS on the guest VM.
In OS X I created folder myfolder
, added it as shared folder to the VM, turned on the VM, in CentOS created folder /home/user/myfolder
and typing:
sudo mount -t vboxsf myfolder /home/user/myfolder
and have output:
/sbin/mount.vboxsf: mounting failed with the error: No such device
What I'm doing wrong?
UPDATED:
Guest Additions
installed.
For me, on a mac, it turned out I had an old VirtualBox image stored on my machine that didn't have metadata, so it wasn't being updated to the latest version.
That old image had an older version of the vbguest plugin installed in it, which the newer vbguest plugin on my machine couldn't work with.
So to fix it, I just removed the image that my Vagrant was based on, and then Vagrant downloaded the newer version and it worked fine.
You can find out which boxes you have cached on your machine by running:
I had also upgraded my vbguest plugin in my earlier attempts at getting this to work, using the following process, but I don't think this helped. FYI !
If you find bring the box fails on guest addtions, you can try doing the following to ensure the plugins install correctly. This downloads the latest based image for your system (for me CentOS), and may resolve the issue (it did for me!)
Below two commands works for me.
You're using share folders, so you need to install VirtualBox Guest Additions inside your virtual machine to support that feature.
Vagrant
If you're using Vagrant (OS X:
brew cask install vagrant
), run:In case it fails, check the logs, e.g.
Maybe you're just missing the kernel header files.
VM
Inside VM, you should install Guest Additions, kernel headers and start the service and double check if kernel extension is running.
This depends on the guest operating system, so here are brief steps:
Install kernel include headers (required by VBoxLinuxAdditions).
sudo apt-get update && sudo apt-get install kernel-devel
sudo yum update && sudo yum -y install kernel-headers kernel-devel
Install Guest Additions (this depends on the operating system).
Ubuntu:
sudo apt-get -y install dkms build-essential linux-headers-$(uname -r) virtualbox-guest-additions-iso
If you can't find it, check by
aptitude search virtualbox
.Debian:
sudo apt-get -y install build-essential module-assistant virtualbox-ose-guest-utils
If you can't find it, check by
dpkg -l | grep virtualbox
.manually by downloading the iso file inside VM (e.g.
wget
) and installing it, e.g.wget http://download.virtualbox.org/virtualbox/5.0.16/VBoxGuestAdditions_5.0.16.iso -P /tmp
sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.16.iso /mnt
sudo sh -x /mnt/VBoxLinuxAdditions.run # --keep
Extra debug:
cd ~/install && sh -x ./install.sh /mnt/VBoxLinuxAdditions.run
Double check that kernel extensions are up and running:
sudo modprobe vboxsf
Start/restart the service:
sudo /opt/VBoxGuestAdditions*/init/vboxadd setup
(addsudo sh -x
to debug)sudo /etc/init.d/vboxadd-service start
sudo /etc/init.d/vboxdrv setup
sudo service VBoxService start
Building the main Guest Additions module
If above didn't work, here are more sophisticated steps to fix it. This assumes that you've already VBoxGuestAdditions installed (as shown above).
The most common reason why mounting shared folder doesn't work may related to building Guest Additions module which failed. If in
/var/log/vboxadd-install.log
you've the following error:this means either you didn't install kernel sources, or they cannot be found.
If you installed them already as instructed above, run this command:
So basically
vboxadd
script is expecting your kernel sources to be available at the following dir:Check if the kernel dir exists (symbolic link points to the existing folder). If it's not, please install them to the right folder (e.g. in
/usr/src/kernels
).So
vboxadd
script can enter your kernel source directory and runmake kernelrelease
, get the value and compare with your current kernel version.Here is the logic:
If the kernel version doesn't match with the sources, maybe you've to upgrade your Linux kernel (in case the sources are newer than your kernel).
CentOS
Example fixing steps for CentOS:
Okay everyone is missing a basic fact.
mkdir /test
- Makes sub directory in current directory.sudo mkdir /test
- Make directory in Root.So if your shared directory name is
shared
and you do the following:It generates this error:
Because the directory is in the wrong place! Yes that's what this error is saying. The error is not saying reload the VBOX guest options.
But if you do this:
Then it works fine.
It really amazes me how many people suggest reloading the Vbox guest additions to solve this error or writing a complex program to solve a directory created in the wrong place.
My shared folder/clipboard stopped to work for some reason (probably due to a patch installation on my virtual machine).
sudo mount -t vboxsf Shared_Folder ~/SF/
Gave following result:
VirtualBox: mount.vboxsf: mounting failed with the error: No such device
The solution for me was to stop vboxadd and do a setup after that:
I have similar issue, check header if it's not match then run below command
CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel