Sometimes we wish to communicate between virtual machines and hosts, such as transfer some files. Then set up shared folders is a good way. Here is my host win10 system, vbox inside the virtual machine is Ubuntu.
1, first install the vbox VBOXGuestAddition.iso.
(1) if it is android developer, installed genymotion , then skip to step 5;
(2) Click the "Device" in the vbox -> "Installation Enhancements."
(3) Ubuntu installation interface will pop up, end of the installation need to restart Ubuntu.
(4) to install this thing can solve the problem of full-screen virtual machine, previously installed here skipped.
(5) VirtualBox interface -> Devices -> CD-ROM distribution -> Select the virtual disk -> select C: \ Program Files \ Oracle \ VBoxGuestAdditions.iso under VirtualBox directory, click "Open." (Note: The path here is the path of genymotion installed, when I put myself genymotion installed in the E drive, look at the results to the C drive, pit for a long time ...)
2, each of the parties to establish a shared folder:
(1) Create a folder on win10, such as the establishment of a vbox-share on the desktop.
(2) re-create a folder in Ubuntu inside a virtual machine, for example, / mnt / shared.
(3) In vbox the pointing device -> Shared Folder, pop shared folder setting window, as shown in FIG.
(4) Click on the top right of the Folder + button in the pop-up window, fill out some information note: the shared folder name to keep in mind, the following will be used. As shown in FIG.
(5) ---- very important to be careful not to select the "Automatically mount" here, because here is set to automatically mount will not be successful, if you want to automatically mount, then we can use the command line to configure. Fill out the information, click OK.
3、然后再Ubuntu中,打开命令行窗口(快捷键Ctrl+Alt+t),输入命令行“sudo mount -t vboxsf vbox-share /mnt/shared”,执行完后就可以使用共享文件夹了。在win10桌面的vbox-share文件夹中拷贝一些文件进去,在Ubuntu的/mnt/shared文件夹中就可以看见了,反之亦然。
4. 这里很蛋疼,建议不要使用:设置自动挂载了,这样就不用每次重启虚拟机都要输入一遍命令行了。配置的方法是:在文件/etc/fstab的末尾添加vbox-share /mnt/shared vboxsf defaults 0 0 或者vbox-share /mnt/shared vboxsf rw,gid=100,uid=1000,auto 0 0注意我们之前在共享文件夹的配置界面,是没有勾选中“自动挂载”的,如果那里选中了“自动挂载”,这里即使配置好/etc/fstab也是没有用的。
但是这里有个很严重的问题:重启Ubuntu之后出现了Ubuntu 15.04 开机无法进入图形界面,自动进入emergency mode的问题。具体原因和解决见:http://blog.csdn.net/ariera/article/details/48784249, 在另一篇blog:http://blog.csdn.net/nicholas_wong/article/details/70157565中提到的方法经过亲自发现并无卵用。
5. 所以,关于自动挂载这个问题,到现在还没有找到比较好的方法,暂且记录,希望大神有好的方法可以指点。
6. 最后如果想卸载共享文件夹的话,输入命令“sudo umount -f /mnt/shared”,执行即可。
7. 过程中遇到的另外一个坑:virtualbox安装增强功能时【未能加载虚拟光盘】
想在主机和VirtualBox的Ubuntu建个共享文件夹,之前一直没搞定,今晚却特别的顺利。以下是设置的步骤:
1.安装VirtualBox的VBoxGuestAddition.iso .在“设备”->“安装增强功能”。安装结束记得重启。以前在解决Ubuntu全屏显示时已经安装了,这里就跳过。
2. VirtualBox的“设备”->“分配数据空间”,添加固定分配,如E:\linux-share, 名称linux-share.
3. 到Terminal命令行下:
$cd /mnt
$sudo mkdir win-share
$sudo mount -t vboxsf linux-share /mnt/win-share
搞定。
之前碰到/sbin/mount.vboxsf:mounting failed with the error: No such file or directory问题,以为很难解决,发现只是因为没有先建好win-share这个目录,详见参考3.
参考:
1.http://www.linuxidc.com/Linux/2009-01/18147.htm
2.http://www.ludou.org/virtualbox-sharedfolder.html
3.http://hi.baidu.com/wangr/blog/item/5db60a306348a99aa9018e9a.html
下次重启virtualbox,该共享连接会丢失,需重新挂载。重启前确认‘设备’->分配空间中的linux-share的Auto-mount选项取消。