Skip to content

标题: VMware 16+Ubuntu 22安装VMwareTools

创建: 2022-09-22 16:20 更新: 2022-09-22 22:13 链接: https://scz.617.cn/unix/202209221620.txt

VMware Workstation 16.2.4,Guest是Ubuntu 22.04.1 LTS (Jammy Jellyfish)。现 需要安装VMwareTools,一是为显卡驱动,二是为hgfs。

VMwareTools变化比较大,不要再用VMware自带的iso安装了。我就犯了经验主义错误, 为了支持hgfs,总是源码编译vmhgfs.ko,一度以为open-vm-tools不包含hgfs的支持, 事实上是支持的。

这次一开始仍然习惯性地用iso安装VMwareTools,遭遇"Segmentation fault",排查 中才发现过去混用iso与open-vm-tools,是一种很low的搞法。只用open-vm-tools即 可,vmtoolsd属于open-vm-tools,vmtoolsd运行后桌面分辨率开始自适应,同时支 持hgfs。

参看


VMware support for open-vm-tools (2073803) https://kb.vmware.com/s/article/2073803

How to configure VMware Tools Shared Folders Linux mounts (60262) - [2018-11-27] https://kb.vmware.com/s/article/60262

https://github.com/vmware/open-vm-tools/issues/199

https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3

在Host中为Guest指定Shared Folders

Settings->Options->Shared Folders

安装两个包,重启使之生效

aptitude install open-vm-tools open-vm-tools-desktop reboot lsmod | grep vmw ps auwx | grep vm

$ vmware-toolbox-cmd -v 11.3.5.31214 (build-18557794)

$ vmhgfs-fuse --version vmhgfs-fuse: version 1.6.12.0 FUSE library version 3.10.5 using FUSE kernel interface version 7.31 fusermount3 version: 3.10.5

$ vmhgfs-fuse --enabled vmhgfs-fuse: 0 - HGFS FUSE client enabled

$ vmware-hgfsclient * share

share是GUI中指定的"Shared Folders"名字,若上述命令能看到share,表示hgfs底 层支持已经就位。

如下命令均可手动mount hgfs

mkdir /mnt/hgfs

vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=1000 vmhgfs-fuse -o subtype=vmhgfs-fuse,allow_other /mnt/hgfs mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other

umount /mnt/hgfs

可在/etc/fstab中增加一行,以便自动mount,比如


.host:/ /mnt/hgfs/ fuse.vmhgfs-fuse defaults,allow_other,uid=1000 0 0

.host:/ /mnt/hgfs/ fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,umask=0002,auto_unmount,defaults 0 0

若不幸用VMware自带的iso安装,可能遭遇"Segmentation fault",此时可回滚

/root/src/vmware/vmware-tools-distrib/bin/vmware-uninstall-tools.pl apt-get purge --auto-remove open-vm-tools rm -rf /etc/vmware-tools/ rm -rf /usr/lib/vmware-tools/

再重新安装open-vm-tools*

aptitude install open-vm-tools open-vm-tools-desktop

查看这两个包都安装了些啥

dpkg -L open-vm-tools dpkg -L open-vm-tools-desktop

启用时间同步

vmware-toolbox-cmd timesync enable

若启动、关闭Guest过程中Host弹框提示

The VMware Tools power-on script did not run successfully in this virtual machine. If you have configured a custom power-on script in this virtual machine, make sure that it contains no errors. You can also submit a support request to report this issue.

直接原因是/etc/vmware-tools/目录下的内容有问题,root cause很可能是卸载、重 装open-vm-tools过程中出幺蛾子了。一般按下列顺序操作即可解决

apt-get purge --auto-remove open-vm-tools reboot aptitude install open-vm-tools open-vm-tools-desktop shutdown -P now

若对这种脚本感兴趣,可以查看到底是哪个脚本

$ vmware-toolbox-cmd help script script: control the scripts run in response to power operations Usage: vmware-toolbox-cmd script [args]

Subcommands: enable: enable the given script and restore its path to the default disable: disable the given script set : set the given script to the given path default: print the default path of the given script current: print the current path of the given script NOTE: If the path is not present in tools.conf, its value from the global configuration is returned if present

$ vmware-toolbox-cmd script power current /etc/vmware-tools/poweron-vm-default

$ vmware-toolbox-cmd script shutdown current /etc/vmware-tools/poweroff-vm-default

在"VMware->VM->Power"菜单处,一般有

Power On Power Off Suspend Reset

若装了VMwareTools,此处会多出另外几项

Start Up Guest Shut Down Guest Suspend Guest Restart Guest

"Shut Down Guest"比"Power Off"要多做一些动作,会执行相应脚本,比如

/etc/vmware-tools/poweroff-vm-default

若用了"Suspend Guest",恢复时应该用配对的"Resume Guest",而非缺省的Resume, 前者涉及相应脚本,后者与脚本无关。条件允许时,尽量用"Suspend Guest"。