Virtualbox共享文件夹权限

本文翻译自:Virtualbox shared folder permissions

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. 我将Windows和Virtualbox与RedHat结合使用,简单起见:我创建了一个共享文件夹,以便可以在Windows OS上使用Eclipse并在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. 但是,我无法与用户访问共享文件夹,我已经以root用户身份登录并使用chmod 777 ,甚至将我的用户移至了该文件夹的组。

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? 如何与用户访问共享文件夹?


#1楼

参考:https://stackoom.com/question/1oCK9/Virtualbox共享文件夹权限


#2楼

Add yourself to the vboxsf group within the guest VM. 将您自己添加到来宾VM中的vboxsf组。

Solution 1 解决方案1

Run sudo adduser $USER vboxsf from terminal. 从终端运行sudo adduser $USER vboxsf
(On Suse it's sudo usermod --append --groups vboxsf $USER ) (在Suse上是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 解决方案2

Edit the file /etc/group (you will need root privileges). 编辑文件/etc/group (您将需要root特权)。 Look for the line vboxsf:x:999 and add at the end :yourusername -- use this solution if you don't have sudo. 查找行vboxsf:x:999并在末尾添加:yourusername如果您没有sudo,请使用此解决方案。

To take effect you should log out and then log in, or you may need to reboot. 要生效,您应该先注销然后再登录,否则您可能需要重新启动。


#3楼

Try this (on the guest machine . ie the OS running in the Virtual box): 尝试以下操作(在客户机上,即在“虚拟”框中运行的操作系统):

sudo adduser your-user vboxsf

Now reboot the OS running in the virtual box. 现在,重新启动在虚拟框中运行的操作系统。


#4楼

This also works 这也有效

sudo usermod -aG  

Then restart vm 然后重启vm


#5楼

For VirtualBox(5.0.24) Host=Mac(El Capitan) and Guest=RHEL(7.2) 对于VirtualBox(5.0.24)主机= Mac(El Capitan)和Guest = RHEL(7.2)

Start up your RHEL Guest VM and open up a Terminal. 启动RHEL Guest VM,然后打开一个终端。 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. 以及内核头文件包,以便Guest Additions脚本可以更新您的内核。

sudo yum install kernel-devel*

Once you have the prereqs in place its time to install the Guest Additions. 有了前提条件后,就可以安装Guest Additions了。 With your running VM selected go to the VirtualBox menu and select Devices --> Insert Guest Additions CD image... 选择运行的虚拟机后,转到VirtualBox菜单,然后选择设备->插入来宾添加CD映像...

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. 脚本完成后,右键单击桌面上的CD图标,然后选择弹出。 Then Shutdown the Guest VM. 然后关闭来宾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. 使用终端在主机系统中创建Shared文件夹,我通常将其放在我的Documents文件夹中,并确保您的用户可以访问它。

sudo mkdir ~/Documents/RhelShared
sudo chmod 755  ~/Documents/RhelShared

In the Oracle VM Virtual Box Manager select your VM and then click on the "Shared folders" configuration element. 在Oracle VM Virtual Box Manager中,选择您的VM,然后单击“共享文件夹”配置元素。 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. 然后,在弹出窗口中,选择刚创建的主机文件夹作为文件夹路径,并为其指定一个将由来宾VM使用的文件夹名称,同时选中“自动挂载”复选框。

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. 重新启动Guest VM后,在主机上启动终端,并检查与正在运行的VirtualBox Guest进程关联的用户是您的用户(很可能是该用户),还是属于有权访问Shared文件夹的组中的用户。

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. 然后,根据来宾VM上终端中以前的几个答案,将您的用户添加到vboxsf组。

sudo usermod -a -G vboxsf 

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. 现在,假设您使用的名称与我在上面的弹出窗口中使用的名称相同,共享文件夹现在应该可以使用sf_rhelshared进行访问。


#6楼

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... :) 我知道这是一个“我也是”的解决方案,但是我确实很懒惰,没有找到其他方法来吸引我的天生冷漠... :)

你可能感兴趣的:(Virtualbox共享文件夹权限)