Linux 如何访问 virtualbox 中的共享文件夹。主机 Win7,来宾 Fedora 16?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10057522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:39:47  来源:igfitidea点击:

How to access share folder in virtualbox. Host Win7, Guest Fedora 16?

linuxwindows-xpfedoravirtualboxvbox

提问by PhiVH

I'm a newbie in linux. I installed Fedora 16 OS as guest in virtualbox on Window 7. Now, I want to access share folder from Fedora. Here is something I did:

我是Linux的新手。我在 Window 7 上的 virtualbox 中安装了 Fedora 16 OS 作为来宾。现在,我想从 Fedora 访问共享文件夹。这是我做的事情:

  • Install guest addtion [OK]
  • Make share folder link to virtualbox [OK]. Share folder path in Window 7: D:\share_folder_vm
  • In terminal program in fedora, I just run some commands:

    [hoangphi@localhost ~]$ su
    Password: 
    [root@localhost hoangphi]# cd Desktop/
    [root@localhost Desktop]# mkdir share_folder
    [root@localhost Desktop]# sudo mount -t vboxsf D:\share_folder_vm \share_folder
    /sbin/mount.vboxsf: mounting failed with the error: Protocol error
    [root@localhost Desktop]# 
    
  • 安装来宾添加 [OK]
  • 将共享文件夹链接到 virtualbox [确定]。在 Window 7 中共享文件夹路径:D:\share_folder_vm
  • 在 Fedora 的终端程序中,我只运行了一些命令:

    [hoangphi@localhost ~]$ su
    Password: 
    [root@localhost hoangphi]# cd Desktop/
    [root@localhost Desktop]# mkdir share_folder
    [root@localhost Desktop]# sudo mount -t vboxsf D:\share_folder_vm \share_folder
    /sbin/mount.vboxsf: mounting failed with the error: Protocol error
    [root@localhost Desktop]# 
    

I got this message: /sbin/mount.vboxsf: mounting failed with the error: Protocol error

我收到了这条消息: /sbin/mount.vboxsf: mounting failed with the error: Protocol error

share_folder_vmis the folder in Win7 Host and share_folderis the folder in Fedora Guest.

share_folder_vm是Win7 Hostshare_folder中的文件夹,也是Fedora Guest中的文件夹。

My question: How can I fix this problem?

我的问题:我该如何解决这个问题?

采纳答案by thejartender

Install Oracle Guest Additions:

安装 Oracle Guest Additions:

[host-hotkey (usually right Ctrl)] + [d],

[host-hotkey (usually right Ctrl)] + [d],

Then:

然后:

sudo /media/VBOXADDITIONS_4.*/VBoxLinuxAdditions.run

You can now enjoy:

您现在可以享受:

  • A guest that can run at native screen resolution
  • Ability to share files between host and guest
  • Share the clipboard (allowing you to copy and paste between host and guest).
  • 可以以本机屏幕分辨率运行的来宾
  • 能够在主机和来宾之间共享文件
  • 共享剪贴板(允许您在主机和来宾之间复制和粘贴)。

To share folders set them up to be shared. Consider the permissions. Note that the host file permissions are transient. IOW if you can't write to file on host, the guest can't either.

要共享文件夹,请将它们设置为共享。考虑权限。请注意,主机文件权限是暂时的。IOW 如果您不能在主机上写入文件,那么来宾也不能。

After setting up the file to be shared create a destination if you don't have one: mkdir -p ~/destination

设置要共享的文件后,如果没有目标,请创建一个目标: mkdir -p ~/destination

Now mount it under the name you configured it with:

现在以您配置的名称安装它:

sudo mount -t vboxsf myFileName ~/destination

