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. 第08组 Beta冲刺(3/5)

    队名:955 组长博客:点这里! 作业博客:点这里! 组员情况 组员1(组长):庄锡荣 过去两天完成了哪些任务 文字/口头描述 ? 维持进度,检查需求 展示GitHub当日代码/文档签入记录 接下来的 ...

  2. Javascript Asynchronous Investigation

    介绍 同步任务:在主线程上排队执行的任务,只有前一个任务执行完毕,才能执行后一个任务: 异步任务:不进入主线程,而进入任务队列中的任务,只有任务队列通知主线程,某个异步任务可以执行了,这个任务才会进入 ...

  3. Spring BeanFactory继承结构图

    结构图 高清大图:https://img2018.cnblogs.com/blog/813478/201910/813478-20191030114422275-1092084932.jpg 源文件( ...

  4. Linux常用命令wc

    wc名字来源: wc -- word, line, character, and byte count The wc utility displays the number of lines, wor ...

  5. Linux学习笔记之RAID笔记

    RAID: Redundant Arrays of Inexpensive Disks Independent Berkeley: A case for Redundent Arrays of Ine ...

  6. NVIDIA-docker Cheatsheet

    TensorFlow Docker requirements Install Docker on your local host machine. For GPU support on Linux,  ...

  7. 利用cv与matplotlib.pyplot读图片与显示图片

    import matplotlib.pyplot as pltimport cv2 as cva=cv.imread('learn.jpg')cv.imshow('learn',a)fig=plt.f ...

  8. MySQL里默认的几个库是干啥的?

    本文涉及:MySQL安装后自带的4个数据库:information_schema. performance_schema.sys.mysql的作用及其中各个表所存储的数据含义 information_ ...

  9. English--虚拟语气和条件状语从句

    English|虚拟语气和条件状语从句 虚拟语气在英语中,还是有一定地位的,毕竟大家都做着我有一百万的梦~~~ 前言 目前所有的文章思想格式都是:知识+情感. 知识:对于所有的知识点的描述.力求不含任 ...

  10. python基础--初始数据结构

    目录: 一.知识点1.IDE 集成开发环境2.字符格式化输出3.数据运算4.循环loop5.数据类型6.列表与元组 二.例子1.输入名字.年龄.工作.薪水,进行格式化的输出.2.for语句实现输入密码 ...