Difference between revisions of "VMware (简体中文)"

From ArchWiki
Jump to: navigation, search
(使用修改过的 BIOS)
Line 145: Line 145:
==== 准备 ====
==== 准备 ====
First install {{pkg|dkms}} from the [[Community repository]]:
首先从 [[Community repository]] 安装 {{pkg|dkms}}
  # pacman -S dkms
  # pacman -S dkms
then create a source directory for the {{ic|Makefile}} and the {{ic|dkms.conf}}:
然后为 {{ic|Makefile}} {{ic|dkms.conf}} 创建源目录:
  # mkdir /usr/src/vmware-modules-9/
  # mkdir /usr/src/vmware-modules-9/

Revision as of 12:32, 25 May 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end


附注: please use the first argument of the template to provide more detailed indications.

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


注意: VMware Workstation/Player 不会 被 pacman 管理,因为这些文件不是用它安装的。

1. 下载最新版的 VMware Workstation 或是 VMware Player (你也可以尝试 testing (Beta/RC) versions)。

2. 开始安装 (--console 使用终端代替 GUI):

$ chmod +x VMware-<edition>-<version>.<release>.<architecture>.bundle
# ./VMware-<edition>-<version>.<release>.<architecture>.bundle --console

3. 阅读并接受最终用户许可协议。

4. 设置 System service scripts directory/etc/init.d

5. (可选) 如果安装了 Eclipse ,在集成虚拟调试器中输入目录路径。

6. 你会得到一个关于 "rc*.d style init script directories" 没有设置的错误。这个可以放心地忽略掉。


Tip: 为了自动化本章节的内容,AUR 中也包含了一个叫做 vmware-patchAUR 的软件包(它同时支持旧版本的 VMware )。
Note: Ensure you have installed the correct headers required for building the modules (linux from [core] uses linux-headers).


7. The module tool paths of certain Workstation scripts now need to be pointed to /usr/bin/ instead of /sbin/. These include the service script in /etc/init.d/ and some other ones in /usr/bin/.

1) 短期的解决方案


  • 对于 Workstation:
# perl -p -i -e 's|/sbin/(?!modprobe)|/usr/bin/|g' /etc/init.d/vmware /usr/bin/vm-support /usr/bin/vmplayer /usr/bin/vmware /usr/bin/vmware-hostd /usr/bin/vmware-wssc-adminTool
  • 对于 Player:
# perl -p -i -e 's|/sbin/(?!modprobe)|/usr/bin/|g' /etc/init.d/vmware /usr/bin/vm-support /usr/bin/vmplayer

2) 长期的解决方案


# ln -s /usr/bin/insmod /usr/bin/lsmod /usr/bin/modinfo /usr/bin/rmmod /sbin/

VMware 模块补丁及安装

VMware Workstation 9 和 Player 5 都支持到 3.9 的内核。

注意: 相对的,本章节目前仅适用于低于 9.0.2 版本的 VMware Workstation 和低于 5.0.2 版本的 Player 。
注意: 由于 VMware 版本的不同,你可能需要在 patch-modules_3.X.0.sh 脚本中分别修改 VMware Workstation 或 Player 的 vmreqverplreqver 变量。

下面的补丁也会在执行完 # vmware-modconfig --console --install-all 之后安装模块。

3.7 内核及以上

With the arrival of 3.7 the directory structure of the uapi sources (and thus the headers) 已经有所 改动。缺失的内核头文件 version.h 可以这样做 符号链接

# ln -s /usr/src/linux-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-$(uname -r)/include/linux/

你可以使用任何不在运行的内核代替 "$(uname -r)"。

注意: 每次内核更新你都需要重复一遍操作。

3.8 / 3.9 内核

In addition to the header symlink outlined above 3.8/3.9 kernels also need this (packaged together with the script in here):

$ cd /tmp
$ curl -O https://raw.github.com/willysr/SlackHacks/master/vmware/vmware-3.8/vmware9.0.1_kernel3.8.zip
$ bsdtar -xvf vmware9.0.1_kernel3.8.zip
# ./patch-modules_3.8.0.sh

