Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed the steps for sharing folders between Windows 7 and Ubuntu in VirtualBox.

Despite that the folder appears with a X sign and gives me the following message when a try to open it:

The folder content could not be displayed

When I choose Shared Folder from the VirtualBox Device menu, the following warning is displayed:

On the system page, you have assigned more than 50% of your computer's memory (2.93 GB) to the virtual machine...

How can I successfully share folders between Windows and Ubuntu using VirtualBox?

share|improve this question
up vote 41 down vote accepted

Access to shared folders in Virtual Box

Command line

By default Virtual Box shared folders are created with read/write permission for the guest. This can be done from the command line on the host with:

VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\test"

By adding the option --readonly we can restrict these for read only access. Use the --transient option if you only want the shares to appear in the present session but not persistent for follwing sessions. There are some limitations for shared folders (see this question for details). If prerequisites are met we may mount these shared folders manually by running the following commands in the guest:

mkdir /home/<user>/vboxshare
sudo mount -t vboxsf -o uid=1000,gid=1000 share /home/<user>/vboxshare

Of course we can also use different mount options to mount as read/only or mount with read access only to root.

Auto-Mount through Virtual Box Manager

In case we enabled auto-mounting on creating a shared folder from the Virtual Box Manager those shared folders will automatically be mounted in the guest with mount point /media/sf_<name_of_folder>. To have access to these folders users in the guest need to be a member of the group vboxsf.

Source and further reading: Virtual Box User Manual

share|improve this answer
2  
i set a shared folder in the GUI and also set the Auto-Mount. restarted the VM, went to /media but still nothing there – amphibient Aug 19 '13 at 20:11
    
@amphibient Same here!! what should I do 。゚ヽ(゚´Д`)ノ゚。 – laike9m Apr 28 '15 at 3:21
    
@amphibient @laike9m I had to restart the VM to see the folder in /media/ – David_G Apr 4 at 0:53

Actually there is an easy way to do that. First you have to install the extension pack for VirtualBox. After that and restart your virtual machine, install in your guest Ubuntu GuestAdditions (you can do it mounting the iso which is on /media or LeftControl+D).

After that, reboot and try to access to /media/sf_your_shared_folder_name. If you still don't have access, that's mean you don't belong to the vboxsf group, as Nilo points earlier.

That command will solve your problem:

sudo adduser your_username vboxsf

share|improve this answer
3  
THIS. I wasn't in the user group. Seems like that should have been automated by the gest additions or at least stated clearly. – AwokeKnowing Jun 17 '14 at 0:39
1  
seems the problem for me is that my username is not root. That should have been mentioned somewhere – AwokeKnowing Jun 17 '14 at 0:47
4  
IMPORTANT: You must reboot the computer after calling adduser. – kol Jan 17 '15 at 15:04
2  
@kol No, you need only to log out and log in again. – Atcold Sep 12 '15 at 23:41

Add the shared folder to the virtual machine using vBox graphical interface Make sure to select automount and make permanent

Login to the virtual machine using a root account

Check vboxsf group exists

~$ grep vboxsf /etc/group
vboxsf:x:125:

Check user is not already in vboxsf group

~$ id nilo
uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare)

Add user nilo to vboxsf group

~$ sudo usermod -a -G vboxsf nilo

Check again user groups

~$ id nilo
uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf)

Reboot and login as nilo

Shared folder is now accesible in /media/sf_dropbox (dropbox is the name I gave to the share)

share|improve this answer
  1. Install the program called 'Programs and Group' from the Software Center
  2. Choose the current user and click on Manage Groups
  3. Choose vboxsf and click 'Add'
  4. Reboot
share|improve this answer

First, please make sure you have installed the Guest Additions

  1. Start your VM

  2. Devices > Insert Guest Additions CD image...enter image description here

  3. Mount the CD: sudo mount /dev/cdrom /media/cdrom

  4. Install the necessary packages: sudo apt-get install make gcc linux-headers-$(uname -r)

  5. Install: sudo /media/cdrom/VBoxLinuxAdditions.run

Second :

~$ echo $USER; 
# ahmed

Then :

~$ sudo usermod -a -G vboxsf ahmed

Reboot ...

Known that the label of your shared folder is : lpi (for example): enter image description here - Prepend prefix sf_ to the label. Then , you will find your shared folder under :

/media/sf_lpi

Finally, you can also create a link to your home. For example: ln -s /media/sf_lpi /home/ahmed/lpi

:)

share|improve this answer

This is both an answer and a question.

Answer

  1. Create a dir where you're going to mount this, like mkdir docs

  2. Install Guest Additions into the guest Ubuntu machine as others have posted here.

  3. Shutdown the Ubuntu guest, then configure the guest.

  4. In Storage as others have pointed to, setup your shared folder and make a note of what you set as the name in the second field. For example "crazy." Check the box for Auto-Mount.

  5. Boot the guest Ubuntu.

  6. Despite what you asked it won't actually be accessible, but it will be part-way there for some reason (this is the question). You'll find instead something is present at:

    /media/sf_crazy

where crazy is the name you gave it. And, it will also create something in your home dir:

~/crazy

You now need to take one more step to actually mount it (why?):

  1. Use sudo to mount it:

    sudo mount -o uid=1000,gid=1000 -t vboxsf ~/crazy ~/docs

Question

I'm sure there's some clear explanation as to why any of this is but man this is confusing and explains why there are 3 or 4 questions fumbling over this endlessly across AskUbuntu, ServerFault, SuperUser and StackOverflow. This really should be simple. It's either not or simply broken. In fact, in my opinion it's either broken from a code standpoint or broken in its feature design. You should be able to check the Auto-mount box and get access to it from the default user that logs in without sudo. That clearly isn't happening, or I am totally missing something.

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.