87

I have Ubuntu 10 as the guest OS on a Windows 7 machine. I have been trying to setup shares through VirtualBox, but nothing is working. First, I create the share in VirtualBox and point it to a Windows folder. Then I try to mount the drive in Linux, but I keep getting

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

I have read so many solutions to this, but none seem to work. I have tried:

  • Using the mount.vboxsf syntax
  • Reinstalling VBox additions
  • Rebooting
  • Enabling and trying as root account

I made a share called "Test" in VBox Shared folders. Then I made a directory in ubuntu named "test2". Then I tried to execute this command:

sudo mount -t vboxsf Test /mnt/test2

Any other ideas?

1
  • 2
    i tried all the answers and after installing dkms error persisted. But the solution to me was to just restart ubuntu and mount again. It worked.
    – void
    Apr 13, 2020 at 13:34

11 Answers 11

96

In order to use shared folder functionality few prerequisites need to be met:

  • Make sure that Guest Additions are properly installed on the guest OS.
  • Users in a guest Ubuntu must be in the group vboxsf to be able to access shares.
  • Define a directory on the host that will be used in the virtual machine using the settings dialogue of Virtual Box.

Depending on host or guest OS the following may also be needed:

  • Do not share personal folders like /home/username or My Documents
  • Avoid special characters or empty spaces in the path to the shared folder, especially if the host or VM is a Windows machine
  • Use different names for share and mountpoint
  • Create a mountpoint on the guest OS (best in your HOME directory).

Testing shared folders functionality can be done by creating a shared directory on the host (e.g. C:\myshare), define this as a shared folder for your guest system in Virtual Box settings (e.g. share), create a mount point in your guest os (e.g. mkdir /home/username/host) and mount this in the guest OS with the command:

sudo mount -t vboxsf -o uid=1000,gid=1000 share /home/username/host

where the option -o makes sure that you will have access to the mount (that will otherwise be owned by root).

For further information on shared folders see also the Virtual Box User Manual.

Files or directories can also be shared over the network by using Samba on the host and the guest.

20
  • 4
    I believe I have met all of these requirements but am still getting the error. Is there a way that I can diagnose what the problem is?
    – skaz
    Mar 15, 2011 at 12:24
  • 1
    Not to the string literal level, but my share is C:\test instead of C:\myshare, it is defined in VBox 4.0.4. I have made a folder in /home/[myusername]/test2 and a folder in /mnt/test2 and run the command exactly on these two folders and both return the same error.
    – skaz
    Mar 15, 2011 at 13:56
  • 1
    Thanks for your help! I didn't realize that the words "test" and "Test2" would be considered as using the same name. This solved the problem!
    – skaz
    Mar 15, 2011 at 15:46
  • 2
    For 'share' I'd foolishly used sf_[sharename], since I could see it was being mounted under /media/ with that name and assumed it would need the ubuntu-local name and not VBox's own name. However, I removed the 'sf_' prefix and this solved the problem. Dec 29, 2015 at 18:13
  • 1
    @MichaelScheper these are recommendations only - if it works for you, all is fine.
    – Takkat
    Aug 8, 2018 at 7:09
17

I also met this trouble. I found that the shared folder were already mounted at /media/sf_share.

I tried to delete /media/sf_share, but I couldn't.

So I deleted shared folder "share" in my home directory.

$ rm -r ~/share

And then switch to root user with the following way:

$ sudo -i

Create softlink/shortcut to the /media/sf_share folder that owns by root user modify the ownership of softlink with chown command. Exit from root user to normal user

# ln -s /media/sf_share /home/username/share
# chown username.username /home/username/share
# exit
logout

$ chmod 777 ~/share

You can see the files in Windows through the shared folder. And username must be a member of group vboxsf.

2
  • Thanks ! you were right... already mounted in /media/sf_sharename
    – Laurent
    Oct 21, 2017 at 13:46
  • 1
    Using CentOS 7, and I also found that my directory is mounted at media/sf_sharename. Creating a symlink to that directory would seem to be a possible option, but this is quite different from the advertised/documented procedure on the VirtualBox site. There must be a proper resolution to this!?!? Sep 15, 2018 at 17:57
12

Here is what worked for me without any problem

I figured it out that, actually my user name was not in vboxsf group. Following two commands will help to get the group info:

grep "vboxsf" /etc/group    
grep "saurav" /etc/group

So I added saurav (me) to the vboxsf group using following command:

sudo usermod -a -G vboxsf saurav 

Then restarted the virtualbox and then.. Jumped from my placed.. :D :D Everything worked fine without any problem.

Please comment if any one still having any problem..

