vmware安裝VMware Tools,並設定共享目錄

junwind發表於2020-09-18

首先,在wmware15上安裝好centos7系統後,wmware會提示我們安裝wmware tools工具,可以直接點選安裝即可,這時,會繼續提示如下資訊

vmware安裝VMware Tools,並設定共享目錄

此時,我們得掛載cdrom,可以先建立一個目錄mkdir /media/cdrom,然後掛載mount /dev/cdrom /media/cdrom

接下來,我們將/media/cdrom的VMwareTools-10.3.21-14772444.tar.gz複製到自己家目錄下,並解壓,然後執行vmware-install.pl

cp /media/cdrom/VMwareTools-10.3.21-14772444.tar.gz ~
tar -zxvf VMwareTools-10.3.21-14772444.tar.gz
cd vmware-tools-distrib/
./vmware-install.pl

接下來,會進入安裝的互動式模式下,一步步說明:

Do you still want to proceed with this installation? [no] yes

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/rc.d] 

What is the directory that contains the init scripts? 
[/etc/rc.d/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] yes

In which directory do you want to install the common agent library files? 
[/usr/lib] 

In which directory do you want to install the common agent transient files? 
[/var/lib] 

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] 

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] yes

The VMware Host-Guest Filesystem allows for shared folders between the host OS 
and the guest OS in a Fusion or Workstation virtual environment.  Do you wish 
to enable this feature? [yes] yes

The path "/bin/gcc" appears to be a valid path to the gcc binary.
Would you like to change it? [no]


這裡要注意,核心標頭檔案路徑為空
Searching for a valid kernel header path...
The path "" is not a valid path to the 3.10.0-1127.el7.x86_64 kernel headers.
Would you like to change it? [yes] 
如何解決,可以參考這篇文章https://blog.csdn.net/w790634493/article/details/80525238
具體意思就讓uname -r查詢的核心版本,kernel-headers,kernel-devel的版本保持一致

然後reboot重啟,繼續之前的安裝步驟,一路走下去,
Searching for a valid kernel header path...
Detected the kernel headers at 
"/lib/modules/3.10.0-1127.19.1.el7.x86_64/build/include".
The path "/lib/modules/3.10.0-1127.19.1.el7.x86_64/build/include" appears to be
a valid path to the 3.10.0-1127.19.1.el7.x86_64 kernel headers.
Would you like to change it? [no] 回車
...
...
The vmblock enables dragging or copying files between host and guest in a 
Fusion or Workstation virtual environment.  Do you wish to enable this feature?
[yes] 

Would you like to enable VMware automatic kernel modules?
[yes] no

Do you want to enable Guest Authentication (vgauth)? Enabling vgauth is needed 
if you want to enable Common Agent (caf). [yes] no

到此,後面不出錯的話,安裝基本完成

現在,讓我們配置虛擬機器與主機的共享目錄:
本地主機:C:\www\centos7-workerman

vmware安裝VMware Tools,並設定共享目錄

vmware安裝VMware Tools,並設定共享目錄

這個也可以啟用起來,很有用

vmware安裝VMware Tools,並設定共享目錄

vmware tools虛擬機器中共享的預設位置為/mnt/hgfs/,接下來,我們還得安裝一下這個yum install open-vm-tools-devel -y 不然下面的掛載很可能會報錯;

在/etc/fstab檔案中,新增掛載點

vim /etc/fstab
...
.host:/centos7-workerman /www/wwwroot fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,umask=022 0 0

mkdir -p /www/wwwroot/

mount -a

其中的centos7-workerman就是上面本地主機目錄的別名,/www/wwwroot就是虛擬機器系統中的目錄,allow_other,uid=1000,gid=1000,umask=022這個就是允許某使用者訪問許可權的,可不寫,換成defaults

mount -a 不出錯,則檢查共享同步情況
至此,本地主機和虛擬機器系統之間的目錄共享設定完畢

另外,對於安裝時的英文,看不懂可以用翻譯軟體

本作品採用《CC 協議》,轉載必須註明作者和本文連結
六月的風

相關文章