VirtualBox: mount.vboxsf: mounting failed with the error: No such device

MacosCentosVirtual MachineVirtualbox

Macos Problem Overview


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.

Macos Solutions


Solution 1 - Macos

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:

cd /opt/VBoxGuestAdditions-*/init  
sudo ./vboxadd setup

Solution 2 - Macos

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:

vagrant plugin install vagrant-vbguest
vagrant vbguest

In case it fails, check the logs, e.g.

vagrant ssh -c "cat /var/log/vboxadd-install.log"

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:

  1. Install kernel include headers (required by VBoxLinuxAdditions).

    • RHEL: sudo apt-get update && sudo apt-get install kernel-devel
    • CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel
  2. 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.

    1. `wget http://download.virtualbox.org/virtualbox/5.0.16/VBoxGuestAdditions_5.0.16.iso -P /tmp`
    1. `sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.16.iso /mnt`
    1. `sudo sh -x /mnt/VBoxLinuxAdditions.run # --keep`
    
      Extra debug: `cd ~/install && sh -x ./install.sh /mnt/VBoxLinuxAdditions.run`
    
  1. Double check that kernel extensions are up and running:

    • sudo modprobe vboxsf
  2. Start/restart the service:

    • manually: sudo /opt/VBoxGuestAdditions*/init/vboxadd setup (add sudo sh -x to debug)
    • Debian: sudo /etc/init.d/vboxadd-service start
    • Fedora: sudo /etc/init.d/vboxdrv setup
    • CentOS: 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:

> The headers for the current running kernel were not found.

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:

$ sudo sh -x /opt/VBoxGuestAdditions-5.0.16/init/vboxadd setup 2>&1 | grep KERN
+ KERN_VER=2.6.32-573.18.1.el6.x86_64
+ KERN_DIR=/lib/modules/2.6.32-573.18.1.el6.x86_64/build

So basically vboxadd script is expecting your kernel sources to be available at the following dir:

ls -la /lib/modules/$(uname -r)/build

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 run make kernelrelease, get the value and compare with your current kernel version.

Here is the logic:

KERN_VER=`uname -r`
KERN_DIR="/lib/modules/$KERN_VER/build"
if [ -d "$KERN_DIR" ]; then
    KERN_REL=`make -sC $KERN_DIR --no-print-directory kernelrelease 2>/dev/null || true`
    if [ -z "$KERN_REL" -o "x$KERN_REL" = "x$KERN_VER" ]; then
        return 0
    fi
fi

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

Try:

vagrant plugin install vagrant-vbguest vagrant vbgues

If won't work, try the following manual steps for CentOS:

$ sudo yum update
$ sudo yum install kernel-$(uname -r) kernel-devel kernel-headers # or: reinstall
$ rpm -qf /lib/modules/$(uname -r)/build
kernel-2.6.32-573.18.1.el6.x86_64
$ ls -la /lib/modules/$(uname -r)/build
$ sudo reboot # and re-login
$ sudo ln -sv /usr/src/kernels/$(uname -r) /lib/modules/$(uname -r)/build
$ sudo /opt/VBoxGuestAdditions-*/init/vboxadd setup

Solution 3 - Macos

I am able to resolved this by running below commmand

modprobe -a vboxguest vboxsf vboxvideo

Solution 4 - Macos

In addition to @Mats answer, I'm adding some more info (it helped me on Debian 8).

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 me 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:

cd /opt/VBoxGuestAdditions-*/init 
sudo ./vboxadd setup

At this point, if you still get the following error:

> No such device. The Guest Additions installation may have failed. The error has been logged in /var/log/vboxadd-install.log

You need to install linux headers:

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

then you can install Guest Additions:

sh /media/cdrom/VBoxLinuxAdditions.run --nox11

and restart your Linux by:

reboot

then you will be able to mount your shared folder!

mount -t vboxsf Shared_Folder ~/SF/

More informations (in French), check this page.

Solution 5 - Macos

This was the only solution what worked for me:

Install Vagrant plugin: vagrant-vbguest, which can keep your VirtualBox Guest Additions up to date.

vagrant plugin install vagrant-vbguest

Source: https://github.com/aidanns/vagrant-reload/issues/4#issuecomment-230134083

Solution 6 - Macos

This was resolved by:

yum install gcc kernel-devel make

workaround is here: https://gist.github.com/larsar/1687725

Solution 7 - Macos

Shared folder was earlier working for me but all f sudden it stopped working (Virualbox - host was Windows 7, Guest was OpenSuSe)

modprobe -a vboxguest vboxsf vboxvideo

