Virtualbox 设置虚拟机和物理机共享文件夹

概述

当我们在本地机安装好一个虚拟机后,特别是安装linux系统的朋友们,经常需要将本地机的文件传递到虚拟机中, 能实现的方式肯定是多式多样的,就本人来说,没有设置共享文件夹之前,一直都是用的sftp方式利用ssh通道传递,由于是本地网络,用得也顺手。这种方式唯一需要的就是需要下载一个好的sftp传递工具,可是有的朋友就会想,虚拟机也是建立在物理机上,为什么不能直接从物理机传递进去呢?对的,vmware 和virtualbox 虚拟机都有共享文件夹功能,直接将本地一个文件夹挂载到虚拟机中,下面介绍如何实现此过程。

由于我这里使用的是virtualbox,所以用virtualbox来演示,其他虚拟的原理是一样的,这里不做介绍。

步骤1

virtuabox建立共享文件夹

先选定需要建立共享文件夹的虚拟机,选择设置=》共享文件夹,点击右侧蓝色+号图标新建共享文件夹。

选择一个本地机文件夹作为共享文件夹,如果没有特殊权限要求,勾选固定分配项。

步骤2

添加驱动

选择存储=》控制器IDE=》添加光驱=》VBoxGuestAdditions.iso,VBoxGuestAdditions.iso光驱镜像在virtualBox的安装目录下

步骤3

挂载到系统

启动系统后执行以下命令

[root@localhost ~]# mount -t auto /dev/cdrom /mnt/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# cd /mnt/cdrom/
[root@localhost cdrom]# ls
32Bit AUTORUN.INF cert runasroot.sh VBoxLinuxAdditions.run VBoxWindowsAdditions-amd64.exe VBoxWindowsAdditions-x86.exe
64Bit autorun.sh OS2 TRANS.TBL VBoxSolarisAdditions.pkg VBoxWindowsAdditions.exe
[root@localhost cdrom]# ls
32Bit AUTORUN.INF cert runasroot.sh VBoxLinuxAdditions.run VBoxWindowsAdditions-amd64.exe VBoxWindowsAdditions-x86.exe
64Bit autorun.sh OS2 TRANS.TBL VBoxSolarisAdditions.pkg VBoxWindowsAdditions.exe
[root@localhost cdrom]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.18 Guest Additions for Linux........
bzip2 not found. Please install: bzip2 tar; and try again.
[root@localhost cdrom]# yum install bzip2
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 bzip2.x86_64.0.1.0.6-13.el7 将被 安装
--> 解决依赖关系完成 ...
## 这里我的centos 虚拟机缺少bzip2依赖,提示缺少什么就安装什么,安装依赖后继续执行 VBoxLinuxAdditions.run 已安装:
bzip2.x86_64 0:1.0.6-13.el7 完毕!
[root@localhost cdrom]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.18 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-1062.4.1.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-1062.4.1.el7.x86_64
[root@localhost ~]# mkdir /local
[root@localhost ~]# mount -t vboxsf local /local
ls /local/
test
[root@localhost ~]# ls /
bin boot dev etc home lib lib64 local media mnt opt proc root run sbin srv sys tmp usr var # 挂载成功 /local 文件夹显示绿色
# mount -t vboxsf local(该目录为virtualbox界面创建的文件夹名称,根据自己修改) /local

