win7与Ubuntu共享文件夹的详细方法

步骤:

1.安装VMware tools

2.设置共享文件夹

3.在Ubuntu中设置。


在网上搜集前辈的总结,自己边实践。

期间遇到菜鸟问题:文件名带空格怎么办:在空格前加“\”,即"\ "代表一个空格,”\ \ “代表两个空格。

在最后安装VMware tools时,安装命令提示符【】中的”yes“或者”no“操作即可,一直到最后的Enjoy,initial done。



之前使用Linux环境使用的是Fodera + VMware,个人感觉还是比较好用,比Red Hat 或之后的N多版本都好用。由于各种原因,现在需要使用Ubuntu + VMware环境,这就牵涉到Windows 和 Ubuntu 共享的问题。试了N多种方法行的通,参考《win7与VMware ubuntu虚拟机实现文件共享(最后一定要装open-vm-dkms插件)》才行的通。下面总结如下:
    1.按照VMtools.
    启动Ubuntu系统,在VMware虚拟机界面下,点击VM->Install VMware Tools,点击Ubuntu窗口中主文件按钮然后再左边会看见设备里有VMware tools文件夹,双击之,并且解压其中的压缩文件,把它拷贝到主文件夹。打开Terminal终端,进入解压的文件夹中,输入以下命令:
           a) sudo tar zxf VMwareTools-xxx.tar.gz (注:xxx为版本号)
           b) cd /vmware-tools-distrib
           c) sudo ./vmware-install.pl
  安装过程中一直按enter即可,或者输入【】提示yes和no,直到安装完毕。
  实在搞不定,可百度或Google之。

    2.设置共享文件夹目录
        1. 将Ubuntu关机(power off),否则不能添加共享文件夹
        2. 在VMware虚拟机窗口,选择VM->Settings->Options->Shared Folders
        3. 点右边的Add,点Next->选择Win7共享目录的路径,然后点Next->选中Enable this share->Finish
        4. 在VM->Settings->Options->Shared Folders窗口的右边,Folder sharing栏里选择Always enabled
        5. 点 OK 确定退出
        但在这里还没有完成,一点要进行第三步才可以完成文件共享。

    3.在Ubuntu虚拟机下安装插件
        1. 执行 sudo apt-get install open-vm-dkms (注:如果安装过,以后就不用执行这一行)
        2. 执行 sudo mount -t vmhgfs .host:/ /mnt/hgfs
        3. cd /mnt/hgfs



VMware Tools的安装,VM官网:

对于 Linux 虚拟机,您可以使用命令行工具手动安装或升级 VMware Tools。

开启虚拟机。

确认客户机操作系统正在运行。

由于 VMware Tools 安装程序是使用 Perl 编写的,因此,请确认在客户机操作系统中安装了 Perl。

1

在主机上,从 Workstation Pro 菜单栏中选择虚拟机 > 安装 VMware Tools

如果安装了早期版本的 VMware Tools,则菜单项是更新 VMware Tools

2

在虚拟机中,以 root 身份登录到客户机操作系统并打开终端窗口。

3

不带参数运行 mount 命令以确定 Linux 发行版是否自动装载 VMware Tools 虚拟 CD-ROM 映像。

如果装载了 CD-ROM 设备,将按以下方式列出 CD-ROM 设备及其装载点:

/dev/cdrom on /mnt/cdrom type iso9660 (ro,nosuid,nodev)
4

如果未装载 VMware Tools 虚拟 CD-ROM 映像,请装载 CD-ROM 驱动器。

a

如果装载点目录尚不存在,请创建该目录。

mkdir /mnt/cdrom

某些 Linux 发行版使用不同的装载点名称。例如,某些发行版上的装载点是 /media/VMware Tools 而不是 /mnt/cdrom。请修改该命令以反映您的发行版使用的约定。

b

装载 CD-ROM 驱动器。

mount /dev/cdrom /mnt/cdrom

某些 Linux 发行版使用不同的设备名称,或者以不同的方式组织 /dev 目录。如果 CD-ROM 驱动器不是 /dev/cdrom 或 CD-ROM 装载点不是/mnt/cdrom,则必须修改该命令以反映您的发行版使用的约定。

5

转到工作目录,例如 /tmp

cd /tmp

6

在安装 VMware Tools 之前,删除以前的 vmware-tools-distrib 目录。

该目录的位置取决于以前安装时的存储位置。通常,该目录位于 /tmp/vmware-tools-distrib

7

列出装载点目录的内容,并记下 VMware Tools tar 安装程序的文件名。

ls mount-point
8

解压缩安装程序。

tar zxpf /mnt/cdrom/VMwareTools-x.x.x-yyyy.tar.gz

x.x.x 值是产品版本号,yyyy 是产品版本的内部版本号。

如果尝试安装 tar 安装以覆盖 RPM 安装或相反,安装程序将检测以前的安装并且必须转换安装程序数据库格式,然后才能继续操作。

9

如果需要,请卸载 CD-ROM 映像。

umount /dev/cdrom 

如果 Linux 发行版自动装载 CD-ROM,则不需要卸载该映像。

10

运行安装程序并配置 VMware Tools。

cd vmware-tools-distrib
./vmware-install.pl

通常,在安装程序文件结束运行后,将运行 vmware-config-tools.pl 配置文件。

11

如果适合您的配置,请按照提示接受默认值。

12

按照脚本结尾处的说明进行操作。

根据使用的功能,这些说明可能包括重新启动 X 将话、重新启动网络连接、重新登录以及启动 VMware 用户进程。或者,也可以重新引导客户机操作系统以完成所有这些任务。

如果虚拟机具有新的虚拟硬件版本,请升级虚拟硬件。




下面是我自己探索安装的过程:


wade@ubuntu:~$ sudo -i
[sudo] password for wade:
root@ubuntu:~# cd /home
root@ubuntu:/home# cd.
No command 'cd.' found, did you mean:
 Command 'cdp' from package 'irpas' (multiverse)
 Command 'cdi' from package 'cdo' (universe)
 Command 'cdo' from package 'cdo' (universe)
 Command 'cdb' from package 'tinycdb' (main)
 Command 'cd5' from package 'cd5' (universe)
 Command 'cdw' from package 'cdw' (universe)
 Command 'cde' from package 'cde' (universe)
 Command 'cdv' from package 'codeville' (universe)
cd.: command not found
root@ubuntu:/home# cd ..
root@ubuntu:/# cd /home/templates
-bash: cd: /home/templates: No such file or directory
root@ubuntu:/# cd /Home/Templates
-bash: cd: /Home/Templates: No such file or directory
root@ubuntu:/# cd /Home
-bash: cd: /Home: No such file or directory
root@ubuntu:/# cd /home
root@ubuntu:/home# ls
wade
root@ubuntu:/home# cd /wade
-bash: cd: /wade: No such file or directory
root@ubuntu:/home# cd /wade
-bash: cd: /wade: No such file or directory
root@ubuntu:/home# cd ..
root@ubuntu:/# ls
bin    dev   initrd.img  lost+found  opt   run   srv  usr
boot   etc   lib         media       proc  sbin  sys  var
cdrom  home  lib64       mnt         root  snap  tmp  vmlinuz
root@ubuntu:/# cd /tmp
root@ubuntu:/tmp# ls
config-err-rYu2ek
systemd-private-0799a101a7a042798c751f5215208d02-colord.service-fuDjIL
systemd-private-0799a101a7a042798c751f5215208d02-rtkit-daemon.service-JQ3JjX
systemd-private-0799a101a7a042798c751f5215208d02-systemd-timesyncd.service-mZNX1l
unity_support_test.0
VMwareDnD
vmware-root
root@ubuntu:/tmp# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=996040k,nr_inodes=249010,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=203072k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-

cgroups-agent,name=systemd,nsroot=/)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,nsroot=/)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct,nsroot=/)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio,nsroot=/)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory,nsroot=/)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,nsroot=/)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer,nsroot=/)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event,nsroot=/)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids,nsroot=/)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb,nsroot=/)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices,nsroot=/)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
vmware-vmblock on /run/vmblock-fuse type fuse.vmware-vmblock

(rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=203072k,mode=700,uid=1000,gid=1000)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
/dev/sr0 on /media/wade/VMware Tools type iso9660

(ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
root@ubuntu:/tmp# tar zxpf /media/wade/VMware Tools.tar.gz
tar (child): /media/wade/VMware: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
root@ubuntu:/tmp# tar /media/wade/VMware Tools.tar.gz
tar: invalid option -- '/'
Try 'tar --help' or 'tar --usage' for more information.
root@ubuntu:/tmp# tar /media/wade/VMware\ Tools.tar.gz
tar: Old option 'V' requires an argument.
Try 'tar --help' or 'tar --usage' for more information.
root@ubuntu:/tmp#
root@ubuntu:/tmp# tar zxpf /media/wade/VMware\ Tools.tar.gz
tar (child): /media/wade/VMware Tools.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
root@ubuntu:/tmp# tar zxpf /media/wade/VMware\ Tools
tar (child): /media/wade/VMware Tools: Cannot read: Is a directory
tar (child): At beginning of tape, quitting now
tar (child): Error is not recoverable: exiting now

gzip: stdin: unexpected end of file
tar: Child returned status 2
tar: Error is not recoverable: exiting now
root@ubuntu:/tmp# cd /media/wade/VMware\ Tools
root@ubuntu:/media/wade/VMware Tools#
root@ubuntu:/media/wade/VMware Tools# cd ~
root@ubuntu:~# cd /wade/tmp
-bash: cd: /wade/tmp: No such file or directory
root@ubuntu:~# ls
root@ubuntu:~# ls
root@ubuntu:~# cd /honme
-bash: cd: /honme: No such file or directory
root@ubuntu:~# cd /home
root@ubuntu:/home# ls
wade
root@ubuntu:/home# cd /wade
-bash: cd: /wade: No such file or directory
root@ubuntu:/home# cd wade
root@ubuntu:/home/wade# ls
Desktop  Documents  Downloads  examples.desktop  Music  Pictures  Public  Templates  Videos
root@ubuntu:/home/wade# cd ~
root@ubuntu:~# cd ..
root@ubuntu:/# ls
bin   cdrom  etc   initrd.img  lib64       media  opt   root  sbin  srv  tmp  var
boot  dev    home  lib         lost+found  mnt    proc  run   snap  sys  usr  vmlinuz
root@ubuntu:/# cd tmp
root@ubuntu:/tmp# ls
config-err-rYu2ek                                                                  unity_support_test.0
systemd-private-0799a101a7a042798c751f5215208d02-colord.service-fuDjIL             VMwareDnD
systemd-private-0799a101a7a042798c751f5215208d02-rtkit-daemon.service-JQ3JjX       vmware-root
systemd-private-0799a101a7a042798c751f5215208d02-systemd-timesyncd.service-mZNX1l
root@ubuntu:/tmp# cd /home
root@ubuntu:/home# cd wade
root@ubuntu:/home/wade# ls
Desktop  Documents  Downloads  examples.desktop  Music  Pictures  Public  Templates  Videos
root@ubuntu:/home/wade# cd documents
-bash: cd: documents: No such file or directory
root@ubuntu:/home/wade# cd Documents
root@ubuntu:/home/wade/Documents# cd qijitao_tmp
-bash: cd: qijitao_tmp: No such file or directory
root@ubuntu:/home/wade/Documents# cd ..
root@ubuntu:/home/wade# ls
Desktop  Documents  Downloads  examples.desktop  Music  Pictures  Public  Templates  Videos
root@ubuntu:/home/wade# cd /Downloads/qijitao_tmp
-bash: cd: /Downloads/qijitao_tmp: No such file or directory
root@ubuntu:/home/wade# cd Downloads
root@ubuntu:/home/wade/Downloads# ls
qjitao_tmp  sogoupinyin_2.1.0.0082_amd64.deb
root@ubuntu:/home/wade/Downloads# ls
qijitao_tmp  sogoupinyin_2.1.0.0082_amd64.deb
root@ubuntu:/home/wade/Downloads# cd qijitao_tmp
root@ubuntu:/home/wade/Downloads/qijitao_tmp# tar zxpf /media/wade/VMware\ Tools/VMwareTools-10.0.10-4301679.tar.gz
root@ubuntu:/home/wade/Downloads/qijitao_tmp# cd vmware-tools-distrib
root@ubuntu:/home/wade/Downloads/qijitao_tmp/vmware-tools-distrib# cd vmware-install.pl
-bash: cd: vmware-install.pl: Not a directory
root@ubuntu:/home/wade/Downloads/qijitao_tmp/vmware-tools-distrib# ./vmware-install.pl
The installer has detected an existing installation of open-vm-tools 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 and attempt to install 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] yes

Creating a new VMware Tools installer database using the tar4 format.

Installing VMware Tools.

In which directory do you want to install the binary files?
[/usr/bin] yes

The path "yes" is a relative path. Please enter an absolute path.

In which directory do you want to install the binary files?
[/usr/bin] y

The path "y" is a relative path. Please enter an absolute path.

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]

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


The installation of VMware Tools 10.0.10 build-4301679 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] yes

The file /usr/bin/vmware-hgfsclient that this program was about to install
already exists.  Overwrite? [no] no

The file /usr/bin/vmhgfs-fuse that this program was about to install already
exists.  Overwrite? [no] no

The file /sbin/mount.vmhgfs that this program was about to install already
exists.  Overwrite? [no] no

Initializing...


Making sure services for VMware Tools are stopped.

Stopping Thinprint services in the virtual machine:
   Stopping Virtual Printing daemon:                                   done
Stopping VMware Tools services in the virtual machine:
   VMware User Agent (vmware-user):                                    done
   Unmounting HGFS shares:                                             done
   Guest filesystem driver:                                            done


update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
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] yes

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

Thinprint provides driver-free printing. Do you wish to enable this feature?
[yes] yes

Creating a new initrd boot image for the kernel.
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic
   Starting Virtual Printing daemon:                                   done
   Checking acpi hot plug                                              done
Starting VMware Tools services in the virtual machine:
   Switching to guest configuration:                                   done
   Guest filesystem driver:                                            done
   Mounting HGFS shares:                                               done
   VMware User Agent:                                                  done
The configuration of VMware Tools 10.0.10 build-4301679 for Linux for this
running kernel completed successfully.

Enjoy,

--the VMware team

Found VMware Tools CDROM mounted at /media/wade/VMware Tools. Ejecting device
/dev/sr0 ...
umount: /media/wade/VMware Tools: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
/usr/bin/eject: unmount of `/media/wade/VMware Tools' failed
Eject Failed:  If possible manually eject the Tools installer from the guest
cdrom mounted at /media/wade/VMware Tools before canceling tools install on the
host.
root@ubuntu:/home/wade/Downloads/qijitao_tmp/vmware-tools-distrib# cd /mnt/hgfs
root@ubuntu:/mnt/hgfs# ls
VM_ubantu_share
root@ubuntu:/mnt/hgfs#




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu共享文件夹的设置有几个步骤。首先,右键点击虚拟机窗口,选择"设置"。在设置窗口中,选择"共享文件夹"选项,并将其设置为"总是启用"。接下来,点击"添加"按钮或修改属性,选择要共享Windows电脑上的文件夹,并点击"确定"。 如果在重启虚拟机后发现共享文件夹在/mnt/hgfs路径下无法找到,可以执行以下命令来重新使用共享文件夹:sudo vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other。这个命令会重新将主机目录和虚拟机目录联系起来,使共享文件夹再次可用。 如果在/mnt/hgfs路径下找不到mnt和hgfs文件夹,可以尝试重新安装VMware Tools。首先,取消对共享文件夹的挂载,然后将压缩包拷贝到其他目录下并解压安装。如果所有操作都正确但是还是无法在hgfs下找到共享文件夹,可以尝试重新启动虚拟机。 请确保按照上述步骤操作,并参考适用于VMware虚拟机的Ubuntu设置共享文件夹的相关资料。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Ubuntu共享文件夹设置](https://blog.csdn.net/SkyGloaming/article/details/120518021)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [VMware虚拟机Ubuntu共享文件夹](https://blog.csdn.net/qq_16763983/article/details/121086240)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值