19.5 win和vmware的linux系统之间文件传递
-  Linux虚拟机与Window主机之间进行文件传输:需要在虚拟机安装VMware Tools才能实现Linux虚拟机和Windows主机之间文件传输。 
-  Linux虚拟机与宿主机之间传输文件,可以通过以下几种方式: 方法1:在宿主机中设置与VMware虚拟机可以互访的共享文件夹 方法2:先在VMware需要安装VMwaretools ,之后就可以拖拽复制粘贴,直接将Linux(ubuntu)虚拟机的文件图标,拖拽到Windows桌面就可以实现文件传输。当然此方法也适用于Windows主机传文件到Linux(ubuntu)虚拟机。 方法3:通过互访的web服务或文件传输工具Xftp进行文件传输。 
但如果虚拟机操作系统是服务器版、linux版本等为装桌面的版本或者是虚拟网卡网络问题,对于方法2.3就不是首选。在宿主机中设置与VMware虚拟机可以互访的共享文件夹,是最简单最理想的文件传递方法。
19.5.1 设置共享文件夹
- 共享文件夹可以在虚拟机和物理机之间进行文件的直接传输和其他操作。
- 在VMware虚拟机设置选项中,启用共享文件夹,共享文件夹相当于是Linux虚拟机和Windows主机都可以看见的一个文件夹,其他文件夹双方不可见。添加Windows下共享文件夹的路径,可以重命名该文件夹,Linux访问该文件夹时,就访问重命名后的文件名。
只有在虚拟机安装VMware Tools才可以在虚拟机运行时设置共享文件夹(如果要安装VMware Tools,请在虚拟机运行的情况下,单击vm菜单栏“虚拟机”->“安装VMware Tools”之后见下一小节进行安装VMware Tools),否则要设置共享文件夹,只能在虚拟机关机的情况下设置
单击vm的菜单栏上的“虚拟机”->“设置”。
 
 选择“选项”页面,选择“共享文件夹”,在右侧单击“总是启用”。
 
 
完成之后,点击确定
-  进入共享文件夹,cd /mnt/hgfs/共享文件夹名/。一般通过cp /mnt/hgfs/共享文件夹名/文件名 目的路径,来将共享文件夹的文件拷贝一份到虚拟机,也可以反过来将虚拟机下的文件复制到共享文件夹中,让Windows主机也可以访问。 
-  存在问题:有时候虚拟机设置好共享文件夹不显示。Linux下共享文件夹的默认路径为 /mnt/hgfs,所以 cd /mnt/hgfs 进入到共享文件夹下, ls 查看刚设置好的共享文件夹是否显示,如若不显示,进行以下操作: 
centos7
1:输入命令  yum install open-vm-tools  安装工具
2:输入命令  vmhgfs-fuse .host:/ /mnt/hgfs  完成设置
centos8
1:输入命令  dnf  remove  open-vm-tools
2:输入命令  yum install open-vm-tools  安装工具
#设置完成后,cd /mnt/hgfs  进入该目录下 ls 查看共享文件夹是否显示,或者重启,然后再  cd /mnt/hgfs 再 ls 查看。
- 若重启后共享目录不见了则可执行以下操作在文件的下面新增以下内容
# mount shared floder
vmhgfs-fuse .host:/ /mnt/hgfs
 
# 加参数
# vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other,uid=1000,gid=1000
- 执行结果:
[root@localhost ~]# cd /mnt
[root@localhost mnt]# ll
总用量 5
dr-xr-xr-x 1 root root 4192 11月 21 00:36 hgfs
[root@localhost mnt]# ll hgfs/
总用量 8
drwxrwxrwx 1 root root 8192 11月 20 13:47 共享文件夹
[root@localhost mnt]# 
19.5.2 安装VMwaretools
- VMware需要安装VMwaretools步骤:
- 虚拟机->设置->添加->CD/DVD驱动器->使用ISO映像文件,选择vm安装目录下的linux.iso的文件

