Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 29 down vote accepted

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.
  • Do not share personal folders like /home/username or My Documents
  • avoid special characters or empty spaces in the path to the shared folder
  • use different names for share and mountpoint
  • create a mountpoint on the guest OS (best in your HOME directory).

Testing shared folders functionality can thus 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.

share|improve this answer
1  
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 '11 at 12:24
    
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 '11 at 13:56
    
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 '11 at 15:46
    
My problem was with the name apparently. It started after I applied an update. Now solved by changing the mounted name to something other than the actual name. –  aditya menon Mar 15 '13 at 9:03
    
everything is good and done. but i need to mount the the shared folder every time I login..ANY ADVICE –  abh-kirrack Apr 27 '13 at 9:58

Make sure you are sharing the folders in your host system (like windows xp, 7, 8 or 8.1 extra

make sure the guest additions are installed without any errors or failures

make this following script

sharename="put the name of your shared folder here..same name also works";
sudo rm -rf /mnt/$sharename  
sudo mkdir /mnt/$sharename
sudo chmod 777 /mnt/$sharename
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename

sudo run the above script

enjoy the shared folder in the /mnt/ directory

share|improve this answer
    
sudo rm -rf /mnt/$sharename with the example $sharename set with spaces in the value... asking for big trouble (very dangerous!). -1. And besides, do you really want to remove all files if you have something mounted there? Please, never advise to rm -rf something like this just to mount something. –  gertvdijk Aug 27 at 13:48

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.

share|improve this answer
1  
/etc/rc.local will never work, since it's done before the network is up. –  Braiam Jan 3 at 18:01
    
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. –  user1482789 Jan 4 at 19:30

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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