原文:https://www.cnblogs.com/sky-cheng/p/15727876.html
官方:https://docs.vmware.com/cn/VMware-Workstation-Pro/16.0/com.vmware.ws.using.doc/GUID-08BB9465-D40A-4E16-9E15-8C016CC8166F.html
一、首先点击vmware客户端菜单的“虚拟机”-》“安装vmware tools”
二、下载完毕后,进入虚拟机安装vmware-tools
当看到如下提示,即下载完毕
三、进入虚拟机,挂载光驱
首先,创建光驱目录
然后,将光驱设备/dev/sr0挂载到/mnt/cdrom
查看/mnt/cdrom
vmware tools安装程序在里面
四、将VmwareTools-9.6.1-1378637.tar.gz复制到/home下,并解压
运行安装脚本
一路回车,安装过程中出现
Searching for a valid kernel header path... The path "" is not a valid path to the 3.10.0-957.el7.x86_64 kernel headers. Would you like to change it? [yes]
需要安装内核,退出安装程序,先用yum list |grep kernel-devel 查看可安装内核
[root@localhost vmware-tools-distrib]# yum list|grep kernel-devel kernel-devel.x86_64 3.10.0-1160.49.1.el7 updates [root@localhost vmware-tools-distrib]#
安装
[root@localhost vmware-tools-distrib]# yum install kernel-devel.x86_64
再安装gcc
[root@localhost vmware-tools-distrib]# yum install gcc -y
再重新安装vmware tools,再reboot
五、设置vmware客户端共享目录
点击"虚拟机"-》“设置”
点击"选项"->"共享文件夹"
设置完毕后,进入虚拟机查看
[root@localhost ~]# vmware-hgfsclient jdk
新建一个/mnt/hgfs 目录
[root@localhost ~]# mkdir /mnt/hgfs
挂载jdk到/mnt/hgfs
[root@localhost ~]# mount -t vmhgfs .host:/jdk /mnt/hgfs Error: cannot mount filesystem: No such device [root@localhost ~]#
报错:没有这个设备,需要安装open-vm-tools
[root@localhost ~]# yum install open-vm-tools -y
执行vmhgfs-fuse 命令将jdk挂载到/mnt/hgfs
[root@localhost ~]# vmhgfs-fuse .host:/jdk /mnt/hgfs/
df -h 查看
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 480M 0 480M 0% /dev tmpfs 491M 0 491M 0% /dev/shm tmpfs 491M 7.5M 484M 2% /run tmpfs 491M 0 491M 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 2.9G 15G 17% / /dev/sda1 1014M 163M 852M 17% /boot tmpfs 99M 0 99M 0% /run/user/0 vmhgfs-fuse 864G 161G 703G 19% /mnt/hgfs
查看/mnt/hgfs 已经能看到宿主机上共享的文件夹内容了
[root@localhost ~]# ll /mnt/hgfs/ total 142281 -rwxrwxrwx 1 root root 11671869 Nov 9 2020 apache-tomcat-8.5.59-windows-x64.zip drwxrwxrwx 1 root root 4096 Dec 16 00:59 apahe_cxf -rwxrwxrwx 1 root root 1627874 Nov 15 2020 aspectjweaver-1.6.8.jar drwxrwxrwx 1 root root 0 Dec 16 01:00 axis drwxrwxrwx 1 root root 0 Dec 16 01:00 axis2 -rwxrwxrwx 1 root root 20443297 Apr 25 2013 axis2-1.4.1-bin.zip -rwxrwxrwx 1 root root 19222129 Apr 25 2013 axis2-1.4.1-war.zip