使用hgfs实现vmware文件传输,不需要任何网络相关设置,这对于网络不通时进行vmware与host传输文件带来方便,不用u盘mount即可实现.
host和ghost可以是linux和windows操作系统,这里只介绍host是windows,ghost是linux下的设置.若ghost是windows,可以参考vmware帮助中的setting up shared folders.
下面的介绍假定VMware,linux等已经安装:-)
1.下载一个VMwareTools包,如:VMwareTools-5.0.0-13124.i386.tar.gz
2.安装VMwareTools包
# tar xzfv VMwareTools-5.0.0-13124.i386.tar.gz
<output>
在当前目录下生成vmware-tools-distrib文件夹
# cd vmware-tools-distrib
# ls
bin doc etc FILES INSTALL installer lib sbin vmware-install.pl
# ./vmware-install.pl <执行vmware的安装脚本,这个脚本是用perl编写的>
安装程序会询问安装文件存放位置和设置分辨率等一系列问题,在大多数情况下,安装默认配置VMware tools就可以正常工作,因此,在此对每一个问题按回车键选择默认配置.输出信息类似如下:
Creating a new installer database using the tar3 format.
Installing the content of the package.
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 goingto 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 isgoing to create it, including needed parent directories. Is this what you want?
[yes]
The installation of VMware Tools 5.0.0 build-13124 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: [ OK ]
Trying to find a suitable vmhgfs module for your running kernel.
The module up-2.4.20-8.athlon-RH9.0 loads perfectly in the running kernel.
Trying to find a suitable vmxnet module for your running kernel.
None of the pre-built vmxnet modules for VMware Tools is suitable for your
running kernel. Do you want this program to try to build the vmxnet module for
your system (you need to have a C compiler installed on your system)? [yes]
Using compiler "/usr/bin/gcc". Use environment variable CC to override.
What is the location of the directory of C header files that match your running
kernel? [/lib/modules/2.4.20-8/build/include]
Extracting the sources of the vmxnet module.
Building the vmxnet module.
Using standalone build system.
make: Entering directory `/tmp/vmware-config0/vmxnet-only'
make: Leaving directory `/tmp/vmware-config0/vmxnet-only'
The module loads perfectly in the running kernel.
Detected XFree86 version 4.3.0.
Shutting down console mouse services: [ OK ]
Starting console mouse services: [ OK ]
Please choose one of the following display sizes (1 - 9):
[1] "640x480"
[2] "800x600"
[3] "1024x768"
[4] "1152x864"
[5]< "1152x900"
[6] "1280x1024"
[7] "1376x1032"
[8] "1600x1200"
[9] "2364x1773"
Please enter a number between 1 and 9:
[5]
XFree86 Version 4.3.0 (Red Hat Linux release: 4.3.0-2)
Release Date: 27 February 2003
X Protocol Version 11, Revision 0, Release 6.6
Build Operating System: Linux 2.4.20-3bigmem i686 [ELF]
Build Date: 27 February 2003
Build Host: porky.devel.redhat.com
Before reporting problems, check http://www.XFree86.Org/
to make sure that you have the latest version.
Module Loader present
OS Kernel: Linux version 2.4.20-8 (bhcompile@stripples.devel.redhat.com) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Thu Mar 13 17:18:24 EST 2003 PFMarkers: (--) 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.18711", Time: Sun Jul 20 00:03:24 2008
(++) Using config file: "/tmp/vmware-config0/XF86Config.18711"
(WW) VMWARE(0): Failed to set up write-combining range (0xf0000000,0x1000000)
X is running fine with the new config file.
Starting VMware Tools services in the virtual machine:
Switching to guest configuration: [ OK ]
Guest filesystem driver: [ OK ]
DMA setup: [ OK ]
Guest operating system daemon: [ OK ]
The configuration of VMware Tools 5.0.0 build-13124 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 XFree86 session.
To use the vmxnet driver, restart networking using the following commands:
/etc/init.d/network stop
rmmod pcnet32
rmmod vmxnet
depmod -a
modprobe vmxnet
/etc/init.d/network start
Enjoy,
--the VMware team
[root@localhost vmware-tools-distrib]#
3.安装完后,vmware会添加一个vmhgfs的模块到内核中,用lsmod查看如下:
[root@localhost /]# lsmod
Module Size Used by Tainted: PF
vmhgfs 41632 4
es1371 30504 0 (autoclean)
ac97_codec 13544 0 (autoclean) [es1371]
gameport 3332 0 (autoclean) [es1371]
soundcore 6276 4 (autoclean) [es1371]
vfat 12844 0 (autoclean)
fat 38328 0 (autoclean) [vfat]
usb-storage 68628 0
ide-cd 35196 0 (autoclean)
............
在/mnt目录下会生成hgfs目录
[root@localhost /]# cd /mnt/
[root@localhost mnt]# ls
cdrom floppy hgfs myusb
[root@localhost mnt]#
4.设置host computer共享的目录
(1) 在ghost computer中(即VMware虚拟机)切换到windows桌面,选择VMware workstation程序菜单中VM---->settings---->Options---->shared folders---->properties
(2) 点击对话框右下的"Add"---->"下一步",在文本框"name"中输入共享目录的名字(即在ghost computer的linux系统中将显示出同样的目录名),假设为win2linux,在"host folder"中填入host computer 中windows系统想要共享出来的目录,假设为F:/win2linux,然后点击"完成".
(注: F:/win2linux目录要手动建立,即在F盘下建一个新建文件夹,命名为win2linux)
(3) 下一个对话框似选择共享的方式:Enable this share是指这个共享长期有效.目录可读写---->"完成",至此,shared folder设置完毕
5.共享目录设置完成后,在/mnt/hgfs/目录下有新生成的共享目录win2linux
[root@localhost /]# cd /mnt/
[root@localhost mnt]# ls
cdrom floppy hgfs myusb
[root@localhost mnt]#
举例:
1.如:要将文件包make-3.81.tar.gz从windows拷贝到VM linux中,只需将make-3.81.tar.gz拷贝到windows的F:/win2linux目录下,则在limux的/mnt/hgfs/win2linux下就有该文件,可以直接用了.
[root@localhost win2linux]# ls
make-3.81.tar.gz
[root@localhost win2linux]# ls
2.将linux中的文件拷贝到windows中
只需将要拷贝的文件拷贝到/mnt/hgfs/win2linux目录下,在windows的F:/win2linux目录下即有该文件
[root@localhost mickey]# cp ./vmtool_install_print.txt /mnt/hgfs/win2linux
[root@localhost mickey]#