3.5 / 3.6 / 3.7 内核

A change in the format of the kernel exception table introduced back in April affecting the vmmon module is known to cause crashes in Fedora guests. The patch here creates a portable exception table (packaged together with the script in here, which will also reload the vmmon module):

$ cd /tmp
$ curl -O http://communities.vmware.com/servlet/JiveServlet/download/2103172-94260/vmware9_kernel35_patch.tar.bz2
$ tar -xvf --strip-components=1 vmware9_kernel35_patch.tar.bz2  # The "--strip-components=1" flag extracts the files only
# ./patch-modules_3.5.0.sh

Systemd 服务

8. (可选) 你也可以创建一个 .service 文件 (或是 文件),而不是直接使用 # /etc/init.d/vmware {start|stop|status|restart} 来管理服务:

Description=VMware daemon

ExecStart=/etc/init.d/vmware start
ExecStop=/etc/init.d/vmware stop


开机启动 .service

# systemctl enable vmware


9. 现在,打开你的 VMware Workstation (终端中,vmware) 或是 VMware Player (终端中,vmplayer) 使用吧!

Tip: 使用以下命令(重)编译模块:
# vmware-modconfig --console --install-all

Tips & Tricks

从终端中输入 Workstation 许可密钥

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


解压缩 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

使用修改过的 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>/

然后在 <Virtual machine name>.vmx 文件中加入:

~/vmware/<Virtual machine name>/<Virtual machine name>.vmx
bios440.filename = "bios440.rom"

写时复制 (CoW)

CoW comes with some advantages, but can negatively affect performance with large files that have small random writes (例如数据库文件和虚拟机镜像):

$ chattr +C ~/vmware/<Virtual machine name>/<Virtual machine name>.vmx
Note: From the chattr man page: "For btrfs, the C flag should be set only on new or empty files. If set on a file which already has data blocks, it is undefined when the blocks assigned to the file will be fully stable. If set on a directory, only new files will be affected."

使用 DKMS 管理模块

The Dynamic Kernel Module Support (DKMS) can be used to manage Workstation modules and to void from re-running vmware-modconfig each time the kernel changes. The following example uses a custom Makefile to compile and install the modules through vmware-modconfig. Afterwards they are removed from the current kernel tree.


首先从 Community repository 安装 dkms

# pacman -S dkms

然后为 Makefiledkms.conf 创建源目录:

# mkdir /usr/src/vmware-modules-9/

Build configuration

Fetch the files from Git or use the ones below.

1) 使用 Git
$ cd /tmp
$ git clone git://github.com/djod4556/dkms-workstation.git
# cp /tmp/dkms-workstation.git/Makefile /tmp/dkms-workstation.git/dkms.conf /usr/src/vmware-modules-9/
2) 手动安装

The dkms.conf describes the module names and the compilation/installation procedure. AUTOINSTALL="yes" tells the modules to be recompiled/installed automatically each time:


MAKE[0]="make all"
CLEAN="make clean"








and now the Makefile:

HEADERS := /usr/src/linux-$(KERNEL)/include
GCC := $(shell vmware-modconfig --console --get-gcc)
DEST := /lib/modules/$(KERNEL)/vmware

TARGETS := vmmon vmnet vmblock vmci vsock

LOCAL_MODULES := $(addsuffix .ko, $(TARGETS))

        mkdir -p modules/
        mv *.ko modules/
        rm -rf $(DEST)

        ln -s /usr/src/linux-$(KERNEL)/include/generated/uapi/linux/version.h /usr/src/linux-$(KERNEL)/include/linux/

%.ko: /usr/src/linux-$(KERNEL)/include/linux/version.h
        vmware-modconfig --console --build-mod -k $(KERNEL) $* $(GCC) $(HEADERS) vmware/
        cp -f $(DEST)/$*.ko .

        rm -rf modules/


The modules can then be registered:

# dkms -m vmware-modules -v 9 -k $(uname -r) add


# dkms -m vmware-modules -v 9 -k $(uname -r) build