As an extra tip you can really exploit this feature to do things like: - Use guest subversion client to create repository to mounted directory (you won't have a full svn client but the repo can be used in an IDE on the host). - I personally use my guest to download and unpack binaries like Tomcat to a targeted mount. Yes you can use Linux to install things on Windows!

作为额外的提示,您可以真正利用此功能来执行以下操作: - 使用来宾 Subversion 客户端创建存储库到挂载目录(您不会拥有完整的 svn 客户端,但可以在主机上的 IDE 中使用该存储库)。- 我个人使用我的来宾下载和解压 Tomcat 等二进制文件到目标安装。是的,您可以使用 Linux 在 Windows 上安装东西!

To unmount all shares:

要卸载所有共享:

sudo umount -f -a -t vboxsf

回答by snow04

For accessing a shared folder, YOU have to have "Oracle VM extension pack" installed.

要访问共享文件夹,您必须安装“Oracle VM 扩展包”。

Look at the bottom of this link, you can download it from there.

看看这个链接的底部,你可以从那里下载。

http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

回答by Jesfre

May be this can help other guys: I had the same problem, and after looking with Google I found that can be because of the permissions of the folder... So, you need first to add permissions...

可能这可以帮助其他人:我遇到了同样的问题,在用谷歌查找后我发现可能是因为文件夹的权限......所以,你需要先添加权限......

$ chmod 777 share_folder

Then run again

然后再次运行

$ sudo mount -t vboxsf D:\share_folder_vm \share_folder

Check the answers here: Error mounting VirtualBox shared folders in an Ubuntu guest...

在此处查看答案:在 Ubuntu 来宾中安装 VirtualBox 共享文件夹时出错...

回答by Chen Sturmweizen

I just figured. You need to add a shared folder using VirtualBox before you access it with the guest.

我只是想。您需要先使用 VirtualBox 添加共享文件夹,然后才能使用来宾访问它。

Click "Device" in the menu bar--->Shared File--->add a directory and name it

点击菜单栏中的“设备”--->共享文件--->添加目录并命名

then in the guest terminal, use:

然后在访客终端中,使用:

sudo mount -t vboxsf myFileName ~/destination

Dont directly refer to the host directory

不要直接引用主机目录

回答by Michael

There's a simpler way I found when running Linux Mint.

我在运行 Linux Mint 时发现了一种更简单的方法。

  1. Ensure you install the Guest Additions from the command line and that you have the folder(s) shared with "automount" and "make permanent" settings selected within "Shared Folders" tab of the Machine Settings
  2. Launch the User management application from Application/Settings/System Setting/ menu selection (requires sudo) from within the Mint menu
  3. In the "Privileges and Groups" tab, check the box next to the "vboxsf" group, and then apply and ok your way back out.
  1. 确保从命令行安装 Guest Additions,并且在机器设置的“共享文件夹”选项卡中选择了与“自动挂载”和“永久”设置共享的文件夹
  2. 从 Mint 菜单中的应用程序/设置/系统设置/菜单选择(需要 sudo)启动用户管理应用程序
  3. 在“权限和组”选项卡中,选中“vboxsf”组旁边的框,然后应用并确定退出。

Any user within the vboxsf group has full access to any shared folders on each boot with no manual mounting or unmounting

vboxsf 组中的任何用户在每次启动时都可以完全访问任何共享文件夹,无需手动安装或卸载

I usually do the following in addition to the above just to have quick access

除了上述之外,我通常会执行以下操作只是为了快速访问

  1. Open the Dolphin file manager and navigate to /media/
  2. Right-Click on the shared folder and click "Add to Places"
  1. 打开 Dolphin 文件管理器并导航到 /media/
  2. 右键单击共享文件夹,然后单击“添加到位置”

回答by tf41xc86x7

There is a really simple tuturial here : http://my-wd-local.wikidot.com/otherapp:configure-virtualbox-shared-folders-in-a-windows-ho

这里有一个非常简单的教程:http://my-wd-local.wikidot.com/otherapp:configure-virtualbox-shared-folders-in-a-windows-ho

telling to do:

告诉做:

sudo mkdir /mnt/vbox_share
sudo mount.vboxsf nameAddesAsShared /mnt/vbox_share

sudo mkdir /mnt/vbox_share
sudo mount.vboxsf nameAddesAsShared /mnt/vbox_share

回答by Andrew Wolfe

This thread has some great tips. However....

这个线程有一些很好的提示。然而....

@GirishB's answer isn't correct - sorry. Jartender's is best.

@GirishB 的答案不正确 - 抱歉。Jartender的最好。

Also, every post in here seems to assume you're logging in to the Linux guest as root, except for @tomoguisuru. Yuck! Don't use root, use a separate user account and "sudo" when you need root privileges. Then this user (or any other user who needs the shared folder) should have membership in the vboxsf group, and @tomoguisuru's command is perfect, even terser than what I use.

此外,这里的每篇文章似乎都假设您以 root 身份登录 Linux 来宾,@tomoguisuru 除外。糟糕!不要使用 root,在需要 root 权限时使用单独的用户帐户和“sudo”。那么这个用户(或任何其他需要共享文件夹的用户)应该是 vboxsf 组的成员,@tomoguisuru 的命令是完美的,甚至比我使用的还要简洁。

Forget running mount yourself. Set up the shared folder to auto mount and you'll find the shared folder - it's under /media in my OEL (RH and Centos probably the same). If it's not there, just run "mount" with no arguments and look for the mounted directory of type vboxsf.

忘记自己运行 mount 吧。将共享文件夹设置为自动挂载,您将找到共享文件夹 - 它位于我的 OEL 中的 /media 下(RH 和 Centos 可能相同)。如果它不存在,只需不带参数运行“mount”并查找类型为 vboxsf 的挂载目录。

Terminal showing 'mount' and where to find mounted shared folder

终端显示“挂载”以及在哪里可以找到挂载的共享文件夹

回答by Satish

These are the steps to share a folder from Windows to Linux Virtual Box

这些是将文件夹从 Windows 共享到 Linux Virtual Box 的步骤

Step 1: Install Virtual Box Extension Pack from this link

步骤 1:从此链接安装 Virtual Box 扩展包

Step 2: Install Oracle Guest Additions:

第 2 步:安装 Oracle Guest Additions:

By pressing -> Right Ctrland dtogether

通过按 ->Right Ctrld一起

Run the command sudo /media/VBOXADDITIONS_4.*/VBoxLinuxAdditions.run

运行命令 sudo /media/VBOXADDITIONS_4.*/VBoxLinuxAdditions.run

Step 3: Create Shared Folder by Clicking Settings in VboxThen Shared Folders -> + and give a name to the folder (e.g. VB_Share) Select the Shared Folder path on Windows (e.g. D:\VBox_Share)

第 3 步:通过单击Vbox然后共享文件夹中的设置创建共享文件夹 -> + 并为文件夹命名(例如 VB_Share) 在 Windows 上选择共享文件夹路径(例如 D:\VBox_Share)

Step 4: Create a folder in named VB_sharein home\user-name(e.g. home\satish\VB_share) and share mkdir VB_Sharechmod 777 VB_share

第四步:在named VB_sharein home\user-name(例如home\satish\VB_share)中创建一个文件夹并共享 mkdir VB_Sharechmod 777 VB_share

Step 5: Run the following command sudo mount –t vboxsf vBox_Share VB_Share

第 5 步:运行以下命令 sudo mount –t vboxsf vBox_Share VB_Share

回答by Wil S

You probably need to change your mount command from:

您可能需要从以下位置更改安装命令:

[root@localhost Desktop]# sudo mount -t vboxsf D:\share_folder_vm \share_folder

to:

到:

[root@localhost Desktop]# sudo mount -t vboxsf share_name \share_folder

where share_name is the "Name" of the share in the VirtualBox -> Shared Folders -> Folder List list box. The argument you have ("D:\share_folder_vm") is the "Path" of the share on the host, not the "Name".

其中 share_name 是 VirtualBox -> Shared Folders -> Folder List 列表框中共享的“名称”。您拥有的参数(“D:\share_folder_vm”)是主机上共享的“路径”,而不是“名称”。

回答by Tin Luu

VirtualBox version has many uncompatibilities with Linux version, so it's hard to install by using "Guest Addition CD image". For linux distributions it's frequently have a good companion Guest Addition package(equivalent functions to the CD image) which can be installed by:

VirtualBox 版本与 Linux 版本有很多不兼容,因此使用“Guest Addition CD 映像”很难安装。对于 linux 发行版,它通常有一个很好的配套 Guest Addition 包(相当于 CD 映像的功能),可以通过以下方式安装:

sudo apt-get install virtualbox-guest-dkms

After that, on the window menu of the Guest, go to Devices->Shared Folders Settings->Shared Folders and add a host window folder to Machine Folders(Mark Auto-mount option) then you can see the shared folder in the Files of Guest Linux.

之后,在Guest的窗口菜单上,进入Devices->Shared Folders Settings->Shared Folders,在Machine Folders中添加一个host窗口文件夹(标记自动挂载选项),然后您可以在Files的Files中看到共享文件夹来宾Linux。