VMware 16+Ubuntu 22安装VMwareTools

admin 2022年9月23日14:01:10评论54 views字数 3646阅读12分9秒阅读模式
创建: 2022-09-22 16:20
更新: 2022-09-22 22:13
http://scz.617.cn:8/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 <power|resume|suspend|shutdown> <subcommand> [args]

Subcommands:
   enableenable the given script and restore its path to the default
   disabledisable the given script
   set <full_path>: 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"。

原文始发于微信公众号(青衣十三楼飞花堂):VMware 16+Ubuntu 22安装VMwareTools

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年9月23日14:01:10
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   VMware 16+Ubuntu 22安装VMwareToolshttp://cn-sec.com/archives/1312224.html

发表评论

匿名网友 填写信息