linux和主机共享文件,在VirtualBox中与主机共享文件夹

安装VirtualBox为了共享文件夹,折腾了一晚上!网上的很多资料都不是很全面,这里就全面的总结一下,如果有其他的疑问,可以留言多多交流。

设置共享文件路径

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

f03ffdcee4e822ba727f2d90dfe4dfdc.png

(图1 设置共享文件夹)

设置共享文件夹路径

1 选择路径

2 填写自定义的共享名称(在后面需要与挂载路径相对应)

3 设置自动挂载/固定分配

eff09b12e1b0fd085164ffd13a3febab.png

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

安装VirtualBox增强工具

先安装必备的包

执行下面的命令:

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

安装完后,重启虚拟机:

shutdown -r now

安装virtualBox增强工具

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

67995ba4cdd46534ab33e2cd9d007333.png

(图3 点击设置)

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

./VBoxLinuxAddtion.run

得到输出内容

[root@localhost VBOXADDITIONS_5.1.2_108956]# ./VBoxLinuxAdditions.run

Verifying archive integrity... All good.

Uncompressing VirtualBox 5.1.2 Guest Additions for Linux...........

VirtualBox Guest Additions installer

Removing installed version 5.1.2 of VirtualBox Guest Additions...

vboxadd.sh: Stopping VirtualBox Additions.

vboxadd-service.sh: Stopping VirtualBox Guest Addition service.

Copying additional installer modules ...

Installing additional modules ...

vboxadd.sh: Building Guest Additions kernel modules.

vboxadd.sh: You should restart your guest to make sure the new modules are actually used.

vboxadd.sh: Starting the VirtualBox Guest Additions.

You may need to restart the the Window System (or just restart the guest system)

to enable the Guest Additions.

即安装成功!

挂载共享文件夹

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

sudo mount -t vboxsf shared_file /home/xingoo/shared

注意格式为

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

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

73aca8ff7ce8eb23c145ccb64e8e67af.png

(图4 windows文件)

[root@localhost shared]# ll

total 337516

-rwxrwxrwx. 1 root root 149599799 Aug 15 21:29 apache-hive-2.1.0-bin.tar.gz

-rwxrwxrwx. 1 root root 196015975 Aug 15 21:31 .6.4.tar.gz

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值