then mount -t vboxsf testsf /opt/tsf (testsf was the folder in Windows C drive which was added in Virtualbox shared folder --- and /opt/tsf is the folder in OpenSuse

Solution 8 - Macos

My host is Windows10 my VM guest is ubuntu build by vagrant. This worked for me:

vagrant plugin install vagrant-winnfsd

Solution 9 - Macos

The solution for me was to update guest additions

(click Devices -> Insert Guest Additions CD image)

Solution 10 - Macos

I also had a working system that suddenly stopped working with the described error.

After furtling around in my /lib/modules it would appear that the vboxvfs module is no more. Instead modprobe vboxsf was the required incantation to get things restarted.

Not sure when that change ocurred, but it caught me out.

Solution 11 - Macos

I am running VirtualBox 5.1.20, and had a similar issue. Here is a url to where I found the fix, and the fix I implemented:

# https://dsin.wordpress.com/2016/08/17/ubuntu-wrong-fs-type-bad-option-bad-superblock/
if [ "5.1.20" == "${VBOXVER}" ]; then
  rm /sbin/mount.vboxsf
  ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
fi

The link had something similar to /usr/lib/VBoxGuestAdditions/other/mount.vboxsf, rather than what I have in the script excerpt.

For a build script I use in vagrant for the additions:

[https://github.com/rburkholder/vagrant/blob/master/scripts/additions.sh][1]

Seems to be a fix at https://www.virtualbox.org/ticket/16670

[1]: https://github.com/rburkholder/vagrant/blob/master/scripts/additions.sh "additions.sh"

Solution 12 - Macos

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.

# Remove an old version of the virtual box image that my vagrant was using    
$ vagrant box remove centos/7 

You can find out which boxes you have cached on your machine by running:

$ vagrant box list

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 !

# Get rid of old plugins
vagrant plugin expunge 

# Globally install the latest version of the vbguest plugin`
vagrant plugin install vagrant-vbguest 

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!)

$ vagrant box update

Solution 13 - Macos

    There can be errors/incorrect approach in two scenarios. Check both of it and figure it out

SCENARIO 1 :

      Once you are running the VBoxLinuxAdditions.run or VBoxSolarisAdditions.pkg or VBoxWindowsAdditions.exe , check if all the modules are getting installed properly.

1.1.a. In case of VBoxLinuxAdditions, if
Building the VirtualBox Guest Additions kernel modules gets failed,
check the log file in /var/log/vboxadd-install.log . If the error is due to kernel version update your kernel and reboot the vm. In case of fedora,
1.1.b. yum update kernel*
1.1.c. reboot
1.2. If nothing gets failed, then all is fine. You are already having the expected kernel version

SCENARIO 2 :

     If the VBoxGuestAdditions is installed (check for a folder /opt/VBoxGuestAdditions-* is present .... * represents version) you need to start it before mounting.

2.1. cd /opt/VBoxGuestAdditions-*/init && ./vboxadd start

      You need to specify the user id and group id of your vm user as options to the mount command.

2.2.a. Getting uid and gid of a user:
      id -u <'user'>
      id -g <'user'>
2.2.b. Setting uid and gid in options of mount command:
      mount -t vboxsf -o uid=x,gid=x    shared_folder_name    guest_folder

Solution 14 - Macos

On Ubuntu this worked:

sudo apt-get install build-essential linux-headers-`uname -r` dkms

Solution 15 - Macos

Had the same issue with VirtualBox 5.0.16/rXXX

Installed latest VirtualBox 5.0.18 and installed latest Vagrant 1.9.3, issue went toodles.

Solution 16 - Macos

I added as root user

/etc/rc.d/rc.local 
/root/mount-vboxsf.sh

then

chmod +x /etc/rc.d/rc.local

and the sample script /root/mount-vboxsf.sh (set your own the uid and gid options)

modprobe -a vboxguest vboxsf vboxvideo
mount -t vboxsf NAME_SHARED_DIRECTORY /media/sf_NAME_SHARED_DIRECTORY -o rw,uid=0,gid=0

you need add

chmod + /root/mount-vboxsf.sh

Solution 17 - Macos

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

Solution 18 - Macos

If you're on Debian:

  1. remove all installed package through Virtualbox Guest Additions ISO file:

sh /media/cdrom/VBoxLinuxAdditions.run uninstall

  1. install Virtualbox packages:

apt-get install build-essential module-assistant virtualbox-guest-dkms virtualbox-guest-utils

Note that even with modprobe vboxsf returning nothing (so the module is correctly loaded), the vboxsf.so will call an executable named mount.vboxsf, which is provided by virtualbox-guest-utils. Ignoring this one will prevent you from understanding the real cause of the error.

strace mount /your-directory was a great help (No such file or directory on /sbin/mount.vboxsf).

Solution 19 - Macos

An update did the trick for me !

$ vagrant box update
$ vagrant plugin install vagrant-vbguest 

Solution 20 - Macos

Below two commands works for me.

vagrant ssh
sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

Solution 21 - Macos

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:

mkdir /test
sudo mount -t vboxsf shared /test

It generates this error:

sbin/mount.vboxsf: mounting failed with the error: No such file or directory

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:

sudo mkdir ~/test
sudo mount -t vboxsf shared ~/test

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncnaizeView Question on Stackoverflow
Solution 1 - MacosMatsView Answer on Stackoverflow
Solution 2 - MacoskenorbView Answer on Stackoverflow
Solution 3 - MacosAtul NView Answer on Stackoverflow
Solution 4 - MacosFroggizView Answer on Stackoverflow
Solution 5 - MacosxxxbenceView Answer on Stackoverflow
Solution 6 - MacoscnaizeView Answer on Stackoverflow
Solution 7 - MacosMAlamView Answer on Stackoverflow
Solution 8 - MacosKaiacodeView Answer on Stackoverflow
Solution 9 - MacosArchLinuxTuxView Answer on Stackoverflow
Solution 10 - MacosTim NView Answer on Stackoverflow
Solution 11 - MacosRaymond BurkholderView Answer on Stackoverflow
Solution 12 - MacosBrad ParksView Answer on Stackoverflow
Solution 13 - MacosyottabyttView Answer on Stackoverflow
Solution 14 - MacoscstroeView Answer on Stackoverflow
Solution 15 - MacosAKSView Answer on Stackoverflow
Solution 16 - MacosDiego piccininiView Answer on Stackoverflow
Solution 17 - MacosJayen ChondigaraView Answer on Stackoverflow
Solution 18 - MacosYvanView Answer on Stackoverflow
Solution 19 - MacosShankar ARULView Answer on Stackoverflow
Solution 20 - MacosSayOwlView Answer on Stackoverflow
Solution 21 - MacosCRANKYOLDGUYView Answer on Stackoverflow