宿主机(Win)和虚拟机(Linux)之间共享文件

在电脑上安装了一个虚拟机virtualBox,打算在虚拟机中安装JDK。ubuntu的版本是:ubuntu-16.10-server-amd64.iso。
搜索网上的各种方法后,打算通过宿主机(Win)和虚拟机(Linux)之间共享文件来安装虚拟机中的JDK。
Let's do it.


一、设置共享文件夹
首先将D:\baidu\shareFolder目录设置为共享文件夹,方法不再赘述。
然后设置虚拟机上的共享文件夹:



二、挂载共享文件
执行:sudo mount -t vboxsf shareFolder /home/fuhy/winshare
但是执行失败,显示:-unknown filesystem type vboxsf
搜索之后,参考https://segmentfault.com/a/1190000004362463
发现需要宿主机(win)和虚拟机(Linux)需要安装Guest Additions这个东西,于是点击“设备-安装增强功能…”:

但是安装时报错:

需要挂载VboxGuestAdditions.iso,于是执行:sudo mount /dev/cdrom /home/fuhy/winshare

查看一下,可见挂载上了:


执行一下:sudo sh ./VboxLinuxAdditions.run

最后一句:Failed to set up service vboxadd, please check the log file,说明执行失败。
查看日志:

有这么一句:Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed..
可见可能是gcc、make等软件没有安装,尝试一下:


于是安装gcc,执行sudo apt-get  install  build-essential

等待一会,安装完毕后,执行:gcc --version

可见安装成功了,重新执行:sudo sh ./VboxLinuxAdditions.run

最后一句:Could not find the X.Org or Xfree86 Windows System, skipping. 没关系,这个不影响。
继续执行:sudo mount -t vboxsf shareFolder /home/fuhy/winshare

可见挂载成功。



猜你喜欢

转载自margaret0071.iteye.com/blog/2366904