Se vi è recentemente capitato di installare l’ultima versione di CentOS in ambiente VMware, probabilmente vi sarete accorti che la condivisione del filesystem da host a guest ha smesso di funzionare. Perché? Semplice: gli Open VM Tools non includono il driver kernel-mode vmhgfs, e sono passati a FUSE. Purtroppo, però, per usufruire della nuova funzionalità è richiesto un kernel 4.x, e CentOS 7 viene distribuito con kernel 3.10. Quindi, almeno per ora, non potremo fare a meno del driver vmhgfs e dovremo compilarlo dai sorgenti.
La documentazione ufficiale raccomanda di installare prima gli Open VM Tools e successivamente il pacchetto VMware Tools distribuito da VMware, allo scopo di ottenere il driver vmhgfs. Il pacchetto proprietario dovrebbe accorgersi della presenza del cugino “Open” e installare solo i componenti mancanti. Peccato che la compilazione del driver fallisce con un errore:
... 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-36luPI/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-36luPI/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-36luPI/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-36luPI/vmhgfs-only/page.o] Error 1 make[1]: *** [_module_/tmp/modconfig-36luPI/vmhgfs-only] Error 2 make[1]: Leaving directory `/usr/src/kernels/3.10.0-514.6.1.el7.x86_64' make: *** [vmhgfs.ko] Error 2 make: Leaving directory `/tmp/modconfig-36luPI/vmhgfs-only'
Niente paura: la soluzione esiste. Partiamo con l’installare gli strumenti di sviluppo, se ancora non sono presenti:
$ sudo yum groupinstall "Development Tools"
Quindi scarichiamo la versione 10.1.0 dei VMware Tools da https://my.vmware.com/group/vmware/details?downloadGroup=VMTOOLS1010&productId=491. C’è bisogno di una login VMware per accedere e scaricare il materiale.
Scompattiamo l’archivio:
$ tar xfz VMware-Tools-10.1.0-core-4449150.tar.gz
Montiamo la ISO contenente i tools per Linux:
$ sudo mount -o loop vmtools/linux.iso /media/cdrom
Estraiamo i sorgenti:
$ tar xfz /media/cdrom/VMwareTools-10.1.0-4449150.tar.gz $ sudo umount /media/cdrom
Ok, ci siamo. Lanciamo il comando di installazione, accettando tutti i valori di default proposti dalla procedura:
$ cd vmware-tools-distrib $ sudo ./vmware-install.pl The installer has detected an existing installation of open-vm-tools packages on this system and will not attempt to remove and replace these user-space applications. It is recommended to use the open-vm-tools packages provided by the operating system. If you do not want to use the existing installation of open-vm-tools packages and use VMware Tools, you must uninstall the open-vm-tools packages and re-run this installer. The packages that need to be removed are: open-vm-tools The installer will next check if there are any missing kernel drivers. Type yes if you want to do this, otherwise type no [yes] A previous installation of VMware Tools has been detected. The previous installation was made by the tar installer (version 4). Keeping the tar4 installer database format. You have a version of VMware Tools installed. Continuing this install will first uninstall the currently installed version. Do you wish to continue? (yes/no) [yes] Uninstalling the tar installation of VMware Tools. Stopping services for VMware Tools Stopping vmware-tools (via systemctl): [ OK ] Stopping Thinprint services in the virtual machine: Stopping Virtual Printing daemon: done The removal of VMware Tools 10.0.6 build-3595377 for Linux completed successfully. Installing VMware Tools. 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] 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 10.1.0 build-4449150 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] You have chosen to install VMware Tools on top of an open-vm-tools package. You will now be given the option to replace some commands provided by open-vm-tools. Please note that if you replace any commands at this time and later remove VMware Tools, it may be necessary to re-install the open-vm-tools. The file /usr/bin/vmware-hgfsclient that this program was about to install already exists. Overwrite? [no] WARNING: It appears your system is missing the required /usr/bin/vmhgfs-fuse Initializing... Making sure services for VMware Tools are stopped. The module vmci has already been installed on this system by another installer or package and will not be modified by this installer. The module vsock has already been installed on this system by another installer or package and will not be modified by this installer. The module vmxnet3 has already been installed on this system by another installer or package and will not be modified by this installer. The module pvscsi has already been installed on this system by another installer or package and will not be modified by this installer. The module vmmemctl has already been installed on this system by another installer or package and will not be modified by this installer. 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] Before you can compile modules, you need to have the following installed... make gcc kernel headers of the running kernel Searching for GCC... Detected GCC binary at "/bin/gcc". 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... Detected the kernel headers at "/lib/modules/3.10.0-514.6.1.el7.x86_64/build/include". The path "/lib/modules/3.10.0-514.6.1.el7.x86_64/build/include" appears to be a valid path to the 3.10.0-514.6.1.el7.x86_64 kernel headers. Would you like to change it? [no] Using kernel build system. make: Entering directory `/tmp/modconfig-hbD7DC/vmhgfs-only' /bin/make -C /lib/modules/3.10.0-514.6.1.el7.x86_64/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \ MODULEBUILDDIR= modules make[1]: Entering directory `/usr/src/kernels/3.10.0-514.6.1.el7.x86_64' CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/message.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/dir.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/request.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/filesystem.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/cpName.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/link.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/rpcout.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/stubs.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/hgfsUtil.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/hgfsEscape.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/file.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/transport.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/module.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/super.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/bdhandler.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/fsutil.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/cpNameLinux.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/hgfsBd.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/backdoorGcc64.o /tmp/modconfig-hbD7DC/vmhgfs-only/backdoorGcc64.o: warning: objtool: BackdoorHbIn()+0xd: duplicate frame pointer save /tmp/modconfig-hbD7DC/vmhgfs-only/backdoorGcc64.o: warning: objtool: BackdoorHbOut()+0xd: duplicate frame pointer save CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/page.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/backdoor.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/inode.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/dentry.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/cpNameLite.o CC [M] /tmp/modconfig-hbD7DC/vmhgfs-only/kernelStubsLinux.o LD [M] /tmp/modconfig-hbD7DC/vmhgfs-only/vmhgfs.o Building modules, stage 2. MODPOST 1 modules CC /tmp/modconfig-hbD7DC/vmhgfs-only/vmhgfs.mod.o LD [M] /tmp/modconfig-hbD7DC/vmhgfs-only/vmhgfs.ko make[1]: Leaving directory `/usr/src/kernels/3.10.0-514.6.1.el7.x86_64' /bin/make -C $PWD SRCROOT=$PWD/. \ MODULEBUILDDIR= postbuild make[1]: Entering directory `/tmp/modconfig-hbD7DC/vmhgfs-only' make[1]: «postbuild» è aggiornato. make[1]: Leaving directory `/tmp/modconfig-hbD7DC/vmhgfs-only' cp -f vmhgfs.ko ./../vmhgfs.o make: Leaving directory `/tmp/modconfig-hbD7DC/vmhgfs-only' The vmxnet driver is no longer supported on kernels 3.3 and greater. Please upgrade to a newer virtual NIC. (e.g., vmxnet3 or e1000e) VMware automatic kernel modules enables automatic building and installation of VMware kernel modules at boot that are not already present. This feature can be enabled/disabled by re-running vmware-config-tools.pl. Would you like to enable VMware automatic kernel modules? [no] Creating a new initrd boot image for the kernel. The configuration of VMware Tools 10.1.0 build-4449150 for Linux for this running kernel completed successfully. Enjoy, --the VMware team
Proviamo. Riavviamo gli Open VM Tools; lo script dovrebbe creare automaticamente il mountpoint ed esporre le directory condivise dall’host:
$ sudo systemctl restart vmware-tools $ ls -l /mnt/hgfs/D drwxrwxrwx 1 root root 4096 30 nov 2015 Android -rwxrwxrwx 1 root root 4295168 14 feb 2014 anyconnect-win-3.1.04072-pre-deploy-k9.msi drwxrwxrwx 1 root root 0 28 apr 2016 apache drwxrwxrwx 1 root root 4096 6 ago 2016 autogs drwxrwxrwx 1 root root 4096 25 ott 2014 AutoIt drwxrwxrwx 1 root root 4096 3 feb 17.10 backup -rwxrwxrwx 1 root root 913 19 mar 2013 bin1.bin -rwxrwxrwx 1 root root 122972 21 dic 2013 capture.pcap ...
Non dimentichiamoci che, ad ogni aggiornamento del kernel, il driver vmhgfs andrà ricompilato e installato rieseguendo lo script vmware-install.pl.
Buon lavoro a tutti!