31

I have configured a shared folder between the Windows host and Ubuntu guest. The folder mounts at start up but its empty(It also has a padlock sign.). I have to run the command below to access its content(the padlock sign disappears).

  sudo mount.vboxsf media ~/media

How can i configure it to be run automatically at start up. I've tried adding to the start up programs but nothing happens. Am new to Linux so try to put your answer in a layman's language. Thanks.

Braiam
  • 67,791
  • 32
  • 179
  • 269
Njihia
  • 371
  • 1
  • 3
  • 6

2 Answers2

49

The mounted share folder belongs to the vboxsf user. You, as a user, were not added to the vboxsf group. To allow access to the shared folders permanently, copy and paste this command in a Terminal window:

sudo usermod -G vboxsf -a $USER

$USER will be replaced with your username. This command appends the user <username> to the vboxsf group, which is the owner of the shared folders (found in /media/... on the Ubuntu box).

You won't need to run a script at startup once you own the mounted shared folder.

But you will most likely need to logout and on again (or restart).

Frank N
  • 1,340
Cosmin Saveanu
  • 822
  • 6
  • 13
  • 1
    For a few other tips about Ubuntu on a VirtualBox (Mac) see: [blog entry] (http://aboutfoto.wordpress.com/2013/04/03/of-ggobi-macports-and-r/). – Cosmin Saveanu Jul 23 '13 at 13:05
  • 1
    It doesn't work. I had tried a similar thing earlier with this code: I don't know if its the same thing.
         `sudo adduser <username> vboxsf`
    
    – Njihia Jul 23 '13 at 16:15
  • 1
    Strange... On the box I'm using the shared folder appears as /media/sf_shared, and if I look at its permissions with ls -l I get: drwxrwx--- 2 root vboxsf 4096 Apr 3 18:47 sf_shared. Please check with the users-admin program if your user name is indeed in the vboxsf group (there is a button called Manage Groups and look at Properties of the vboxsf group). – Cosmin Saveanu Jul 23 '13 at 17:40
  • Am so sorry. The shared folder with the contents does appear in the media folder. What i wanted was for it to appear in my home folder with the contents. Sorry for the mistake. – Njihia Jul 25 '13 at 13:15
  • No problem. If you have writing access on the shared folder, that's fine. You can create a symbolic link in your home or Documents folder for easy access. In Terminal (assuming that you are in the directory where you want the link to appear) do: ln -s /media/sf_shared/ name_of_link. Replace sf_shared with the actual name of the shared directory and name_of_link with whatever you want. Alternatively, you can just drag the folder in Nautilus to the right navigation area and it will create an easy to access link. – Cosmin Saveanu Jul 26 '13 at 13:59
  • Thank you. Used the terminal option. Linux is haha,fun to learn. Thank you @Cocofifi. – Njihia Jul 26 '13 at 19:49
  • You're welcome. I'm glad you found a working solution. I have little experience with askubuntu, but if possible, it would be probably good to change the title of your question, so that people looking for the same kind of information could benefit from the discussion. – Cosmin Saveanu Jul 27 '13 at 21:26
  • How can i do that? Am also new to askbuntu. – Njihia Jul 29 '13 at 10:57
  • Me too :-) I think there is an edit link for the original question that allows you to change the title. Best regards. – Cosmin Saveanu Jul 30 '13 at 20:43
  • I've edited it.I hope that helps. – Njihia Aug 01 '13 at 07:10
  • Hey @Njihia its probably better to put all this comments (steps) in an answer and accept your answer. This way someone doesn't have to look through all this comments – mojo706 Aug 01 '13 at 07:22
  • Ok. A good suggestion. In fact i was looking for something like "accept as solution". I'll do that. Thanks @Mojo706. – Njihia Aug 02 '13 at 15:34
  • ! Restart virtual machine once you done this. – Chapuller Jul 26 '17 at 08:52
6

So here is how to access your shared folders on Ubuntu VM(Oracle Virtualbox). Am assuming you have already enabled auto-mount while you were adding the folder. Open the terminal and type.

sudo usermod -G vboxsf -a $USER

This command appends the current user to the vboxsf group, which is the owner of the shared folders (found in /media/ on the Ubuntu box). Confirm from your media folder if the shared folders are present. They're usually named "sf_name-of-shared-folder". For quick access, you may want to create a link to the shared folders in the home folder. In Terminal (assuming that you are in the directory where you want the link to appear and that you've enabled the Nautilus plugin that gives you the context menu option ) do:

ln -s /media/sf_shared/ name_of_link.

Replace sf_shared with the actual name of the shared directory and name_of_link with whatever you want. However the name-of-link shouldn't exist in the directory where you want to create the link(That is there should be no folder or file with that name). Alternatively, you can just drag the folder in Nautilus to the right navigation area and it will create an easy to access link.

Bora
  • 226
Njihia
  • 371
  • 1
  • 3
  • 6