ChatGPT解决这个技术问题 Extra ChatGPT

Virtualbox shared folder permissions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions about general computing hardware and software on Stack Overflow. You can edit the question so it’s on-topic for Stack Overflow. Closed last year. Improve this question

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?


A
Alexander Malakhov

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.


FWIW, logging out and in is enough for the change to take effect.
Thanks, it was just lacking the restart part, for me.
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).
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.
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.
N
Nav

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.


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)
There's even no need to log out/in, su - $USER is enough. (for the programs started from the new shell, of course.)
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.
on Fedora 36, I had to do sudo usermod -aG <group> <user> instead, and logoff didn't work, only reboot
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.
p
phuclv

This also works

sudo usermod -aG <group> <user>

Then restart vm


Don't need to restart the vm, just log off and back on
On my system, restarting was needed for some reason.
I second @Tensigh. Although my user was displayed in /etc/group, it never showed up by typing groups. I had to reboot the VM.
Thank you, the restart is what got it to work for me.
I
ISparkes

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... :)


Log out doesn't help, I have to restart it.
Restart required using above in VirtualBox 6.1 using Ubutun 18.04.xLTS
T
TJA

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...

https://i.stack.imgur.com/SrXHK.png

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.

https://i.stack.imgur.com/sTGS5.png

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.


I
Ian Owens

To clarify the last post:

The VBoxManage command is:

VBoxManage setextradata <VM_NAME> VBoxInternal2/SharedFoldersEnableSymlinksCreate/<SHARE_NAME> 1

Wish I saw this earlier! Found it in another post. This command allows the creation of symbolic links in the guest system. Thank you.
D
Devesh Sharma
sudo adduser xxxxxxx vboxsf

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


Or simply "sudo adduser $USER vboxsf" and let the username be read from the system automatically
J
James Hirschorn

In my case the following was necessary:

sudo chgrp vboxsf /media/sf_sharedFolder

C
Community

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.

Shut down the virtual machine. Note your machine name at Machine > Settings > General > Name Note your shared folder name at 'Machine > Settings > Shared Folders` Find your VirtualBox root directory and execute the following command. VBoxManage setextradata "[vm name]" VBoxInternal2/SharedFoldersEnableSymlinksCreate/[shared folder] 1 Start up the virtual machine and the shared folder will now allow symbolic links.


Step 3 doesn't seem to be used in your instruction and step 4 produces an error.
S
Stephen Rauch

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.


M
MaartenDev

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.


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now