VMware (简体中文)

From ArchWiki
翻译状态:本文是 VMware翻译。上次翻译日期:2022-4-10。如果英文版本有所更改,则您可以帮助同步翻译。

Tango-preferences-desktop-locale.png本文或本节需要翻译。要贡献翻译,请访问简体中文翻译团队Tango-preferences-desktop-locale.png

附注: need translation(在 Talk:VMware (简体中文)# 中讨论)

本文介绍的是最新的主要 VMware 版本,意思是 VMware Workstation Pro 和 Player 16、15、14 和 12.5。

本文是关于在 Arch 中安装 VMware,你也许想寻找的是 在 VMware 中安装 Arch Linux

先决条件

1. 通过机器的 BIOS/UEFI 启用虚拟化

安装

您可以使用 VMware 捆绑包或软件包 vmware-workstationAUR 进行安装。 如果在 x86_64 上使VMware Workstation,则首选后者。

Note: 自版本 14 以来,VMware 已放弃对许多 CPU 的支持,包括早期的 Intel Core i7 CPU。请查看 Processor Requirements for Host Systems 。如果较新版本不支持您的 CPU,则可以使用 vmware-workstation12AUR.

VMware 捆绑包

Install 正确的依赖:

下载最新版的 VMware Workstation Pro 或者 Player (或者一个 beta 版本, 如果可用).

开始安装:

# sh VMware-edition-version.release.architecture.bundle
Tip: 一些有用的标志:
  • --eulas-agreed - Skip the EULAs
  • --console - Use the console UI.
  • --custom - Allows changing the install directory to e.g. /usr/local (make sure to update the vmware-usbarbitrator.service paths in #systemd services).
  • -I, --ignore-errors - Ignore fatal errors.
  • --set-setting=vmware-workstation serialNumber XXXXX-XXXXX-XXXXX-XXXXX-XXXXX - Set the serial number during install (good for scripted installs).
  • --required - Only ask mandatory questions (results in silent install when combined with --eulas-agreed and --console).

For the System service scripts directory, use /etc/init.d (the default).

Note: During the installation you will get an error about "No rc*.d style init script directories" being given. This can be safely ignored, since Arch uses systemd.
Tip: To (re)build the modules from terminal later on, use:
# vmware-modconfig --console --install-all

x86_64 的软件包构建

安装 vmware-workstationAURvmware-workstation15AURvmware-workstation14AURvmware-workstation12AURvmware-workstation11AUR 分别适用于VMware Workstation的版本 16、15、14、12 和 11。 还需要为已安装的内核安装适当的头文件包:例如 linux-headerslinux-lts-headers

Tip: 请检查当前的kernel version 是否被vmware-workstation支持,vmware-workstation-pro-16.1.0 支持到Linux5.8。经过测试能在Linux5.10中运行

然后,根据需要启用以下一些服务:

  • vmware-networks.service 用于访客网络访问(否则您将收到错误 could no connect 'ethernet 0' to virtual network 并且您将无法使用 vmware -netcfg
  • vmware-usbarbitrator.service 用于将 USB 设备连接到访客
  • vmware-hostd.service 用于共享虚拟机(从版本 16 起不可用)

最后,加载 VMware 模块:

# modprobe -a vmw_vmci vmmon

配置

内核模块

VMware Workstation 16.0 支持开箱即用的内核 5.8。 本文介绍的旧版本及其本机支持的内核如下:15.5(最高为 5.4 的内核)、14.1.7 (4.18) 和 12.5.9 (4.12)。 对于 VMware 捆绑包版本,可以从 [1] GitHub 存储库中找到针对最新内核构建 VMware 主机模块所需的补丁集合 . 有关 VMware Workstation 12.5.5 及更高版本的最新模块安装说明,请参阅存储库中的安装文档。

systemd services

(Optional) Instead of using /etc/init.d/vmware (start|stop|status|restart) and /usr/bin/vmware-usbarbitrator directly to manage the services, you may also use .service files (vmware-usbarbitrator and vmware-networks are also included vmware-workstationAUR with a few differences):

/etc/systemd/system/vmware.service
[Unit]
Description=VMware daemon
Requires=vmware-usbarbitrator.service
Before=vmware-usbarbitrator.service
After=network.target

[Service]
ExecStart=/etc/init.d/vmware start
ExecStop=/etc/init.d/vmware stop
PIDFile=/var/lock/subsys/vmware
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
/etc/systemd/system/vmware-usbarbitrator.service
[Unit]
Description=VMware USB Arbitrator
Requires=vmware.service
After=vmware.service

[Service]
ExecStart=/usr/bin/vmware-usbarbitrator
ExecStop=/usr/bin/vmware-usbarbitrator --kill
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Add this service to enable networking:

/etc/systemd/system/vmware-networks-server.service
[Unit]
Description=VMware Networks
Wants=vmware-networks-configuration.service
After=vmware-networks-configuration.service

[Service]
Type=forking
ExecStartPre=-/sbin/modprobe vmnet
ExecStart=/usr/bin/vmware-networks --start
ExecStop=/usr/bin/vmware-networks --stop

[Install]
WantedBy=multi-user.target

Add this service as well, if you want to connect to your VMware Workstation installation from another Workstation Server Console:

/etc/systemd/system/vmware-workstation-server.service
[Unit]
Description=VMware Workstation Server
Requires=vmware.service
After=vmware.service

[Service]
ExecStart=/etc/init.d/vmware-workstation-server start
ExecStop=/etc/init.d/vmware-workstation-server stop
PIDFile=/var/lock/subsys/vmware-workstation-server
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

After which you can enable them on boot.

Workstation Server service

The vmware-workstation-server.service calls wssc-adminTool in its command chain, despite having been renamed to vmware-wssc-adminTool.

To prevent the service startup, this can be fixed with a symlink:

# ln -s wssc-adminTool /usr/lib/vmware/bin/vmware-wssc-adminTool

Launching the application

To open VMware Workstation Pro:

$ vmware

or Player:

$ vmplayer

Tips and tricks

Entering the Workstation Pro license key

From terminal

# /usr/lib/vmware/bin/vmware-vmx-debug --new-sn XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Where XXXXX-XXXXX-XXXXX-XXXXX-XXXXX is your license key.

Note: The -debug binary informs the user of an incorrect license.

From GUI

If the above does not work, you can try:

# /usr/lib/vmware/bin/vmware-enter-serial

Extracting the VMware BIOS

$ objcopy /usr/lib/vmware/bin/vmware-vmx -O binary -j bios440 --set-section-flags bios440=a bios440.rom.Z
$ perl -e 'use Compress::Zlib; my $v; read STDIN, $v, '$(stat -c%s "./bios440.rom.Z")'; $v = uncompress($v); print $v;' < bios440.rom.Z > bios440.rom

Extracting the installer

To view the contents of the installer .bundle:

$ sh VMware-edition-version.release.architecture.bundle --extract /tmp/vmware-bundle/

Using the modified BIOS

If and when you decide to modify the extracted BIOS you can make your virtual machine use it by moving it to ~/vmware/Virtual_machine_name:

$ mv bios440.rom ~/vmware/Virtual_machine_name/

then adding the name to the Virtual_machine_name.vmx file:

~/vmware/Virtual_machine_name/Virtual_machine_name.vmx
bios440.filename = "bios440.rom"

Enable 3D graphics on Intel, Optimus and AMD

Some graphics drivers are blacklisted by default, due to poor and/or unstable 3D acceleration. After enabling Accelerate 3D graphics, the log may show something like:

Disabling 3D on this host due to presence of Mesa DRI driver.  Set mks.gl.allowBlacklistedDrivers = TRUE to override.

The configuration file where you can set this setting is ~/.vmware/preferences.

VMware Workstation 16.2 switched from OpenGL to Vulkan, so the setting is a bit different. If your driver is unsupported, you might see a message like this in the log:

mks Vulkan Renderer: Only the AMDVLK driver is supported at this time.
mks Vulkan Renderer: No supported Vulkan device/driver found (See mks.vk.allowUnsupportedDevices or mks.vk.forceDevice configuration options).

If your Vulkan driver is blacklisted, you might have to add mks.vk.allowUnsupportedDevices = "TRUE" to ~/.vmware/preferences or switch to a supported driver - check vmware.log in the VM's directory if unsure.

Note: You might need to add the mks.gl.allowBlacklistedDrivers = "TRUE" inside the .vmx file for the specific virtual machine as well, for 3D acceleration with intel drivers to be enabled.

Suspend virtual machines before host suspend/hibernate

Create an executable file /usr/lib/systemd/system-sleep/vmware_suspend_all.sh:

#! /bin/bash

set -eu

if [[ $# -ne 2 ]]; then
    echo "Usage: $0 <period> <action>"
    exit 1
fi

period=$1
action=$2

echo "vmware system-sleep hook argv: ${period} ${action}"

if ! command -v vmrun &>/dev/null; then
    echo "command not found: vmrun"
fi

if [[ "${period}" = "pre" ]]; then
    readarray -t vms < <(vmrun list | tail -n +2)

    echo "Number of running VMs: ${#vms[@]}"

    if [[ ${#vms[@]} -eq 0 ]]; then
        exit
    fi

    for vm in "${vms[@]}"; do
        echo -n "Suspending ${vm}... "
        vmrun suspend "${vm}"
        echo "done"
    done

    sleep 1
else
    echo "Nothing to do"
fi

See also Power management#Hooks in /usr/lib/systemd/system-sleep, suspend all virtual machines with vmrun and Support for hibernation.

System speedup tricks

See also Improving performance.

Disable transparent hugepages

Merge-arrows-2.pngThis article or section is a candidate for merging with Improving performance.Merge-arrows-2.png

Notes: Not specific to VMware. (Discuss in Talk:VMware (简体中文))

If you notice the guest and/or the host frequently freezing when running a VM, you may want to disable transparent hugepages. To disable them for the current session, run (on the host):

# echo never > /sys/kernel/mm/transparent_hugepage/enabled

To make the change persistent across boots, add the kernel parameter transparent_hugepage=never.

Ensure direct RAM access

By default, VMware writes a running guest system's RAM to a file on disk. If you are certain you have enough spare memory, you can ensure the guest OS writes its memory directly to the host's RAM by adding the following to the VM's .vmx:

Virtual_machine_name.vmx
MemTrimRate = "0"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
mainmem.backing = "swap"

Performance tips

To improve the performance of your virtual machine, try the following tips:

Paravirtual SCSI adapter

VMware Paravirtual SCSI (PVSCSI) adapters are high-performance storage adapters for VMware ESXi that can result in greater throughput and lower CPU utilization. PVSCSI adapters are best suited for environments, where hardware or applications drive a very high amount of I/O throughput.

The SCSI adapter type VMware Paravirtual is available in the Virtual Machine settings.

If these settings are not in the virtual machine's configuration, the paravirtual SCSI adapter can still be enabled. Ensure that the paravirtual SCSI adapter is included in the kernel image by modifying the mkinitcpio.conf:

/etc/mkinitcpio.conf
...
MODULES=(... vmw_pvscsi)
...

Regenerate the initramfs.

Shut down the virtual machine and change the SCSI adapter: set the .vmx to the following:

scsi0.virtualDev = "pvscsi"

Paravirtual network adapter

VMware offers multiple network adapters for the guest OS. The default adapter used is usually the e1000 adapter, which emulates an Intel 82545EM Gigabit Ethernet NIC. This Intel adapter is generally compatible with the built-in drivers across most operating systems, including Arch.

For more performance and additional features (such as multiqueue support), the VMware native vmxnet3 network adapter can be used.

Arch has the vmxnet3 kernel module available with a default install. Once enabled in mkinitcpio (or if it is auto-detected; check by running lsmod | grep vmxnet3 to see if it is loaded), shut down and change the network adapter type in the .vmx file to the following:

ethernet0.virtualDev = "vmxnet3"

After changing network adapters, the network and dhcpcd settings will need to be updated to use the new adapter name and MAC address.

# dhcpcd new_interface_name
# systemctl enable dhcpcd@new_interface_name.service

The new interface name can be obtained by running ip link.

Virtual machine settings

These settings could help improve the responsiveness of the virtual machine by reducing disk I/O, at the expense of using more host memory. Vmware's KB1008885 provides the following optimizations:

mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
prefvmx.useRecommendedLockedMemSize = "TRUE"
MemAllowAutoScaleDown = "FALSE"
sched.mem.pshare.enable = "FALSE"
  • mainMem.useNamedFile: This will only work for Windows hosts and this parameter can be used if high disk activity is experienced upon shutting down the virtual machine. This will prevent VMware from creating a .vmem file. Use mainmem.backing = "swap" on Linux hosts instead.
  • MemTrimRate: This setting prevents that memory which was released by the guest is released on the host also.
  • prefvmx.useRecommendedLockedMemSize: Unfortunately there does not seem to exist a proper explanation for this setting; it seems to prevent the host system from swapping parts of the guest memory.
  • MemAllowAutoScaleDown: Prevents VMware from adjusting the memory size of the virtual machine if it cannot allocate enough memory.
  • sched.mem.pshare.enable: If several virtual machines are running simultaneously, VMware will try to locate identical pages and share these between the virtual machines. This can be very I/O intensive.

The following settings can also be set in the configuration dialog of VMware Workstation(Edit -> Preferences... -> Memory/Priority).

prefvmx.minVmMemPct = "100"
mainMem.partialLazySave = "FALSE"
mainMem.partialLazyRestore = "FALSE"
  • prefvmx.minVmMemPct: Sets amount of RAM in percent which should be reserved by the virtual machine on the host system. If this is set to a lower value it is possible to assign the virtual machine more memory than is available in the host system. Be careful though, as in this case it will most likely lead to excessive hard drive usage. If enough RAM is on the host system, this value should be left at 100.
  • mainMem.partialLazySave and mainMem.partialLazyRestore: These two parameters will prevent the virtual machine from creating partial snapshots for suspends. When these parameters are used, virtual machine suspension will take slightly longer, but there should be less hard disk activity from VMware trying to store this information.

Troubleshooting

Kernel headers for version x.y-zzzz were not found. If you installed them[...]

Install the headers (linux-headers).

Note: Upgrading the kernel and the headers will require you to boot to the new kernel to match the version of the headers. This is a relatively common error.

USB devices not recognized

If not using the systemd service to automatically handle the services, you need to manually start the vmware-usbarbitrator binary as root each time.

To start:

# vmware-usbarbitrator

To stop:

# vmware-usbarbitrator --kill

Incorrect login/password when trying to access VMware remotely

VMware Workstation provides the possibility to remotely manage Shared VMs through the vmware-workstation-server service. However, this will fail with the error "incorrect username/password" due to incorrect PAM configuration of the vmware-authd service. To fix it, edit /etc/pam.d/vmware-authd like this:

/etc/pam.d/vmware-authd
#%PAM-1.0
auth     required       pam_unix.so
account  required       pam_unix.so
password required       pam_permit.so
session  required       pam_unix.so

and restart the vmware systemd service.

Now you can connect to the server with the credentials provided during the installation.

Note: libxslt may be required for starting virtual machines.

Issues with ALSA output

To fix sound quality issues or enabling proper HD audio output, first run:

$ aplay -L

If interested in playing 5.1 surround sound from the guest, look for surround51:CARD=vendor_name,DEV=num, if experiencing quality issues, look for front:CARD=vendor_name,DEV=num. Finally put the name in the .vmx:

~/vmware/Virtual_machine_name/Virtual_machine_name.vmx
sound.fileName="surround51:CARD=Live,DEV=0"
sound.autodetect="FALSE"

OSS emulation should also be disabled.

Kernel-based Virtual Machine (KVM) is running

To disable KVM on boot, you can use something like:

/etc/modprobe.d/vmware.conf
blacklist kvm
blacklist kvm-amd   # For AMD CPUs
blacklist kvm-intel # For Intel CPUs
Tip: If kvm modules continue to load, despite being blacklisted, and you are running a system with integrated Intel graphics (i915,i965), it may be necessary to blacklist the kvmgt kernel module directly from the kernel command line options. See Kernel module#Using kernel command line_2 for more details.

Module Issues

/dev/vmmon not found

The full error is:

Could not open /dev/vmmon: No such file or directory.
Please make sure that the kernel module 'vmmon' is loaded.

This means that at least the vmmon module is not loaded. See the #systemd services section for automatic loading.

/dev/vmci not found

The full error is:

Failed to open device "/dev/vmci": No such file or directory
Please make sure that the kernel module 'vmci' is loaded.

First, try to manually load the modules

# sudo modprobe -a vmw_vmci

Try to recompile VMware kernel modules with:

# vmware-modconfig --console --install-all

Installer Fails to Start

If you just get back to the prompt when opening the .bundle, then you probably have a deprecated or broken version of the VMware installer and it should removed (you may also refer to the uninstallation section of this article):

# rm -r /etc/vmware-installer/

User interface initialization failed

You may also see an error like this:

 Extracting VMware Installer...done.
 No protocol specified
 No protocol specified
 User interface initialization failed.  Exiting.  Check the log for details.

This can be fixed by either installing the ncurses5-compat-libsAUR dependency or temporarily allowing root access to X:

 $ xhost +
 $ sudo ./<vmware filename>.bundle
 $ xhost -

VMware Fails to Start

Module CPUIDEarly power on failed

Version 14 has stricter CPU requirements than version 12. If you try to start a virtual machine with an affected CPU, the following message will appear:

 This host does not support virtualizing real mode.
 The Intel "VMX Unrestricted Guest" feature is necessary to run this virtual machine on an Intel processor.

The solution is to uninstall version 14 and install version 12 (vmware-workstation12AUR).

When VMware was usable and this error suddenly appears it could be due to a warm/soft boot or after suspending the system. Please try a cold boot (shutting the system down and starting it again).

Segmentation fault at startup due to old Intel microcode

Old Intel microcode may result in the following kind of segmentation fault at startup:

/usr/bin/vmware: line 31: 4941 Segmentation fault "$BINDIR"/vmware-modconfig --appname="VMware Workstation" --icon="vmware-workstation"

See Microcode for how to update the microcode.

vmplayer/vmware version 14 fails to start

On systems with librsvg version 2:2.44.0 and above, the log files (located in /tmp/vmware-<id>) show several instances of the following error:

appLoader| I125+ undefined symbol

A workaround is to downgrade librsvg to earlier version, or more preferably, force VMware to use its own shipped version of librsvg:

# export LD_LIBRARY_PATH=/lib/vmware/lib/librsvg-2.so.2:$LD_LIBRARY_PATH

VMware also has a VMWARE_USE_SHIPPED_LIBS variable:

$ env VMWARE_USE_SHIPPED_LIBS=1 vmware

vmplayer/vmware fails to start from version 12.5.4

As per [2] the temporary workaround is to downgrade the package libpng to version 1.6.28-1 and keep it in the IgnorePkg parameter in /etc/pacman.conf.

An easier workaround is to make VMWare use the system's version of zlib instead of its own one:

# cd /usr/lib/vmware/lib/libz.so.1
# mv libz.so.1 libz.so.1.old
# ln -s /usr/lib/libz.so.1 .

vmplayer/vmware fails to start from version 12.5.3 to version 12.5.5

It seems to be a problem with the file /usr/lib/vmware/lib/libstdc++.so.6/libstdc++.so.6, missing CXXABI_1.3.8.

If the system have installed gcc-libs, that library is already installed. Therefore, it is possible to remove that file and vmplayer will use the one provided by gcc-libs instead. As root do:

# mv /usr/lib/vmware/lib/libstdc++.so.6/libstdc++.so.6 /usr/lib/vmware/lib/libstdc++.so.6/libstdc++.so.6.bak

Also there is a workaround:

# export VMWARE_USE_SHIPPED_LIBS='yes'

vmware 12 process terminates immediately after start, no GUI is launched

Registered bug at Mageia, but it seems that there are no error messages shown in terminal with arch. When inspecting the logs, which are in /tmp/vmware-<id>, there are VMWARE_SHIPPED_LIBS_LIST is not set, VMWARE_SYSTEM_LIBS_LIST is not set, VMWARE_USE_SHIPPED_LIBS is not set, VMWARE_USE_SYSTEM_LIBS is not set issues. Process simply terminates with Unable to execute /usr/lib/vmware/bin/vmware-modconfig. after vmware or vmplayer is executed. Solution is the same, as root do:

# mv /etc/vmware/icu/icudt44l.dat /etc/vmware/icu/icudt44l.dat.bak

Also there is a workaround:

# export VMWARE_USE_SHIPPED_LIBS='yes'

Despite setting the VMWARE_USE_SHIPPED_LIBS variable, VMWare may still fail to find certain libraries. An example is the libfontconfig.so.1 library. Check vmware logs in the tmp directory to see which libraries are still not found. Copy them to the appropriate path with libraries existing on the system:

# cp /usr/lib/libfontconfig.so.1 /usr/lib/vmware/lib/libfontconfig.so.1/

Instead of copying all these files manually, you may want to try exporting an additional setting:

# export VMWARE_USE_SYSTEM_LIBS='yes'

On systems with fontconfig version 2.13.0 and above, it may be needed to force VMware to use the shipped libfontconfig file instead of the newer system file. In such case, it is also necessary to provide a shared object library file libexpat.so.0 for the shipped fontconfig. This applies for at least VMware version 12.5.9. As root do:

# ln -s /usr/lib/libexpat.so /usr/lib/vmware/lib/libfontconfig.so.1/libexpat.so.0
# export LD_LIBRARY_PATH=/usr/lib/vmware/lib/libfontconfig.so.1:$LD_LIBRARY_PATH

Guest Issues

Unable to download VMware Tools for Guests

To download the tools manually, visit the VMware repository.

Navigate to: "application name / version / build ID / linux / packages/" and download the appropriate Tools.

Extract with:

$ tar -xvf vmware-tools-name-version-buildID.x86_64.component.tar

And install using the VMware installer:

# vmware-installer --install-component=/path/vmware-tools-name-version-buildID.x86_64.component

If the above does not work, try installing ncurses5-compat-libsAUR.

Guests have incorrect system clocks or are unable to boot: "[...]timeTracker_user.c:234 bugNr=148722"

This is due to incomplete support of power management features (Intel SpeedStep and AMD PowerNow!/Cool'n'Quiet) in VMware Linux that vary the CPU frequency. In March 2012, with the release of linux 3.3-1 the maximum frequency Performance governor was replaced with the dynamic Ondemand. When the host CPU frequency changes, the Guest system clock runs too quickly or too slowly, but may also render the whole Guest unbootable.

To prevent this, the maximum host CPU frequency can be specified, and Time Stamp Counter (TSC) disabled, in the global configuration:

/etc/vmware/config
host.cpukHz = "X"  # The maximum speed in KHz, e.g. 3GHz is "3000000".
host.noTSC = "TRUE" # Keep the Guest system clock accurate even when
ptsc.noTSC = "TRUE" # the time stamp counter (TSC) is slow.
Tip: To periodically correct the time (once per minute), in the Options tab of VMware Tools, enable: "Time synchronization between the virtual machine and the host operating system".

Networking on Guests not available after system restart

This is likely due to the vmnet module not being loaded [3]. See also the #systemd services section for automatic loading.

Mouse issues

Mouse buttons above 5 do not work

If your mouse's thumb buttons or other additional buttons do not work, set guest to use advanced mouse.

Strange mouse wheel behavior on Guest

This is related to the current Xorg keyboard layout on Host system. Keep primary layout (e.g., English) selected on Host while working on Guest.

No IP address and network access for nested VMs

This issue is related to promiscuous mode which, following standard Linux practice, can only be enabled by the root user. To work around these limitations, the permissions for the networking device in question have to be changed.

Give permissions to one group:

# chgpr group /dev/vmnetX

# chmod g+rw /dev/vmnetX

Give permissions to all users:

# chmod a+rw /dev/vmnetX

Uninstallation

To uninstall VMware you need the product name (either vmware-workstation or vmware-player). To list all the installed products:

$ vmware-installer -l

and uninstall with (--required skips the confirmation):

# vmware-installer -u product --required
Tip: Use --console for the console UI.

Remember to also disable and remove the services:

# rm /etc/systemd/system/vmware.service
# rm /etc/systemd/system/vmware-usbarbitrator.service

You may also want to have a look at the module directories in /usr/lib/modules/kernel_name/misc/ for any leftovers, and remove /etc/init.d/ if now empty.