最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】VMWare Workstation中实现Win7和Ubuntu虚拟机之间的文件共享

VMWare crifan 8403浏览 0评论

【背景】

折腾:

【记录】在Ubuntu下用crosstool-ng编译xscale的交叉工具链

期间,需要把win7中的文件,共享到VMware Workstation的虚拟机Ubuntu中。

【折腾过程】

1.去VMWare中,VM->Settings:

vmware vm settings

 

2.默认的文件共享:

Options->Shared Folders:

是关闭的:

default shared folders is disabled

去开启:

Always Enabled:

然后再去添加文件夹:

always enabled add next

3.

add host path and name

4.

added host path and name then next

5.

enable this share not read only

6.

added share folder then ok

7.然后进去Ubuntu中,看看能否看到和使用此共享。

结果直接出错:

unable to update run-time folder sharing status

看来需要重启Ubuntu才可以的。

8.重启后,进入Ubuntu,参考:

How do I mount shared folders (win7 host) in Ubuntu (guest) using VMware(tools v6)

但是在/mnt下没有看到希望的hgfs:

under mnt no hgfs

 

所以,再参考:

How to Share folders with your Ubuntu Virtual Machine (guest)

去看看vmhgfs是否安装了,结果没有:

crifan@ubuntu:/mnt$     lsmod | grep vmhgfs
crifan@ubuntu:/mnt$ lsmod
Module                  Size  Used by
acpiphp                23314  0 
rfcomm                 37420  0 
bnep                   17669  2 
bluetooth             202069  10 bnep,rfcomm
joydev                 17097  0 
coretemp               13131  0 
kvm_intel             126842  0 
kvm                   376505  1 kvm_intel
aesni_intel            18156  0 
aes_i586               16995  1 aesni_intel
xts                    12749  1 aesni_intel
lrw                    13057  1 aesni_intel
gf128mul               14503  2 lrw,xts
ablk_helper            13357  1 aesni_intel
cryptd                 15613  1 ablk_helper
ppdev                  12817  0 
snd_ens1371            24506  2 
snd_ac97_codec        105692  1 snd_ens1371
ac97_bus               12670  1 snd_ac97_codec
gameport               15016  1 snd_ens1371
parport_pc             27504  1 
snd_pcm                80890  2 snd_ac97_codec,snd_ens1371
snd_page_alloc         14230  1 snd_pcm
snd_seq_midi           13132  0 
snd_seq_midi_event     14475  1 snd_seq_midi
snd_rawmidi            25114  2 snd_ens1371,snd_seq_midi
snd_seq                51280  2 snd_seq_midi_event,snd_seq_midi
snd_seq_device         14137  3 snd_seq,snd_rawmidi,snd_seq_midi
snd_timer              24411  2 snd_pcm,snd_seq
mac_hid                13037  0 
snd                    56485  11 snd_ac97_codec,snd_timer,snd_pcm,snd_seq,snd_rawmidi,snd_ens1371,snd_seq_device
vmw_balloon            12593  0 
soundcore              12600  1 snd
vmwgfx                114653  3 
ttm                    71289  1 vmwgfx
psmouse                81038  0 
i2c_piix4              13066  0 
shpchp                 32129  0 
drm                   228750  4 ttm,vmwgfx
microcode              18286  0 
serio_raw              13031  0 
lp                     13299  0 
parport                40753  3 lp,ppdev,parport_pc
hid_generic            12484  0 
usbhid                 41805  0 
hid                    82666  2 hid_generic,usbhid
pcnet32                40598  0 
floppy                 55441  0 
mptspi                 22145  2 
mptscsih               39113  1 mptspi
mptbase                96272  2 mptspi,mptscsih
vmw_pvscsi             22006  0 
vmxnet3                43948  0 
crifan@ubuntu:/mnt$ 

9.所以去手动insmod试试,结果根本没此模块:

crifan@ubuntu:/mnt$ modprobe vmhgfs
FATAL: Module vmhgfs not found.

10.所以,只能参考:

Install VMware Tools on Ubuntu Edgy Eft

再去安装vmware tools:

大事却看到是已经安装过的,所以显示uninstall:

but see reinstall vmware tools

11.但是参考之前的帖子,是可以看到共享的文件夹的:

crifan@ubuntu:/mnt$ vmware-hgfsclient
crosstool_ng_src

但是接下来去尝试弄pl脚本,结果太麻烦:

crifan@ubuntu:/mnt$ sudo vmware-config-tools.pl 
Initializing...


Making sure services for VMware Tools are stopped.

vmware-tools stop/waiting


[EXPERIMENTAL] The VMware FileSystem Sync Driver (vmsync) is a new feature that
creates backups of virtual machines. Please refer to the VMware Knowledge Base 
for more details on this capability. Do you wish to enable this feature? 
[no] 


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 "/usr/bin/gcc".
The path "/usr/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.8.0-19-generic kernel headers.
Would you like to change it? [yes] 

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? 

The path "" is not a valid path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes] 

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? 

The path "" is not a valid path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes] 

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? 

The path "" is not a valid path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes] 

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? 

The path "" is not a valid path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes] 

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? ^C
Execution aborted.

crifan@ubuntu:/mnt$ ^C
crifan@ubuntu:/mnt$ ^C
crifan@ubuntu:/mnt$ gksu gedit /etc/fstab
The program 'gksu' is currently not installed. You can install it by typing:
sudo apt-get install gksu
crifan@ubuntu:/mnt$ 

12.还是去试试别人的:

No /mnt/hgfs in Ubuntu guest under VMWare Fusion

就可以了:

crifan@ubuntu:/mnt$ sudo apt-get install open-vm-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  dkms ethtool fakeroot libdumbnet1 open-vm-dkms zerofree
Suggested packages:
  dpkg-dev debhelper open-vm-toolbox
The following NEW packages will be installed:
  dkms ethtool fakeroot libdumbnet1 open-vm-dkms open-vm-tools zerofree