Virtualbox 设置虚拟机和物理机共享文件夹的更多相关文章

  1. CentOS虚拟机和物理机共享文件夹实现

    安装open-vm-tools: yum -y install  open-vm-tools yum -y  install open-vm-tools yum -y install  open-vm ...

  2. vmware linux虚拟机与本地物理机共享文件夹

    cd /mnt/hgfs 使用Vmware安装了linux虚拟机后,开发时,为了方便文件的传输等,因此需要使用共享文件夹,减少工作量.共享文件夹需要用到vmware提供的vmware tools工具, ...

  3. Virtualbox Ubuntu 虚拟机命令行挂载共享文件夹及设置静态IP

    挂载共享文件夹 参考 [1], VirtualBox/GuestAdditions [2], VirtualBox/SharedFolders 步骤 在Virtualbox 虚拟机的菜单『设备』中,点 ...

  4. Mac下Kali虚拟机与宿主机共享文件夹

    宿主机: 1.创建文件夹.测试文件 ZhangSan-MacBook-Air:~ zhangsan$ mkdir kalishare && cd kalishare/ ZhangSan ...

  5. 宿主机共享文件夹给不同Linux虚拟机的方法

    一.Windows/Linux宿主机共享文件夹给VMWare中的Linux虚拟机 1.能安装vmware tools1)在vmware的ubuntu中安装vmware tools2)在vmware中开 ...

  6. 设置VMware Player中的虚拟机和宿主机共享文件

    设置VMware Player中的虚拟机和宿主机共享文件 试验环境: 虚拟机软件:VMware Player 6.0.3 宿主机os:windows7 虚拟机os:centos6.6(32位)   完 ...

  7. [转帖]如何禁止VirtualBox虚拟机和物理机之间的时间同步

    如何禁止VirtualBox虚拟机和物理机之间的时间同步 乐者为王 2014-11-02 706 阅读   http://ju.outofmemory.cn/entry/97301 验证了下 修改注册 ...

  8. 【转】virtualbox安装增强包及配置共享文件夹

    原文网址:http://www.2cto.com/os/201308/233609.html virtualbox安装增强包及配置共享文件夹     因为需要在host及虚拟机间传输数据,想使用共享文 ...

  9. VMware: windows8 与 虚拟机ubuntu 14.04 共享文件夹

    假设当前用户为xxx 安装 VMwareTools 1. 打开 VMwareworkstation窗口,选择”虚拟机” -> “重新安装VMwareTools(T)”. 点击之后,会发现 Ubu ...

随机推荐

  1. 你好,我叫Flask

    首先,要看你学没学过Django 如果学过Django 的同学,请从头看到尾,如果没有学过Django的同学,并且不想学习Django的同学,轻饶过第一部分 一. Python 现阶段三大主流Web框 ...

  2. [转]Jumpserve跳板机的生产环境应用

    Jumpserver是国内一款开源的轻便的跳板机系统,他们的官网:http://www.jumpserver.org/ 使用这款软件意在提高公司内部登录生产环境服务器的便捷性,权限分配细化,以及后台管 ...

  3. 执行git log/status等命令时,重新打开了个窗口,必须按q才能退出

    终端运行: git config --global core.pager ''

  4. Centos目录及其常用处理命令

    1.Centos之常见目录作用介绍[1] 我们先切换到系统根目录 / 看看根目录下有哪些目录 [root@localhost ~]# cd / [root@localhost /]# ls bin   ...

  5. 【Gamma】Scrum Meeting 9

    目录 写在前面 进度情况 任务进度表 燃尽图 照片 写在前面 例会时间:6.7 22:30-23.00 例会地点:微信群语音通话 代码进度记录github在这里 进度情况 任务进度表 注:点击链接跳转 ...

  6. sbt 安装

    此次安装实在windows 下进行的 1.官网下载sbt 2.安装并配置环境变量 path  中添加: 3.更改sbt配置文件 1)修改C:\notos\software\sbt\conf\sbtco ...

  7. [转帖]知新之--12-factors

    知新之--12-factors https://blog.csdn.net/weixin_34233421/article/details/85819756 12-factors I. 基准代码 一份 ...

  8. 开源分布式数据库中间件 DBLE

    DBLE 是企业级开源分布式中间件,江湖人送外号 “MyCat Plus”:以其简单稳定,持续维护,良好的社区环境和广大的群众基础得到了社区的大力支持: DBLE官方网站:https://openso ...

  9. Excel数据都在一列,如何批量转置

    Evernote Export Excel数据都在一列,如何批量转置 创建时间: 2019-10-21 星期一 13:41 作者: 苏苏 标签: excel, 转置       问题 Excel数据都 ...

  10. django开发_七牛云图片管理

    七牛云注册 https://www.qiniu.com/ 实名认证成功之后,赠送10G存储空间 复制粘贴AK和SK 创建存储空间,填写空间名称,选择存储区域.访问控制选择位公开空间 获取测试域名 七牛 ...