Virtualbox set up virtual and physical machines shared folders

Virtualbox set up virtual and physical machines shared folders

Outline

When we installed a virtual machine on the local machine, install the linux system especially friends, often need to transfer files from the local machine to a virtual machine, is definitely the way to achieve a variety of multi-style, to himself, not previously set up shared folders, sftp way has been passed with the use of ssh channel, due to the local network, and must also smoothly. In this way the only need is to download a good sftp transfer tool, but some friends would think, is the establishment of a virtual machine on a physical machine, why not transfer directly from the physical machine into it? Right, vmware virtualbox virtual machine and has a shared folder function, a local folder directly mount to the virtual machine, the following describes how to implement this procedure.

Since I used here is virtualbox, so use virtualbox to demonstrate, other virtual principle is the same, not introduced here.

step 1

virtuabox build a shared folder

First select the need to set up a virtual machine shared folder, select Settings = "shared folder, right click on the blue + icon new shared folder.

Choose a local machine folder as a shared folder, if no special permission requirements, check the fixed allocation entries.

Step 2

Add Drive

Memory select = "= the IDE controller" = add the CD-ROM "VBoxGuestAdditions.iso, VBoxGuestAdditions.iso drive the mirror installation directory virtualBox

Step 3

Mount system

After starting the system, execute the following command

[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

Guess you like

Origin www.cnblogs.com/h-gallop/p/12080984.html