# dkms -m vmware-modules -v 9 -k $(uname -r) install

If everything went well, the modules will now be recompiled automatically the next time the kernel changes.


Could not open /dev/vmmon: No such file or directory.


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

这意味这至少 vmmon VMware 服务没有运行。如果使用步骤 8 中的 .service 文件,可以这样启动 VMware 服务:

# systemctl start vmware


# /etc/init.d/vmware start

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


# pacman -S linux-headers
Note: 更新内核和头文件会需要你启动新的内核以匹配头文件的版本。这是一个相对常见的错误。

无法识别 USB 设备

Tip: 可以通过 vmware-patchAUR 解决。

1) 缺少 vmware-USBArbitrator 脚本

由于种种原因,一些安装会缺少 vmware-USBArbitrator 脚本。手动重新添加这个文件,查看 this forum post.

You may also manually extract the VMware bundle and copy the vmware-USBArbitrator script from <destination folder>/vmware-usbarbitrator/etc/init.d/ to /etc/init.d/:

$ ./VMware-<edition>-<version>.<release>.<architecture>.bundle --extract /tmp/vmware-bundle
# cp /tmp/vmware-bundle/vmware-usbarbitrator/etc/init.d/vmware-USBArbitrator /etc/init.d/

2) The vmware-usbarbitrator binary is segfaulting

This could also mean that the vmware-usbarbitrator binary called in the script is segfaulting:

# vmware-usbarbitrator
Pipe unexpectedly closed.	
# vmware-usbarbitrator --info -f
VTHREAD initialize main thread 2 "usbArb" pid 6426
Segmentation fault

This is caused by an empty /etc/arch-release (owned by filesystem). It is used by the service to alter its behavior based on the distribution's release version.

To fix it, add a version string in the form of <year>.<month>(.<day>) (e.g. 2013.04.01).

process XXXX: Attempt to remove filter function [...]

The full error is, for example:

process 6094: Attempt to remove filter function 0xadcc96f0 user data 0xb795aba0, but no such filter has been added
  D-Bus not built with -rdynamic so unable to print a backtrace

This means that the hal daemon is not running. Install halAUR from the AUR and start the daemon with:

# hald

The 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 you should remove it (you may also refer to the uninstallation section of this article):

# rm -r /etc/vmware-installer

Incorrect login/password when trying to access VMware remotely

VMware Workstation 9 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:

auth     required       pam_unix.so
account  required       pam_unix.so
password required       pam_permit.so
session  required       pam_unix.so

and restart VMware services with:

# systemctl restart vmware

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

The following instructions from Bankim Bhavsar's wiki show how to manually adjust the ALSA output device in a VMware .vmx file. This might help with quality issues or with enabling proper HD audio output:

  1. Suspend/Power off the VM.
  2. Run aplay -L
  3. If you are interested in playing 5.1 surround sound from the guest, look for surround51:CARD=vendor-name,DEV=num. If you are experiencing quality issues, look out for a line starting with front.
  4. Open the <Virtual machine name>.vmx config file of the VM in a text editor, located under ~/vmware/<Virtual machine name>/, and edit the sound.fileName field, e.g.: sound.fileName="surround51:CARD=Live,DEV=0". Ensure that it also reads sound.autodetect="FALSE".
  5. Resume/Power on the VM.


To uninstall VMware you need the product name (vmware-workstation 或是 vmware-player)。列出所有的产品:

# vmware-installer -l


# vmware-installer -u <vmware-product>

Manually included symlinks have to be removed manually in /sbin/:

# rm /sbin/insmod /sbin/lsmod /sbin/modinfo /sbin/rmmod

记得也要删除 .service 文件:

# systemctl disable vmware
# rm /etc/systemd/system/vmware.service

You may also want to have a look at the kernel directories in /usr for any leftovers. The now unnecessary #3.7 kernels and up patching step leaves header directories in /usr/src/ (full path: /usr/src/linux-[kernel name]/include/linux/version.h).

模块目录位于 /usr/lib/modules/[kernel name]/misc/