667

I'm using Windows and Virtualbox with RedHat, putting it simple: I've created a shared folder so I can use Eclipse on my Windows OS and do some testing in Linux.

However, I can't access the shared folder with my user, I've logged in with root and used chmod 777 and even moved my user to the folder's group.

Whatever I do the result is the same:

/media/sf_sharedFolder/: Permission denied

What can I do? How can I access the shared folder with my user?

SaintLike
  • 9,119
  • 11
  • 39
  • 69

11 Answers11

1385

Add yourself to the vboxsf group within the guest VM.

Solution 1

Run sudo adduser $USER vboxsf from terminal.
(On Suse it's sudo usermod --append --groups vboxsf $USER)

To take effect you should log out and then log in, or you may need to reboot.

Solution 2

Edit the file /etc/group (you will need root privileges). Look for the line vboxsf:x:999 and add at the end :yourusername -- use this solution if you don't have sudo.

To take effect you should log out and then log in, or you may need to reboot.

Alexander Malakhov
  • 3,383
  • 2
  • 33
  • 58
Constantin
  • 16,812
  • 9
  • 34
  • 52
  • 141
    FWIW, logging out and in is enough for the change to take effect. – 3c71 Feb 21 '16 at 13:45
  • doesn't work for me with most recent versions on windows 7 host and ubuntu 16.04 host. – HelpNeeder Oct 22 '16 at 04:49
  • @HelpNeeder did you update your guest additions? (Also which is the host/guest?) – Constantin Oct 24 '16 at 20:10
  • It's current, I assume. Just downloaded from the website, and guest additions come with VB. Windows 7 is host and Ubuntu 16.04 guest. I've avoided the issue by creating network share, instead. But I would love the answer for this. – HelpNeeder Oct 24 '16 at 22:12
  • 1
    Just tried this on 16.04.1 on a W10 host and it works. Although I did `sudo chown yourusername /media/sf_*` prior to this in an attempt to fix this, which might or might not have something to do with it. – Sebastian Graf Nov 27 '16 at 09:17
  • 11
    FWIW, since you are already in the comment line, no need to logout and re-login. Simply unmount the share and mount it again. Host VirtualBox > Devices > Shared Folder > mouse over the folder you shared to see tooltip info. E.g.: `sudo mount -t vboxsf VboxSharedFolderName /media/VboxSharedFolderName` (this feature requires Guest Additions). – firepol Feb 27 '17 at 14:32
  • 15
    I use Ubuntu 17.04 as guest and Windows 10 as Host OS (both 64 Bit) and for some reason it didn't work until I rebooted the guest. I used Solution 2. – Alex May 16 '17 at 13:44
  • Also dont forget to sudo adduser plex vboxsf – Sunday Ikpe Oct 06 '17 at 01:16
  • 27
    Same result as @Alex here, using Win7 as host and Ubuntu 17.04 as guest, adding user to vboxsf and login/logout was not sufficient, full reboot of virtual machine was necessary for permissions to take effect. – Hugh Nolan Oct 16 '17 at 10:49
  • 1
    Doesn't work for me: It's telling me "The group 'vboxsf' does not exist" – Alex Nov 11 '17 at 00:17
  • @Alex, there are some packages needed on the VM. See: https://askubuntu.com/questions/792832/how-to-install-virtualbox-guest-additions-for-ubuntu-16-04 – Stephen McAteer Nov 30 '17 at 01:10
  • 1
    Or quicker: `sudo adduser $USER vboxsf` – Qohelet Jan 14 '18 at 11:20
  • 1
    For www-data user, I needed to reboot to have the permissions refreshed with all the daemon/services. – Toto Aug 18 '18 at 14:56
  • For some reason I had to restart the VM to get this to work, but it did work. – Tensigh Sep 07 '18 at 06:41
  • 2
    Why doesn't chmod / chown work with shared virtualbox folders? – jrh Jun 06 '19 at 13:24
  • 2
    for me it does not work! group has user added to the vboxfs. I restarted the host, and restarted the virtualbox. ls -l shows in the vb me as owner of the shared folder, but when I go into it and try to add a file to the host, I see the owner is root. even with permission 777 I cannot write there. What do I miss? – Ronald Wiplinger Nov 30 '19 at 00:38
  • Solution 1 works for me but after restarting vm run sudo adduser $USER vboxsf and then restart the vm and it works !!! – S.Bao Sep 01 '20 at 13:45
  • on Fedora 36, I had to do `sudo usermod -aG ` instead, and logoff didn't work, only reboot – xdavidliu May 21 '21 at 00:56
  • 1
    In linux, after adding user to group, just do: `sudo mount -o remount /media/` instead of logging out. – javs Feb 07 '22 at 01:01
  • 1
    This worked for me. Thank you very much. I have one more question, I am not able to use the Shared Clipboard even if I set to "Bidirectioncal" ! Can you please help me on this? @Alexander – Shinoy Babu Jun 28 '22 at 14:27
  • 1
    none of these options are working for me. I even did what @SebastianGraf proposed of using the chown command, but now I can enter the sf_... folder but can't see anything inside. No matter what I do, shared folder is not working! please help!!! – WKGuy Sep 02 '22 at 00:48
244

Try this (on the guest machine. i.e. the OS running in the Virtual box):

sudo adduser your-user vboxsf

Now reboot the OS running in the virtual box.

Nav
  • 19,885
  • 27
  • 92
  • 135
aflorezd
  • 2,630
  • 1
  • 11
  • 9
  • 11
    Thanks a lot!! Worked just fine. Only thing to add is that I had to restart the OS (didn't try just loggin off but it could be enough) – Osmar Mar 24 '16 at 22:49
  • 3
    There's even no need to log out/in, su - $USER is enough. (for the programs started from the new shell, of course.) – tzp Jun 30 '16 at 07:56
  • 2
    For what I wanted to do, a restart was needed. It's just easier to reboot if you want it to be automagical and not based on you mounting manually. – J. Martin May 09 '18 at 18:38
  • 1
    on Fedora 36, I had to do `sudo usermod -aG ` instead, and logoff didn't work, only reboot – xdavidliu May 21 '21 at 00:56
  • 1
    I also had to reboot on Ubuntu 18. Logging out and logging back in didn't do it. Un-mounting and re-mounting didn't do it. Only reboot seemed to make it work. – tom Dec 13 '21 at 14:42
  • On CentOS, I had to just logout and back in, and use the sudo usermod version from xdavidliu – tobi delbruck Nov 16 '22 at 13:34
66

This also works

sudo usermod -aG <group> <user>

Then restart vm

phuclv
  • 37,963
  • 15
  • 156
  • 475
GEverding
  • 3,131
  • 2
  • 21
  • 23
64

For the truly lazy (no typing, only totally easy copy and paste):

sudo usermod -aG vboxsf $USER

Log out and back in to make the change active.

I know it's a "me too" solution, but I am truly lazy and didn't find any other solution to appeal my innate apathy... :)

ISparkes
  • 1,695
  • 15
  • 15
14

For VirtualBox(5.0.24) Host=Mac(El Capitan) and Guest=RHEL(7.2)

Start up your RHEL Guest VM and open up a Terminal. Make sure you have the Developer Tools installed.

sudo yum groupinstall 'Developer Tools'

And the Kernel headers package so that the Guest Additions script can update your kernel.

sudo yum install kernel-devel*

Once you have the prereqs in place its time to install the Guest Additions. With your running VM selected go to the VirtualBox menu and select Devices --> Insert Guest Additions CD image...

enter image description here

Allow a few seconds for the mount to occur and the install script to kick off. Once they have click the "Run" button in the dialog that popped up in your Guest VM.

After the script finishes right click the CD Icon on the Desktop and choose Eject. Then Shutdown the Guest VM.

Create the Shared folder in you Host system using Terminal, I usually put it in my Documents folder, and make sure that your user can access it.

sudo mkdir ~/Documents/RhelShared
sudo chmod 755 <user> ~/Documents/RhelShared

In the Oracle VM Virtual Box Manager select your VM and then click on the "Shared folders" configuration element. In the next dialog click on the Add Folder icon to the right of the Folders List.

Then in the popup window select the Host Folder you just created as the Folder Path and give it a Folder Name that will be used by the Guest VM, also tick the "Auto Mount" check-box.

enter image description here

After rebooting the Guest VM launch a terminal on the Host and check the user that is associated with the running VirtualBox Guest process is either your user, very likely, or in a group with access to the Shared folder.

ps aux | grep VirtualBoxVM

Then as per several of the previous answers in a Terminal on the Guest VM add your user to the vboxsf group.

sudo usermod -a -G vboxsf <user>

Log out and in again to pickup the change.

The shared folder should now be available and accessible as sf_rhelshared assuming you used the same names as I did in the popup window above.

TJA
  • 2,969
  • 2
  • 25
  • 32
6

To clarify the last post:

The VBoxManage command is:

VBoxManage setextradata <VM_NAME> VBoxInternal2/SharedFoldersEnableSymlinksCreate/<SHARE_NAME> 1
Ian Owens
  • 61
  • 1
  • 2
  • Wish I saw this earlier! Found it in another post. This command allows the creation of symbolic links in the guest system. Thank you. – Ignat Oct 20 '21 at 09:58
5

In my case the following was necessary:

sudo chgrp vboxsf /media/sf_sharedFolder
James Hirschorn
  • 7,032
  • 5
  • 45
  • 53
2

The issue is that the shared folder's permissions are set to not allow symbolic links by default. You can enable them in a few easy steps.

  1. Shut down the virtual machine.
  2. Note your machine name at Machine > Settings > General > Name
  3. Note your shared folder name at 'Machine > Settings > Shared Folders`
  4. Find your VirtualBox root directory and execute the following command. VBoxManage setextradata "[vm name]" VBoxInternal2/SharedFoldersEnableSymlinksCreate/[shared folder] 1
  5. Start up the virtual machine and the shared folder will now allow symbolic links.
Community
  • 1
  • 1
Andy Jenkins
  • 171
  • 1
  • 1
  • 9
2
sudo adduser xxxxxxx vboxsf

where xxxxxx is your user account name. Log out and log back in to Ubuntu.

Devesh Sharma
  • 949
  • 11
  • 14
  • 1
    Or simply "sudo adduser $USER vboxsf" and let the username be read from the system automatically – KaO Dec 05 '19 at 00:48
-1

After adding the user to the vboxsf group, you might need to completely log out of the gnome/xfce/??? session, because someone long ago decided that group affiliation should be cached at first login to the window system.

Or go old school:

% newgrp vboxsf

in any shell you want to use to access the folder. Luckily, newgrp looks up the group list for itself and doesn't used the cached values. You'll still need to log out and back in to access the folder from something other than a shell.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
-9

In my personal experience, it's difficult to enable shared folders in VirtualBox but it Is posible. I have a debian Buster guest virtual machine installed in my Windows 10 host.

I don't recognize exactly what did it, but I remember I went to Windows defender, my antivirus to see if they recognize VirtualBox as a program and not as a virus. After that, I press right click on the document file and allowed to share the folder and I gave click to some buttons there and accepted to share with groups and with muy user in Windows 10.

Also, I found a webpage of Windows about something like virtual machines that I don't remember well, but it took me to a panel and I had to change three things double clicking so when I update Windows, it recognizes my virtual machine. Also, in muy debian, in the terminal, using some command lines, muy VirtualBox recognized my user giving permissions, I based on some info in the Ubuntu forums. I put all what I remember.

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
Worker
  • 1