190

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.

6
  • Make sure Guest Additions is installed properly, you might have to sudo apt-get upgrade ;sudo apt-get install build-essential module-assistant; sudo m-a prepare; You need to see the Guest Aditions module being built...
    – ntg
    Commented Jun 3, 2015 at 14:46
  • 14
    To the random internet surfer who's having this problem: Do yourself a favour and look at the second answer.
    – jrharshath
    Commented Dec 17, 2015 at 22:35
  • 9
    a tip - sudo mount -t vboxsf sf_folder /home/user/folder, here the sf_folder and folder MUST be different names
    – cnaize
    Commented Feb 22, 2016 at 16:24
  • 8
    @jrharshath Which one is the "second answer"? Sorting can change. Click on share in the answer to get the permalink.
    – wisbucky
    Commented Mar 10, 2016 at 18:46
  • @cnaize Ok, that is the REAL answer. I literally spent hours trying to figure out why this wasn't working. Yes, need to have the folder namd and share name be different or the mount command does not work. FOLKS THIS IS THE REAL SOLUTION! Commented Oct 3, 2021 at 13:49

21 Answers 21

190

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
11
  • 1
    After upgrading my Ubuntu 12.04 vm to Ubuntu 14.04, my shared folders were empty in the vm and when trying to manually mount, I got the error /sbin/mount.vboxsf: mounting failed with the error: No such device. After running the above and restarting the system, my shared folders appeared as they did before upgrading.. thanks!
    – Angelo
    Commented Apr 4, 2016 at 13:57
  • The problem persists on VirtualBox 5.0.18 with an Ubuntu 16.04 guest, and this solution worked for me.
    – Ivan Perez
    Commented Jul 9, 2016 at 10:17
  • 9
    how do you stop vboxadd?
    – aristofun
    Commented Jul 13, 2016 at 8:48
  • 1
    Thanks! I also had to install the vagrant-vbguest plugin - stackoverflow.com/a/23752848/2043134 Commented Jun 29, 2017 at 8:15
  • 4
    @aristofun @brainmurphy1 : in that same directory, before sudo ./vboxadd setup, you can do sudo ./vboxadd stop. Not sure if it's still necessary, but I'm guessing that's what that sentence means.
    – hraban
    Commented Jan 13, 2018 at 14:52
103

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
      2. sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.16.iso /mnt
      3. sudo sh -x /mnt/VBoxLinuxAdditions.run # --keep

        Extra debug: cd ~/install && sh -x ./install.sh /mnt/VBoxLinuxAdditions.run

  3. Double check that kernel extensions are up and running:

    • sudo modprobe vboxsf
  4. 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
4
  • 1
    RE the CentOS fix, it solved my issue but make sure you have gcc installed.
    – ggdx
    Commented Jul 28, 2016 at 15:43
  • 2
    Using Chef's Test Kitchen (Vagrant), vagrant plugin install vagrant-vbguest worked for me
    – pfernandom
    Commented Apr 5, 2017 at 19:51
  • In my case it was because the GuestAdditions weren't the same declared between Vagrant and the Guest.
    – Anthony
    Commented Nov 8, 2017 at 10:12
  • 1
    vagrant plugin install vagrant-vbguest vagrant vbguest works also on centos 7 and resolved the issue. Thanks Commented Mar 13, 2019 at 13:33
58

I am able to resolved this by running below commmand

modprobe -a vboxguest vboxsf vboxvideo

4
  • The same issue happened on my vbox5.0.6 and Centos 7 guest. The issue is I'll need to run this every time after (re)boot. Commented Oct 11, 2015 at 19:15
  • 14
    This works because these are the kernel modules you need running on a guest in order for VirtualBox to properly do all of its functions. Specifically, vboxsf (VirtualBox Shared Folders) is what's needed here. You can list these 3 files one per line in a file in /etc/modules-load.d/ (call it maybe virtualbox.conf) to make this change persist through reboots. Commented Nov 29, 2015 at 16:18
  • 1
    On Debian 8 guest, running this command ruined video output. Commented Feb 5, 2017 at 22:48
  • 1
    ´modprobe: WARNING: Module vboxsf not found in directory /lib/modules/5.3.11-100.fc29.x86_64´ Commented Feb 4, 2022 at 11:23
26

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.

4
  • 3
    apt-get install linux-headers-virtual helped with Lubuntu 15.04 on VirtualBox
    – fider
    Commented Oct 8, 2015 at 7:55
  • /media/cdrom ois empty in my case
    – CCC
    Commented Jan 24, 2019 at 20:41
  • Did you Clicked on Install Guest Additions from the Devices menu ?
    – Froggiz
    Commented Jan 26, 2019 at 17:43
  • /sbin/mount.vboxsf: mounting failed with the error: No such device Commented Feb 4, 2022 at 11:27
16

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

1
  • thanks, it helped me a lot (Y) Commented Dec 5, 2016 at 6:07
10

This was resolved by:

yum install gcc kernel-devel make

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

9
  • Ran all updates no luck at all. Sorry, the answer with 13 up-votes did work better Commented Jul 2, 2015 at 19:57
  • I'm using a Windows 7 host with RHEL 7 and this resolved it for me (including the info from the gist link) - Thank you! Commented Dec 15, 2015 at 17:34
  • On Ubuntu, this worked: sudo apt-get install build-essential linux-headers-uname -r dkms
    – cstroe
    Commented Jan 13, 2016 at 19:55
  • 4
    @AndrewShatnyy "answer with 13 up-votes" is ambiguous. Please post the permalink to the answer you are referring to (click share under the answer)
    – wisbucky
    Commented Mar 10, 2016 at 18:47
  • 1
    @wisbucky you right sorry. stackoverflow.com/a/29456128/849187 worked two times already Commented Mar 10, 2016 at 21:57
6

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

5

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

vagrant plugin install vagrant-winnfsd
0
4

The solution for me was to update guest additions

(click Devices -> Insert Guest Additions CD image)

3

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.

2
  • 1
    It worked for me after running ` sudo modprobe vboxsf` Commented Nov 13, 2015 at 11:41
  • 1
    modprobe: FATAL: Module vboxsf not found in directory /lib/modules/5.3.11-100.fc29.x86_64 Commented Feb 4, 2022 at 11:28
3

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

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

3

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
2

    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

0
1

On Ubuntu this worked:

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

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.

1

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
0

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

0

If you're on Debian:

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

sh /media/cdrom/VBoxLinuxAdditions.run uninstall

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

0

An update did the trick for me !

$ vagrant box update
$ vagrant plugin install vagrant-vbguest 
-1

Below two commands works for me.

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

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.

4
  • 2
    The error being encountered is "No such device", not "No such file or directory". :)
    – mjtko
    Commented May 20, 2015 at 10:04
  • mynttest@mynttest-VirtualBox:/media/sf_shared$ sudo mkdir ~/test sudo mount -t vboxsf vbshared ~/test mkdir: invalid option -- 't' Try `mkdir --help' for more information. Commented May 28, 2015 at 9:14
  • 1
    mkdir /test will create the directory /test in /. sudo mkdir /test will create the same directory, but owned by root rather than the current user.
    – Schlueter
    Commented Mar 3, 2016 at 21:34
  • I had same problem. So i installed kernel-devel.x86_64 0:2.6.32-754.11.1.el6 and then run these command-- cd /opt/VBoxGuestAdditions-*/init and sudo ./vboxadd setup. That worked for me. Commented Mar 4, 2019 at 7:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.