您好,登錄后才能下訂單哦!
通過(guò)VMware Tools實(shí)現(xiàn)物理機(jī)與虛擬機(jī)之間的文件共享。然而CentOS 7在安裝(或更新)VMware Tools可能會(huì)遇到一些問(wèn)題,需要手動(dòng)修改源文件并打包,重新安裝。
環(huán)境說(shuō)明
環(huán)境 | 版本 |
---|---|
物理機(jī) | Windows 10 |
VMware | VMware Workstation 12 Pro, 版本是 12.5.2 build-4638234 |
CentOS 7 | kernel-3.10.0-514.21.1.el7.x86_64 |
1、檢查VMware Tools
檢查是否已經(jīng)安裝了VMware Tools, 如果已經(jīng)安裝好,可以跳到步驟4,配置共享文件夾。
單擊菜單 虛擬機(jī)
如果下拉列表中出現(xiàn)了如下圖所示的 更新 VMware Tools
,則說(shuō)明已經(jīng)安裝好了(但這并不意味著能成功配置共享文件夾,如果此時(shí)VMware默認(rèn)的共享目錄/mnt/hgfs/不存在,那基本意味著需要重新安裝了),可以暫時(shí)跳過(guò)安裝步驟。
如果出現(xiàn) 安裝 VMware Tools ,則直接點(diǎn)擊安裝
2、安裝 VMware Tools
點(diǎn)擊安裝VMware Tools
或更新VMware Tools
后, CentOS會(huì)自動(dòng)掛載VMware Tools, 雙擊打開,將里面的VMwareTools-X.tar.gz復(fù)制到桌面上
在桌面打開終端,解壓tar.gz包
進(jìn)入解壓得到的vmware-tools-distrib目錄,開始安裝(需要已root身份進(jìn)行),過(guò)程中遇到需要輸入信息的,一路回車下去,采用默認(rèn)設(shè)置即可
[hadoop@centos7-2 vmware-tools-distrib]$ sudo ./vmware-install.pl
安裝過(guò)程可能不會(huì)一路順利,比如會(huì)遇到以下錯(cuò)誤
Using kernel build system. make: Entering directory `/tmp/modconfig-yqRMXf/vmhgfs-only' /bin/make -C /lib/modules/3.10.0-514.21.1.el7.x86_64/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \ MODULEBUILDDIR= modules make[1]: Entering directory `/usr/src/kernels/3.10.0-514.21.1.el7.x86_64' CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/message.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/dir.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/rpcout.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/filesystem.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/cpName.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/link.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/request.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/hgfsUtil.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/file.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/bdhandler.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/transport.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/module.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/super.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/stubs.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/fsutil.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/cpNameLinux.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/hgfsBd.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/backdoorGcc64.o /tmp/modconfig-yqRMXf/vmhgfs-only/backdoorGcc64.o: warning: objtool: BackdoorHbIn()+0xd: duplicate frame pointer save /tmp/modconfig-yqRMXf/vmhgfs-only/backdoorGcc64.o: warning: objtool: BackdoorHbOut()+0xd: duplicate frame pointer save CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/page.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/backdoor.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/hgfsEscape.o CC [M] /tmp/modconfig-yqRMXf/vmhgfs-only/inode.o /tmp/modconfig-yqRMXf/vmhgfs-only/page.c: In function ‘HgfsWbRequestWait': /tmp/modconfig-yqRMXf/vmhgfs-only/page.c:1649:23: warning: passing argument 3 of ‘wait_on_bit' makes integer from pointer without a cast [enabled by default] TASK_UNINTERRUPTIBLE); ^ In file included from include/linux/mmzone.h:9:0, from include/linux/gfp.h:5, from include/linux/mm.h:9, from include/linux/pagemap.h:7, from /tmp/modconfig-yqRMXf/vmhgfs-only/page.c:28: include/linux/wait.h:1044:1: note: expected ‘unsigned int' but argument is of type ‘int (*)(void *)' wait_on_bit(void *word, int bit, unsigned mode) ^ /tmp/modconfig-yqRMXf/vmhgfs-only/page.c:1649:23: error: too many arguments to function ‘wait_on_bit' TASK_UNINTERRUPTIBLE); ^ In file included from include/linux/mmzone.h:9:0, from include/linux/gfp.h:5, from include/linux/mm.h:9, from include/linux/pagemap.h:7, from /tmp/modconfig-yqRMXf/vmhgfs-only/page.c:28: include/linux/wait.h:1044:1: note: declared here wait_on_bit(void *word, int bit, unsigned mode) ^ make[2]: *** [/tmp/modconfig-yqRMXf/vmhgfs-only/page.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [_module_/tmp/modconfig-yqRMXf/vmhgfs-only] Error 2 make[1]: Leaving directory `/usr/src/kernels/3.10.0-514.21.1.el7.x86_64' make: *** [vmhgfs.ko] Error 2 make: Leaving directory `/tmp/modconfig-yqRMXf/vmhgfs-only'
上網(wǎng)查了下,此時(shí)需要修改vmware-tools-distrib/lib/modules/source/vmhgfs-only/page.c
[hadoop@centos7-2 vmware-tools-distrib]$ cd lib/modules/source/ [hadoop@centos7-2 source]$ tar -xvf vmhgfs.tar [hadoop@centos7-2 source]$ cd vmhgfs-only/ [hadoop@centos7-2 vmhgfs-only]$ chmod 777 page.c #該文件是只讀的,這里隨便更改了下權(quán)限,只要讓它可寫就行 [hadoop@centos7-2 vmhgfs-only]$ vi page.c # 進(jìn)入文件編輯模式 :set number # 顯示行號(hào) :1639 # 跳到第1639行,需要對(duì)該行進(jìn)行修改
把第1639行的:
if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) 改成 if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
說(shuō)明:因?yàn)?CentOS 7 的內(nèi)核版本是 3.10.0
修改保存后,重新歸檔
[hadoop@centos7-2 source]$ mv vmhgfs.tar vmhgfs.tar.bak [hadoop@centos7-2 source]$ tar -cvf vmhgfs.tar vmhgfs-only [hadoop@centos7-2 source]$ cd ../../.. [hadoop@centos7-2 vmware-tools-distrib]$ sudo ./vmware-install.pl
此后一路回車下去,最終看到如下信息,表示安裝成功
Creating a new initrd boot image for the kernel. Starting Virtual Printing daemon: done Starting vmware-tools (via systemctl): [ OK ] The configuration of VMware Tools 10.0.10 build-4301679 for Linux for this running kernel completed successfully. Enjoy, --the VMware team
重新啟動(dòng)CentOS
3、配置共享文件夾
打開虛擬機(jī)設(shè)置
進(jìn)入虛擬機(jī)設(shè)置
啟用共享文件夾,添加物理機(jī)上需要共享的目錄
VMware默認(rèn)的共享路徑是在/mnt/hgfs
,這是寫死在VMware Tools的腳本里的,我們可以從/etc/init.d/vmware-tools
查到:
vmhgfs_mnt="/mnt/hgfs" #Mount all hgfs filesystems" vmware_mount_vmhgfs() { if [ "`is_vmhgfs_mounted`" = "no" ]; then if [ "`vmware_vmhgfs_use_fuse`" = "yes" ]; then mkdir -p $vmhgfs_mnt vmware_exec_selinux "$vmdb_answer_BINDIR/vmhgfs-fuse \ -o subtype=vmhgfs-fuse,allow_other $vmhgfs_mnt" else vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt" fi fi }
此時(shí)在CentOS 7中就能看到物理機(jī)上面共享的文件夾了:
[hadoop@centos7-2 ~]$ ll /mnt/hgfs/ dr-xr-xr-x. 1 root root 0 Jun 15 00:17 pc-share
至此物理機(jī)與虛擬機(jī)CentOS 7之間的文件夾共享設(shè)置就成功了。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。