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

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

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

Youre using share folders, so you need to install VirtualBox Guest Additions inside your virtual machine to support that feature.

Vagrant

If youre 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 youre 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 cant find it, check by aptitude search virtualbox.

    • Debian: sudo apt-get -y install build-essential module-assistant virtualbox-ose-guest-utils

      If you cant 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 didnt work, here are more sophisticated steps to fix it. This assumes that youve already VBoxGuestAdditions installed (as shown above).

The most common reason why mounting shared folder doesnt work may related to building Guest Additions module which failed. If in /var/log/vboxadd-install.log youve the following error:

The headers for the current running kernel were not found.

this means either you didnt 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 its 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 doesnt match with the sources, maybe youve to upgrade your Linux kernel (in case the sources are newer than your kernel).

CentOS

Try:

vagrant plugin install vagrant-vbguest vagrant vbgues

If wont 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

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

I am able to resolved this by running below commmand

modprobe -a vboxguest vboxsf vboxvideo

Leave a Reply

Your email address will not be published.