virtualbox共享文件夹

主机:windows 8

虚拟机:ubuntu server 12.04(没有图形化界面)

1、挂载Virtualbox的增加镜像

virtualbox共享文件夹_第1张图片

2、在ubuntu中挂载此iso

enyo@UBUNTU /media$ sudo mount /dev/cdrom /media/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
enyo@UBUNTU /media$ ls /media/cdrom/
32Bit        autorun.sh  runasroot.sh              VBoxWindowsAdditions-amd64.exe
64Bit        cert        VBoxLinuxAdditions.run    VBoxWindowsAdditions.exe
AUTORUN.INF  OS2         VBoxSolarisAdditions.pkg  VBoxWindowsAdditions-x86.exe

3、安装增强功能

enyo@UBUNTU /media$ sudo cdrom/VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.2 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.

Building the main Guest Additions module ...done.
Building the shared folder support module ...done.
Building the OpenGL support module ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)

enyo@UBUNTU /mnt$ sudo reboot

虽然有报错说没有桌面环境,但是不影响共享文件夹,重启设置共享文件夹即可

4、设置共享文件夹

virtualbox共享文件夹_第2张图片

5、挂载共享文件夹

enyo@UBUNTU /media$ sudo mkdir myshare
enyo@UBUNTU /media$ sudo mount -t vboxsf myshare myshare

6、开机自动挂载文件夹

网上很多教程说把下面的代码加入/etc/fstab,重启即可

myshare /media/myshare vboxsf rw,gid=100,uid=1000,auto 0 0

但是系统调用fstab的时候,Virtualbox的共享目录的模块还没有加载,所以每次加载都会失败,我的解决办法是在在/etc/rc.local文件中加入一行

mount -t vboxsf myshare myshare

重新启动即可实现自动挂载

你可能感兴趣的:(virtualbox共享文件夹)