VirtualBox中Linux设置共享文件夹

设置共享文件路径

点击虚拟机 设置-->选择 共享文件夹

(图1 设置共享文件夹)

设置共享文件夹路径

  • 1 选择路径
  • 2 填写自定义的共享名称(在后面需要与挂载路径相对应)
  • 3 设置自动挂载/固定分配

(图2 设置共享文件路径属性)

安装VirtualBox增强工具

先安装必备的包

执行下面的命令:

yum install -y gcc gcc-devel gcc-c++ gcc-c++-devel make kernel kernel-devel

安装完后,重启虚拟机:

shutdown -r now

安装virtualBox增强工具

点击 设置-->点击 安装增强功能...

(图3 点击设置)

自动执行安装 或者 进入目录/media/VBOXADDITIONS_5.1.2_108956,执行命令

./VBoxLinuxAddtion.run

得到输出内容

  1.  
    [root@localhost VBOXADDITIONS_5.1.2_108956]# ./VBoxLinuxAdditions.run
  2.  
    Verifying archive integrity... All good.
  3.  
    Uncompressing VirtualBox 5.1.2 Guest Additions for Linux...........
  4.  
    VirtualBox Guest Additions installer
  5.  
    Removing installed version 5.1.2 of VirtualBox Guest Additions...
  6.  
    vboxadd.sh: Stopping VirtualBox Additions.
  7.  
    vboxadd-service.sh: Stopping VirtualBox Guest Addition service.
  8.  
    Copying additional installer modules ...
  9.  
    Installing additional modules ...
  10.  
    vboxadd.sh: Building Guest Additions kernel modules.
  11.  
    vboxadd.sh: You should restart your guest to make sure the new modules are actually used.
  12.  
    vboxadd.sh: Starting the VirtualBox Guest Additions.
  13.  
     
  14.  
    You may need to restart the the Window System (or just restart the guest system)
  15.  
    to enable the Guest Additions.

即安装成功!

挂载共享文件夹

进入Linux,打开终端,创建挂载点目录,这里为/home/deepin/Downloands

sudo mkdir /mnt/shared如果是 /home/deepin/Downloands 不用创建

切换到root用户输入挂载命令:

sudo mount -t vboxsf shared_file /home/deepin/Downloands  这里要注意大小写

注意格式为

sudo mount -t vboxsf 共享文件夹名称(在设置页面设置的) 挂载的目录

然后进入/mnt/shared,就可以看到windows中的文件了

设置自动挂载,可以在/etc/fstab中添加一项 
sudo vim /etc/fstab 
share /mnt/shared vboxsf rw,gid=110,uid=1100,auto 0 0 
卸载挂载点命令 
sudo umount -f  /home/deepin/Downloands
 

其他使用技巧

如果宿主机是windows经常需要来回的拷贝内容,那么可以打开【共享粘贴板】,步骤为:

设备-->共享粘贴板-->双向
原文地址:https://www.cnblogs.com/Thenext/p/14000076.html