0 upgraded, 7 newly installed, 0 to remove and 198 not upgraded.
Need to get 1,141 kB of archives.
After this operation, 9,508 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main dkms all 2.2.0.3-1.1ubuntu2 [72.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ raring/main ethtool i386 1:3.4.2-1 [98.3 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ raring/main ethtool i386 1:3.4.2-1 [98.3 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ raring/main fakeroot i386 1.18.4-2ubuntu1 [89.0 kB]
Err http://us.archive.ubuntu.com/ubuntu/ raring/main fakeroot i386 1.18.4-2ubuntu1
  Connection failed [IP: 91.189.91.14 80]
Get:5 http://us.archive.ubuntu.com/ubuntu/ raring/universe libdumbnet1 i386 1.12-3.1 [30.7 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ raring/multiverse open-vm-dkms all 2012.12.26-958366-0ubuntu3 [394 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ raring/multiverse open-vm-dkms all 2012.12.26-958366-0ubuntu3 [394 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ raring/multiverse open-vm-tools i386 2012.12.26-958366-0ubuntu3 [448 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ raring/universe zerofree i386 1.0.2-1ubuntu1 [8,574 B]
Fetched 954 kB in 11min 38s (1,366 B/s)                                        
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/f/fakeroot/fakeroot_1.18.4-2ubuntu1_i386.deb  Connection failed [IP: 91.189.91.14 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
crifan@ubuntu:/mnt$ sudo apt-get install open-vm-tools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  dkms ethtool fakeroot libdumbnet1 open-vm-dkms zerofree
Suggested packages:
  dpkg-dev debhelper open-vm-toolbox
The following NEW packages will be installed:
  dkms ethtool fakeroot libdumbnet1 open-vm-dkms open-vm-tools zerofree
0 upgraded, 7 newly installed, 0 to remove and 198 not upgraded.
Need to get 89.0 kB/1,141 kB of archives.
After this operation, 9,508 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main fakeroot i386 1.18.4-2ubuntu1 [89.0 kB]
Fetched 41.1 kB in 1s (33.7 kB/s)                      
Selecting previously unselected package dkms.
(Reading database ... 155956 files and directories currently installed.)
Unpacking dkms (from .../dkms_2.2.0.3-1.1ubuntu2_all.deb) ...
Selecting previously unselected package ethtool.
Unpacking ethtool (from .../ethtool_1%3a3.4.2-1_i386.deb) ...
Selecting previously unselected package fakeroot.
Unpacking fakeroot (from .../fakeroot_1.18.4-2ubuntu1_i386.deb) ...
Selecting previously unselected package libdumbnet1.
Unpacking libdumbnet1 (from .../libdumbnet1_1.12-3.1_i386.deb) ...
Selecting previously unselected package open-vm-dkms.
Unpacking open-vm-dkms (from .../open-vm-dkms_2012.12.26-958366-0ubuntu3_all.deb) ...
Selecting previously unselected package open-vm-tools.
Unpacking open-vm-tools (from .../open-vm-tools_2012.12.26-958366-0ubuntu3_i386.deb) ...
Selecting previously unselected package zerofree.
Unpacking zerofree (from .../zerofree_1.0.2-1ubuntu1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up dkms (2.2.0.3-1.1ubuntu2) ...
Setting up ethtool (1:3.4.2-1) ...
Setting up fakeroot (1.18.4-2ubuntu1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libdumbnet1 (1.12-3.1) ...
Setting up open-vm-dkms (2012.12.26-958366-0ubuntu3) ...
Loading new open-vm-tools-2012.12.26 DKMS files...
First Installation: checking all kernels...
Building only for 3.8.0-19-generic
Building for architecture i686
Building initial module for 3.8.0-19-generic
Done.

vmblock:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.8.0-19-generic/updates/dkms/

vmci.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.8.0-19-generic/updates/dkms/

vmhgfs.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.8.0-19-generic/updates/dkms/

vmxnet.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.8.0-19-generic/updates/dkms/

vsock.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.8.0-19-generic/updates/dkms/

depmod....

DKMS: install completed.
Setting up open-vm-tools (2012.12.26-958366-0ubuntu3) ...

Configuration file `/etc/vmware-tools/suspend-vm-default'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** suspend-vm-default (Y/I/N/O/D/Z) [default=N] ? 

Configuration file `/etc/vmware-tools/poweron-vm-default'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** poweron-vm-default (Y/I/N/O/D/Z) [default=N] ? 

Configuration file `/etc/vmware-tools/scripts/vmware/network'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** network (Y/I/N/O/D/Z) [default=N] ? 

Configuration file `/etc/vmware-tools/resume-vm-default'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** resume-vm-default (Y/I/N/O/D/Z) [default=N] ? 

Configuration file `/etc/vmware-tools/statechange.subr'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** statechange.subr (Y/I/N/O/D/Z) [default=N] ? 

Configuration file `/etc/vmware-tools/poweroff-vm-default'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** poweroff-vm-default (Y/I/N/O/D/Z) [default=N] ? 
update-initramfs: deferring update (trigger activated)
 * Loading open-vm-tools modules                                         [ OK ] 
 * Remove pcnet32 module, if vmxnet is loaded                            [ OK ] 
 * Starting open-vm daemon vmtoolsd                                      [ OK ] 
Setting up zerofree (1.0.2-1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for ureadahead ...
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.8.0-19-generic
crifan@ubuntu:/mnt$ sudo mkdir /mnt/hgfs
crifan@ubuntu:/mnt$ sudo mout -t vmhgfs .host:/ /mnt/hgfs
sudo: mout: command not found
crifan@ubuntu:/mnt$ sudo mount -t vmhgfs .host:/ /mnt/hgfs
crifan@ubuntu:/mnt$ ls /mnt/hgfs/ -l
total 4
drwxrwxrwx 1 root root 8192 Jul 31 01:58 crosstool_ng_src
crifan@ubuntu:/mnt$ ll /mnt/hgfs/crosstool_ng_src/
total 232564
drwxrwxrwx 1 root root     8192 Jul 31 01:58 ./
dr-xr-xr-x 1 root root     4192 Aug  7 02:39 ../
-rwxrwxrwx 1 root root 17506655 Jul 23 01:00 binutils-2.20.tar.bz2*
-rwxrwxrwx 1 root root 19973532 Jul 23 00:00 binutils-2.22.tar.bz2*
-rwxrwxrwx 1 root root   772737 Jul 24 22:44 cloog-ppl-0.15.11.tar.gz*
-rwxrwxrwx 1 root root   572629 Jul 23 00:21 dmalloc-5.5.2.tar.bz2*
-rwxrwxrwx 1 root root   343078 Jul 23 02:45 expat-2.0.1.tar.bz2*
-rwxrwxrwx 1 root root   446456 Jul 23 02:40 expat-2.0.1.tar.gz*
-rwxrwxrwx 1 root root   562616 Jul 24 01:33 expat-2.1.0.tar.gz*
-rwxrwxrwx 1 root root 44144408 Jul 24 01:25 gcc-4.2.2.tar.bz2*
-rwxrwxrwx 1 root root 62944934 Jul 23 00:14 gcc-4.4.3.tar.bz2*
-rwxrwxrwx 1 root root 63135296 Jul 24 22:22 gcc-4.4.6.tar.bz2*
-rwxrwxrwx 1 root root 71579535 Jul 25 02:38 gcc-4.6.0.tar.bz2*
-rwxrwxrwx 1 root root 15981190 Jul 24 01:28 gdb-6.8a.tar.bz2*
-rwxrwxrwx 1 root root 15581509 Jul 23 00:22 gdb-6.8.tar.bz2*
-rwxrwxrwx 1 root root 16079568 Jul 23 00:15 glibc-2.9.tar.bz2*
-rw-rw-rw- 1 root root   457264 Jul 23 01:03 glibc-ports-2.9.tar.bz2
-rwxrwxrwx 1 root root  1897483 Jul 23 00:22 gmp-4.3.2.tar.bz2*
-rwxrwxrwx 1 root root  2024576 Jul 24 22:25 gmp-5.0.2.tar.bz2*
-rw-rw-rw- 1 root root   148529 Nov  1  2009 libelf-0.8.13.tar.gz
-rwxrwxrwx 1 root root 48412492 Nov 20  2012 linux-2.6.19.1.tar.bz2*
-rwxrwxrwx 1 root root 70277083 Jul 23 00:08 linux-2.6.36.tar.bz2*
-rw-rw-rw- 1 root root   147198 Jul 25  2009 ltrace_0.5.3.orig.tar.gz
-rw-rw-rw- 1 root root  1151445 Mar 31  2006 make-3.81.tar.bz2
-rw-rw-rw- 1 root root   565953 Feb 21  2011 mpc-0.9.tar.gz
-rwxrwxrwx 1 root root  1077886 Jul 23 00:23 mpfr-2.4.2.tar.bz2*
-rw-rw-rw- 1 root root  1083128 Oct  3  2011 mpfr-3.1.0.tar.xz
-rwxrwxrwx 1 root root  1276843 Jul 23 02:16 ncurses-5.7.tar.bz2*
-rwxrwxrwx 1 root root  2445052 Jul 23 01:41 ncurses-5.7.tar.gz*
-rwxrwxrwx 1 root root  2826473 Jul 24 01:30 ncurses-5.9.tar.gz*
-rwxrwxrwx 1 root root 12348525 Jul 24 22:37 ppl-0.11.2.tar.bz2*
-rwxrwxrwx 1 root root   499565 Jul 23 00:18 strace-4.5.19.tar.bz2*
crifan@ubuntu:/mnt$ 

 

【总结】

1. 第一次安装Ubuntu的时候:

【记录】VMWare Workstation 8中安装刚创建和配置好的Ubuntu 13.04虚拟机

就已经看到有安装VMWare Tools了

2.本以为此处只需要去开启文件共享,然后直接添加文件夹即可。

设置好共享文件夹后。

3.结果出错,/mnt下,找不到hgfs文件夹。

后来是用如下命令,解决的:

sudo apt-get install open-vm-tools
sudo mkdir /mnt/hgfs
sudo mount -t vmhgfs .host:/ /mnt/hgfs

转载请注明:在路上 » 【记录】VMWare Workstation中实现Win7和Ubuntu虚拟机之间的文件共享

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.178 seconds, using 22.65MB memory