- 之后登入ubuntu虚拟机中会在桌面出现一个dvd,把里边的压缩包VMwareTools-10.1.15-6627299.tar.gz复制到/usr/local/src目录下使用用sudo复制并在/usr/local/src目录下解压tar -xzvf xxxx,解压完出现vmware-tools-distrib文件夹,找到vmware-install.pl,sudo运行,然后重启虚拟机。就可以出现主机和虚拟机之间复制粘贴。
- 对于centos虚拟机未安装桌面从而没有dvd目录,那么需要将linux.iso镜像文件中的VMwareTools-10.3.23-16594550.tar.gz安装包使用xftp等文件传输工具上传到/usr/local/src目录
#复制VMwareTools-10.1.15-6627299.tar.gz到/usr/local/src
cp VMwareTools-10.1.15-6627299.tar.gz /usr/local/src
#进入/usr/local/src目录
cd /usr/local/src
#创建到/usr/local/VMwareToos目录安装目录
mkdir /usr/local/VMwareToos
#解压VMwareTools-10.1.15-6627299.tar.gz安装包到/usr/local/VMwareToos目录
tar -zxvf VMwareTools-10.1.15-6627299.tar.gz -C /usr/local/VMwareToos
#进入解压安装目录
cd /usr/local/VMwareToos/vmware-tools-distrib
#ls 查看     
[root@localhost vmware-tools-distrib]# ls
bin  doc  FILES    installer  vgauth
caf  etc  INSTALL  lib        vmware-install.pl
#如果是root 就不需要sudo 直接执行绿色的可执行文件
sudo ./vmware-install.pl ,输入密码,有提示直接回车就行
#sudo 以管理员的权限运行后面的程序,reboot后就可以直接从主机复制文件到虚拟机上
- 回车之后提示输入管理员密码,然后一路确认回车后(不用输“y”,直接回车,相当于在Windows里安装软件时所填答的诸多对话框,我们这里均采用缺省设置),直到最后出现“Enjoy——the VMware team”的字样后,VMwareTools终于安装完成了。
   Creating a new VMware Tools installer database using the tar4 format.   
   Installing VMware Tools.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin] y   
   The path "y" is a relative path. Please enter an absolute path.   
   In which directory do you want to install the binary files?   
   [/usr/bin]   
   What is the directory that contains the init directories (rc0.d/ to rc6.d/)?   
   [/etc]   
   What is the directory that contains the init scripts?   
   [/etc/init.d]   
   In which directory do you want to install the daemon files?   
   [/usr/sbin]   
   In which directory do you want to install the library files?   
   [/usr/lib/vmware-tools]   
   The path "/usr/lib/vmware-tools" does not exist currently. This program is   
   going to create it, including needed parent directories. Is this what you want?   
   [yes]   
   In which directory do you want to install the documentation files?   
   [/usr/share/doc/vmware-tools]   
   The path "/usr/share/doc/vmware-tools" does not exist currently. This program   
   is going to create it, including needed parent directories. Is this what you   
   want? [yes]   
   The installation of VMware Tools 6.5.0 build-118166 for Linux completed   
   successfully. You can decide to remove this software from your system at any   
   time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl".   
   Before running VMware Tools for the first time, you need to configure it by   
   invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want   
   this program to invoke the command for you now? [yes]   
   Stopping VMware Tools services in the virtual machine:   
   Guest operating system daemon: done   
   Virtual Printing daemon: done   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmmemctl module loads perfectly into   
   the running kernel.   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmhgfs module loads perfectly into   
   the running kernel.   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmxnet module loads perfectly into   
   the running kernel.   
   update-initramfs: Generating /boot/initrd.img-2.6.24-16-generic   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmblock module loads perfectly into   
   the running kernel.   
   [EXPERIMENTAL] The VMware FileSystem Sync Driver (vmsync) is a new feature that   
   creates backups of virtual machines. Please refer to the VMware Knowledge Base   
   for more details on this capability. Do you wish to enable this feature?   
   [no] yes   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmsync module loads perfectly into   
   the running kernel.   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vmci module loads perfectly into the   
   running kernel.   
   The bld-2.6.24-16-i386generic-Ubuntu8.04 - vsock module loads perfectly into   
   the running kernel.   
   Detected X.org version 7.3.0.   
   Please choose one of the following display sizes that X will start with (1 -   
   29):   
   [1] "320x200"   
   [2] "320x240"   
   [3] "400x300"   
   [4] "512x384"   
   [5] "640x400"   
   [6] "640x480"   
   [7] "720x480"   
   [8] "800x480"   
   [9] "854x480"   
   [10]< "720x576"   
   [11] "800x600"   
   [12] "1024x768"   
   [13] "1280x720"   
   [14] "1280x768"   
   [15] "1152x864"   
   [16] "1280x800"   
   [17] "1366x768"   
   [18] "1280x960"   
   [19] "1440x900"   
   [20] "1280x1024"   
   [21] "1400x1050"   
   [22] "1680x1050"   
   [23] "1600x1200"   
   [24] "1920x1080"   
   [25] "1920x1200"   
   [26] "1920x1440"   
   [27] "2048x1536"   
   [28] "2560x1600"   
   [29] "2560x1920"   
   Please enter a number between 1 and 29:   
   [10] 11 //或其他尺寸,一般不要超过宿主机的屏幕分辨率,要不看起来还得拖动滚动条。全屏显示虚拟机的快捷键是CTRL+ALT+ENTER.  
   This is a pre-release version of the X server from The X.Org Foundation.   
   It is not supported in any way.   
   Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.   
   Select the "xorg" product for bugs you find in this release.   
   Before reporting bugs in pre-release versions please check the   
   latest version in the X.Org Foundation git repository.   
   See http://wiki.x.org/wiki/GitPage for git access instructions.   
   X.Org X Server 1.4.0.90   
   Release Date: 5 September 2007   
   X Protocol Version 11, Revision 0   
   Build Operating System: Linux Ubuntu (xorg-server 2:1.4.1~git20080131-1ubuntu9)   
   Current Operating System: Linux jim-desktop 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686   
   Build Date: 15 April 2008 05:26:17PM   
   Before reporting problems, check http://wiki.x.org to make sure that you have the latest version.   
   Module Loader present   
   Markers: (--) probed, (**) from config file, (==) default setting,   
   (++) from command line, (!!) notice, (II) informational,   
   (WW) warning, (EE) error, (NI) not implemented, (??) unknown.   
   (++) Log file: "/tmp/vmware-config0/XF86ConfigLog.6478", Time: Fri Sep 26 18:16:38 2008   
   (++) Using config file: "/tmp/vmware-config0/XF86Config.6478"   
   (II) Module "ramdac" already built-in   
   X is running fine with the new config file.   
   expected keysym, got XF86KbdLightOnOff: line 70 of pc   
   expected keysym, got XF86KbdBrightnessDown: line 71 of pc   
   expected keysym, got XF86KbdBrightnessUp: line 72 of pc   
   expected keysym, got XF86KbdLightOnOff: line 70 of pc   
   expected keysym, got XF86KbdBrightnessDown: line 71 of pc   
   expected keysym, got XF86KbdBrightnessUp: line 72 of pc   
   FreeFontPath: FPE "/usr/share/fonts/X11/misc" refcount is 2, should be 1; fixing.   
   Checking acpi hot plug done   
   Starting VMware Tools services in the virtual machine:   
   Switching to guest configuration: done   
   Guest filesystem driver: done   
   Mounting HGFS shares: failed   
   Guest memory manager: done   
   Guest vmxnet fast network device: done   
   VM communication interface: done   
   VM communication interface socket family: done   
   Blocking file system: done   
   File system sync driver: done   
   Guest operating system daemon: done   
   Virtual Printing daemon: done   
   The configuration of VMware Tools 6.5.0 build-118166 for Linux for this running   
   kernel completed successfully.   
   You must restart your X session before any mouse or graphics changes take   
   effect.   
   You can now run VMware Tools by invoking the following command:   
   "/usr/bin/vmware-toolbox" during an X server session.   
   To enable advanced X features (e.g., guest resolution fit, drag and drop, and   
   file and text copy/paste), you will need to do one (or more) of the following:   
   1. Manually start /usr/bin/vmware-user   
   2. Log out and log back into your desktop session; and,   
   3. Restart your X session.   
   To use the vmxnet driver, restart networking using the following commands:   
   /etc/init.d/networking stop   
   rmmod pcnet32   
   rmmod vmxnet   
   modprobe vmxnet   
   /etc/init.d/networking start   
   If the virtual printer feature is enabled, you will need to restart the CUPS   
   service to make use of this feature.   
   Enjoy,   
   --the VMware team  
   //至此VMware Tools安装结束。  
问题:在安装VMwanre tools时 会出现所需内核头版本太低而导致无法识别的问题Enter the path to the kernel header files for the 3.10.0-862.14.4.el7.x86_64 kernel?
解决步骤:
1.使用ctrl+z停止安装vmtools安装
2.然后yum升级
yum -y update #先更新旧的内核文件 yum -y install kernel-headers kernel-devel gcc #在安装内核头文件
- Linux真机和Windows主机之间如果要进行文件共享,需要双方的网络连通,之后就可以使用filezilla,totalcommand,cuteftp等文档传输工具进行文档传输


