3
  • 2
    This worked for me, thank you. There is only a type: should be sudo usermod -a -G vboxsf saurav (first group then user).
    – user673592
    Apr 9, 2016 at 11:04
  • Yes.. Typed incorrect.. :) Thanks for pointing out. Edited now.. Apr 9, 2016 at 13:53
  • 1
    You don't need to restart VB to acquire your newly assigned group. $ su - saurav will do the trick. Nov 28, 2017 at 12:11
2

I also struggled a lot with the mounting, and tried everything I come up with in the interwebz but I finally found a very weird workaround to solve it! My guest is Ubuntu 13 and my host is Windows 7.

Change to the media folder and from there type user@os:/media$ sudo mount -t vboxsf share /home/username/folder

Yeah, that's it. But I don't understand how come it only works if it's done from the media folder. If someone knows please kindly explain us below. Thanks.

P.s. Editing my /etc/rc.local to do the automounting at startup doesn't work for me.

3
  • 1
    /etc/rc.local will never work, since it's done before the network is up.
    – Braiam
    Jan 3, 2014 at 18:01
  • 2
    Hi Braiam! Nice to know. Unfortunately I have read in countless of sites people recommend editing the /etc/rc.local for the automounting. Do you know what is the correct way to automount it on startup? Thanks. Jan 4, 2014 at 19:30
  • I am also finding it only works from /media. Very strange. I just added this to my .profile: pushd media && sudo mount /media/<theshare> && popd.
    – Matt Greer
    Apr 9, 2018 at 16:21
2

Tried all the aforesaid and nothing worked for me. Lastly I created a new transient folder "Shared" with "Make Permanent" and "Auto Mount" enabled. And then I run the command

sudo mount -t vboxsf -o uid=1000,gid=1000 Shared /mnt/sharedvm

It worked for me. No error this time.

1

With VirtualBox 5.1.20 running on Windows 10, and Ubuntu 16.04 as the guest OS with GuestAdditions 5.1.20 installed, I couldn't mount the shared folders from the command line. The mount commands failed, with mentions of Protocol Error and sf_read_super_aux err=-22.

Eventually I found https://www.virtualbox.org/ticket/16670 "mount.vboxsf symlink broken". I followed one of the workarounds there, to correct the symlink for mount.vboxsf, and it all worked. My approach was to do:

mv /sbin/mount.vboxsf /sbin/mount.vboxsf-orig
ln -s /opt/VBoxGuestAdditions-5.1.20/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf

The commands need to be done by root. So, because it was Ubuntu, I added "sudo " at the beginning of each line to do the command as root. Other flavors of Linux have other ways of doing that.

As an aside, there was a similar symlink problem reported in virtualbox's Ticket #12879 "Can't mount shared folders with guest additions 4.3.10" in 2014, that was fixed the following month.

2017-04-27

4
  • @duncan: good point. The title of the ticket describes the problem, but I edited to show the solution I used.
    – J Cumming
    May 1, 2017 at 19:24
  • The changelog for virtual box v5.1.22 at virtualbox.org/wiki/Changelog#v22 says that
    – J Cumming
    May 1, 2017 at 19:27
  • The changelog for virtual box v5.1.22, released 2017-04-28, (virtualbox.org/wiki/Changelog#v22), says that this bug/ticket #16670 is fixed. I'm excited!
    – J Cumming
    May 1, 2017 at 19:35
  • Not sure why this was downvoted, but it helped me with my problems using Vbox 5.122
    – qodeninja
    Aug 1, 2017 at 3:41
1

For me, the problem was that I was a goose, and I'd forgotten that I'd removed the entry from my Shared Folders list in VirtualBox (Machine→Settings→Shared Folders).

I'm just throwing this in here, in case anybody else is ever similarly mislead by 'Protocol error'.

:honk: 😉

1

I tried a few answers and then saw void's comment saying he restarted the Linux guest OS and re-mounted.

Worked for me. :)

0

My shared folder was working and after rebooting my host, it wasn't.

By changing the name of the shared folder from Shared to Shared2 it worked.

config.vm.synced_folder "/Users/username/Dropbox/Shared", "/Shared2"

No idea on what happened and why nor how to fix. System with no global mutable state like Nix do have a point.

0

Personally I faced the same error message and the problem was related to the fact I did a typo related to the folder located on the host machine and which I set as a shared folder from within the virtual machine thanks to the guest additions.

So the right command is:

sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) shared_folder_located_in_host_machine path_to_mounting_folder_inside_the_virtual_machine

This fixed the error message.

0

For me it was the wrong version of guest-additions.

I moved my whole VM from one laptop (which ran VirtualBox 5.8/something) to another laptop with VirtualBox 6.0. Everything worked except the mounting of shared folder.

I just started VM, clicked on Devices -> Insert Guest additions CD image... and followed instructions. It cribbed a bit about presence of older version of guest additions, but then removed it and installed the new one on second attempt. Reboot and works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .