VMware 共享文件夹未显示在 Ubuntu 客户机上

VMware 共享文件夹未显示在 Ubuntu 客户机上

我在 Windows 10 上测试 VMware Workstation Pro 16,客户机是安装了 VMware Tools 的 Ubuntu 22.04 LTS。

我在 的上下文中配置了一个共享文件夹VM > Settings;但是,它没有出现在客户虚拟机的 目录中/mnt/

如果您需要更多详细信息,请告诉我,我非常感谢任何提示或建议。

有关设置的更多细节:

此 YouTube 视频是关于 VMware Player 的。因此,我尝试了 VMware Workstation Pro 和 VMware Player 上的设置,结果相同,不起作用。我的步骤是:

  • 在上下文“VMware Workstation > VM > 设置 > 选项 > 共享文件夹”中,将目标文件夹配置为“始终启用”。
  • 启动客户虚拟机。
  • 在客户虚拟机上,查找目录中的共享文件夹/mnt/hgfs/my-shared-folder/,但它没有按照帖子中描述的那样工作。

在我的例子中,该命令vmware-hgfsclient知道共享文件夹,但目录/mnt/是空的,并且没有/mnt/hgfs/。有关更多详细信息,请参阅下面的屏幕截图。

截屏:

root@ubuntu:/home/work/Desktop# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy
root@ubuntu:/home/work/Desktop# vmware-toolbox-cmd -v
11.3.5.31214 (build-18557794)
root@ubuntu:/home/work/Desktop# vmware-hgfsclient
my-shared-folder
root@ubuntu:/home/work/Desktop# ll /mnt/
total 8
drwxr-xr-x  2 root root 4096 Apr 19 04:02 ./
drwxr-xr-x 20 root root 4096 May 21 14:14 ../
root@ubuntu:/home/work/Desktop# 

答案1

您的计算机上似乎mnt-hgfs.mount尚未运行系统服务。该服务必须正在运行 --- 您的共享文件夹必须出现在/mnt/hgfs--- 中,然后您才能尝试将共享文件夹挂载到其他任何地方。请按照以下步骤操作(详见https://kb.vmware.com/s/article/74650):

  • 填充/etc/systemd/system/mnt-hgfs.mount
[Unit]
Description=VMware mount for hgfs
DefaultDependencies=no
Before=umount.target
ConditionVirtualization=vmware
After=sys-fs-fuse-connections.mount

[Mount]
What=vmhgfs-fuse
Where=/mnt/hgfs
Type=fuse
Options=default_permissions,allow_other

[Install]
WantedBy=multi-user.target
  • 无论是否/etc/modules-load.d/open-vm-tools.conf存在,请添加此行:
fuse
  • 启用系统mnt-hgfs.mount服务
sudo systemctl enable mnt-hgfs.mount # so that mount happens after reboot  
  • 如果尚未完成,请在您的机器的 VMware 选项卡中 > 设置 > 设置 > 选项 > 共享文件夹 >(填写主机路径和名称的信息)
  • 启动服务
sudo systemctl start mnt-hgfs.mount

然后,在您想要的共享文件夹出现后,/mnt/hgfs/您可以尝试通过 将它们自动启动挂载到其他地方/etc/fstab,或者将其应用于它们vmhgfs-fuse

答案2

VMware 共享文件夹可与 Windows 客户机配合使用。我尚未让它们在 Linux 客户机上立即运行。

尝试一下这篇文章,看看是否有帮助。

VMware 共享文件夹

我在 Windows 11 上安装了 VMware V16 Pro,并安装了 Ubuntu 22.04 客户机。

我使用了两种前进方式(两种方法)。

(1)从 Ubuntu 到 Windows 的 SMB。这是最简单的,因为 Windows 默认有 SMB。

在 Linux 中:smb://192.168.xy/folder/ 并进行身份验证。

(2)在 Ubuntu 中安装 Samba。我也这样做了。配置它,然后使用文件资源管理器在 Windows 中映射 Ubuntu 驱动器。Samba 也可以正常工作。

这是安装 Samba 的教程

安装 Samba

1. Installing Samba

In the Linux machine, install Samba

sudo apt update
sudo apt install samba

Use  whereis samba to verify the install.


2. Setting up Samba


Make a directory to share:  mkdir /home/<username>/sambashare

Edit the smb.conf file:  sudo nano /etc/samba/smb.conf

Add the following lines at the bottom of the file:
    
    [sambashare}
    comment = Samba on Ubuntu
path = /home/<username>/sambashare
read only = no
    browsable = yes

    Ctrl-O to save and Ctrl-X to exit the editor
    
    Restart the samba service:   sudo service smd restart
    
    Update the firewall rules if necessary:  sudo ufw allow samba

    
Setting up User Accounts and Connecting to Share

sudo smbpasswd -a <username>   and password

(username must belong to a system account or it will not work)

In Linux:

smb://ip_address_of_Linux/sambashare

In Windows:

\\192.168.x.y where this is the IP of the Linux Machine

Authenticate with <username> and password

Shows as sambashare in Windows Explorer

答案3

在 VMware 网站上看到了这个解决方案:

  • 在虚拟机中打开 root shell
  • 确保 /mnt/hgfs 目录存在。如果不存在,请创建该目录。
  • 将以下行添加到 /etc/fstab: vmhgfs-fuse /mnt/hgfs fuse defaults,allow_other,_netdev 0 0
  • 然后重新启动虚拟机。共享文件夹现在应该出现在挂载点 /mnt/hgfs

相关内容