2019独角兽企业重金招聘Python工程师标准>>>

本文讨论的是共享问题针对 Mac 和 VirtualBox 之间的文件共享;

众所周知,跨系统文件共享问题有几种解决办法:

  • 通过 samba 协议解决
  • 通过 Web 服务解决
  • 通过 ftp 类协议解决

本文针对另外一种方法进行说明,即 Guest Additions ;


以下内容部分参考自:《How to install VirtualBox Guest Additions for Linux》

------

下面内容假设你已经基于 vagrant + VirtualBox + Ubuntu 成功搭建起了虚拟机系统;

a.下载对应 VirtualBox 版本的 guest additions

vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ wget http://download.virtualbox.org/virtualbox/5.0.20/VBoxGuestAdditions_5.0.20.iso

b.安装必要的软件包

vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ sudo apt-get install dkms gcc

c.挂载 guest additions 对应的 ISO 文件

vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ sudo mount -o loop VBoxGuestAdditions_5.0.20.iso /mnt
mount: block device /home/vagrant/workspace/WGET/VBoxGuestAdditions_5.0.20.iso is write-protected, mounting read-only

查看挂载情况

vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ mount
…
/home/vagrant/workspace/WGET/VBoxGuestAdditions_5.0.20.iso on /mnt type iso9660 (ro)
vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ 

d.运行脚本进行安装

vagrant@vagrant-ubuntu-trusty:~/workspace/WGET$ cd /mnt
vagrant@vagrant-ubuntu-trusty:/mnt$ sudo ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest AdditionsInstalling the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping....done.vagrant@vagrant-ubuntu-trusty:/mnt$ 

e.查看安装成功后,内核模块中增加的和 vbox 相关的内容

vagrant@vagrant-ubuntu-trusty:/mnt$ lsmod | grep vbox
vboxvideo              45696  1
ttm                    85115  1 vboxvideo
drm_kms_helper         52758  1 vboxvideo
drm                   302817  3 ttm,drm_kms_helper,vboxvideo
syscopyarea            12529  1 vboxvideo
sysfillrect            12701  1 vboxvideo
sysimgblt              12640  1 vboxvideo
vboxsf                 43802  0
vboxguest             276728  3 vboxsf,vboxvideovagrant@vagrant-ubuntu-trusty:/mnt$ 

------

上面给出的一切顺利的情况下,你能够看到的安装过程~~

然而,实际操作中你可能会遇以下情况:

a.针对 lucid64.box ,即使 guest additions 版本不一致也可以提供文件共享功能

sunfeideMacBook-Pro:lucid64 sunfei$ vagrant reload==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...default: Adapter 1: natdefault: Adapter 2: hostonly
==> default: Forwarding ports...default: 80 (guest) => 8080 (host) (adapter 1)default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...default: SSH address: 127.0.0.1:2200default: SSH username: vagrantdefault: SSH auth method: private keydefault: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...default: The guest additions on this VM do not match the installed version of    -- 这里可以看到存在版本不一致问题default: VirtualBox! In most cases this is fine, but in rare cases it candefault: prevent things such as shared folders from working properly. If you seedefault: shared folder errors, please make sure the guest additions within thedefault: virtual machine match the version of VirtualBox you have installed ondefault: your host and reload your VM.default: default: Guest Additions Version: 4.2.0default: VirtualBox Version: 5.0
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...default: /vagrant => /Users/sunfei/workspace/vagrant/lucid64                -- 但依然能够成功挂载共享目录default: /vagrant_data => /Users/sunfei/workspace/vagrant/lucid64/data      -- 但依然能够成功挂载共享目录
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.sunfeideMacBook-Pro:lucid64 sunfei$ 

b.针对 ubuntu-14.04-amd64.box 的情况,则必须安装正确版本的 guest additions 才能共享文件

sunfeideMacBook-Pro:ubuntu-14.04-amd64 sunfei$ vagrant upBringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu-14.04-amd64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: ubuntu-1404-amd64_default_1465201090522_12444
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...default: Adapter 1: natdefault: Adapter 2: hostonly
==> default: Forwarding ports...default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...default: SSH address: 127.0.0.1:2200default: SSH username: vagrantdefault: SSH auth method: private keydefault: Warning: Remote connection disconnect. Retrying...default: Warning: Remote connection disconnect. Retrying...default: default: Vagrant insecure key detected. Vagrant will automatically replacedefault: this with a newly generated keypair for better security.default: default: Inserting generated public key within guest...default: Removing insecure key from the guest if it's present...default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...default: No guest additions were detected on the base box for this VM! Guest  - 这里看到当前 box 未提供 guest additionsdefault: additions are required for forwarded ports, shared folders, host onlydefault: networking, and more. If SSH fails on this machine, please installdefault: the guest additions and repackage the box to continue.default: default: This is not an error message; everything may continue to work properly,default: in which case you may ignore this message.
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...default: /vagrant => /Users/sunfei/workspace/vagrant/ubuntu-14.04-amd64
Failed to mount folders in Linux guest. This is usually because       - 这里会看到共享文件夹挂载失败
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrantThe error output from the last command was:
stdin: is not a tty
mount: unknown filesystem type 'vboxsf'sunfeideMacBook-Pro:ubuntu-14.04-amd64 sunfei$ 

c.针对 ubuntu-14.04-amd64.box 安装完 guest additions 的情况

sunfeideMacBook-Pro:ubuntu-14.04-amd64 sunfei$ vagrant reload==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...default: Adapter 1: natdefault: Adapter 2: hostonly
==> default: Forwarding ports...default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...default: SSH address: 127.0.0.1:2200default: SSH username: vagrantdefault: SSH auth method: private keydefault: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...                  — 安装后,这里不再出现其他信息
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...default: /vagrant => /Users/sunfei/workspace/vagrant/ubuntu-14.04-amd64   - 根据配置文件成功挂载共享目录default: /vagrant_data => /Users/sunfei/workspace/vagrant/ubuntu-14.04-amd64/datasunfeideMacBook-Pro:ubuntu-14.04-amd64 sunfei$ 

此时,登录到虚拟机系统中可以看到

sunfeideMacBook-Pro:ubuntu-14.04-amd64 sunfei$ vagrant ssh
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)* Documentation:  https://help.ubuntu.com/Last login: Mon Jun  6 09:05:32 2016 from 10.0.2.2
vagrant@vagrant-ubuntu-trusty:~$
vagrant@vagrant-ubuntu-trusty:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
vagrant on /vagrant type vboxsf (uid=1000,gid=1000,rw)      — 共享目录成功挂载
vagrant_data on /vagrant_data type vboxsf (uid=1000,gid=1000,rw)     — 共享目录成功挂载vagrant@vagrant-ubuntu-trusty:~$ 

补充:Guest Additions 除了能够解决文件共享问题外,还能解决一些其它宿主机和虚拟机之间的问题,详细内容可以查阅相关资料~

转载于:https://my.oschina.net/moooofly/blog/706750

【原创】Mac 工作协同之文件共享问题相关推荐

  1. 钉钉(工作协同)应用之前端源码赏析

    这几天在兴趣下翻看了钉钉(工作协同)应用的前端源码,分析其目录结构.构建工具及框架使用等,进行前端技术研究,分享我的总结成果. PS:不知道这应用的没关系,因为总结出来是前端通用的东西. PS:其应用 ...

  2. 工作中办公文件共享用什么软件比较便捷?

    在日常工作中经常需要和同事共享一些办公文件,有些文件需要发送给多个人,如果依靠一些社交工具发送的话非常耗费时间,而使用邮箱发送的话可能会导致部分人员查看不及时.所以说,在日常工作中还是选择一些支持共享 ...

  3. [原创软件测试工作技能

    [原创软件测试工作技能 转载于:https://www.cnblogs.com/mayingbao/archive/2007/12/17/1000764.html

  4. Mac 开启局域网smb文件共享(附全平台连接方法)

    在同一个wifi下 在Mac上开启smb文件共享 可以让自己mac上的文件 可以被手机或者windows系统电脑一起共享. 使用最广的场景就是可以在家里的电视上面通过这个功能来观看自己下载的视频或者图 ...

  5. 云工作协同办公都有哪些优势

    云工作是2014年才刚刚兴起的名词,它是新型的团队协作工作方式,但并不等同于传统OA.它具备高智商,可以进行数据处理.资源共享.商业交流.娱乐功能--它不但能够组建成一个优秀的企业生态圈,也是企业内部 ...

  6. 番茄土豆 for Mac工作原理介绍

    番茄土豆 for Mac是一款可以有效管理用户时间任务的软件.让你能够合理的安排自己的时间,比如制定什么样的计划,而且支持计划暂停,在你休息的时候,或者娱乐的时候暂停时间确保你能够完全完成自己制定的任 ...

  7. mac如何打开服务器文件,mac 打开远程服务器文件共享

    mac 打开远程服务器文件共享 内容精选 换一换 分析辅助软件是一款支持部署到多台服务器目标环境上,实现对整个业务集群的数据采集和优化的组件.已成功登录Java性能分析.待安装分析辅助软件的服务器已开 ...

  8. 互联网+智慧人才:全面提升人才工作协同、服务、监管、决策的综合水平

    人才是第一资源,创新是第一动力,要紧密围绕人社发展大局和中心工作,按照"总体设计.分类架构.统一标准.重点突破.形成系统"的建设思路,开展人才一体化综合服务平台项目建设,不断深化人 ...

  9. 腾讯企点 for Mac(办公协同软件)免费版

    腾讯企点 for Mac是腾讯官方推出的一款办公协同软件,腾讯企点mac版提供了一个企业多平台的社媒管理平台,企业可以通过腾讯企点for mac在互联网时代连接不同营销渠道的客户,这样就可以更精细的进 ...

  10. 腾讯企点 for Mac(办公协同软件)中文免费版

    腾讯企点 for Mac是腾讯官方推出的一款办公协同软件,腾讯企点mac版提供了一个企业多平台的社媒管理平台,企业可以通过腾讯企点for mac在互联网时代连接不同营销渠道的客户,这样就可以更精细的进 ...

最新文章

  1. 独家 | 带你认识几种最流行的Python编辑器/IDEs(附链接)
  2. delphi xls 线程_锐龙9 5950X怒超近6GHz!关键是16核心32线程全开-锐龙,锐龙9 5950X,超频 ——快科技(驱动之家旗下媒体)-...
  3. 解压与压缩(把dataset转为string、、 )
  4. Android之View和SurfaceView
  5. 那些你踩过的币圈投资陷阱(下)
  6. optee_os中静态共享内存的注册
  7. mysql常用命令集合 及附图操作
  8. [导入]在ASP.NET中跨页面实现多选
  9. Oracle约束的关键字Enable/Disable/Validate/Novalidate
  10. 5G的场景、需求、通信速率
  11. python传中文参数_解决Python传递中文参数的问题
  12. 最近两天遇到的问题 原因 和处理方式 小结
  13. python与mysql数据库如何连接_如何连接Python中的MySQL数据库?
  14. python 对话框开发_python文件选择对话框的操作方法
  15. 查看驱动安装错误日志
  16. 正式环境docker部署hyperf_HyperLedger/Fabric SDK使用Docker容器镜像快速部署上线
  17. Jquery Ajax 异步设置Table中某列的值
  18. qca9377linux无线驱动,ubuntu下安装无线网卡去驱动Qualcomm-Atheros-QCA9377
  19. 端口映射公网IP访问内网服务器
  20. 扫描文件怎么设置到服务器,如何为扫描仪添加局域网功能

热门文章

  1. 更多编译器对C++11的支持比较
  2. 自己做的一些练习题代码
  3. Java Web基础回顾 —HTTP
  4. 图像等比例缩放的函数封装(PHP)
  5. 转:Android ViewPager多页面滑动切换以及动画效果
  6. Bootstrap页面布局18 - BS导航路径以及分页器
  7. sicily 1345. 能量项链
  8. Web Service Software Factory
  9. Docker使用(三)使用Dockerfile创建镜像以及为镜像添加SSH服务
  10. encodeURI和uncodeURIComponent的介绍