环境:-
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
$ uname -a
Linux bmrmt 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
目前我已经安装了以下 vmware 工作站版本。
$ vmware --version
VMware Workstation 15.5.7 build-17171714
当我vmware
从命令行启动时,它要求选择内核路径。提供了最新安装的内核路径,但没有用,它开始显示以下消息。
C header files matching your running kernel were not found
错误。
因此,发现下面的命令可以自动修复与 vm 依赖相关的问题。但是它失败并出现以下错误。
$ sudo vmware-modconfig --console --install-all
[AppLoader] GLib does not have GSettings support.
(process:31113): GLib-CRITICAL **: 14:51:49.338: g_file_test: assertion 'filename != NULL' failed
Failed to setup build environment.
下面的包已经安装。
sudo apt-get install build-essential
sudo apt-get install linux-headers-$(uname -r)
$ sudo /etc/init.d/vmware start
Starting VMware services:
Virtual machine monitor failed
Virtual machine communication interface done
VM communication interface socket family done
Blocking file system done
Virtual ethernet failed
VMware Authentication Daemon done
尝试过这个解决方案:
#!/bin/bash
VMWARE_VERSION="workstation-$(vmware -v|grep -oE "[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"| head -n1)" # this is detect the version you have VMware Workstation 16.2.1 build-18811642
TMP_FOLDER=/tmp/patch-vmware
rm -fdr $TMP_FOLDER
mkdir -p $TMP_FOLDER
cd $TMP_FOLDER
git clone https://github.com/mkubecek/vmware-host-modules.git
cd $TMP_FOLDER/vmware-host-modules
git checkout $VMWARE_VERSION
git fetch
make
sudo make install
sudo rm /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo /etc/init.d/vmware restart
失败并出现以下错误。
make[2]: Leaving directory '/usr/src/linux-headers-5.4.0-91-generic'
make -C $PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= postbuild
make[2]: Entering directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
make[2]: 'postbuild' is up to date.
make[2]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
cp -f vmnet.ko ./../vmnet.o
make[1]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
Version mismatch: module vmmon-only/vmmon.ko 5.4.151, kernel 5.4.0-91-generic
Version mismatch: module vmnet-only/vmnet.ko 5.4.151, kernel 5.4.0-91-generic
make: *** [Makefile:35: install] Error 1
Stopping VMware services:
VMware Authentication Daemon done
VM communication interface socket family done
Virtual machine communication interface done
Virtual machine monitor done
Blocking file system done
Starting VMware services:
Virtual machine monitor failed
Virtual machine communication interface done
VM communication interface socket family done
Blocking file system done
Virtual ethernet failed
VMware Authentication Daemon done
$ sudo /etc/init.d/vmware status
Module vmmon not loaded
Module vmnet not loaded
$ cat /proc/cpuinfo | grep 'name'| uniq
model name : Intel(R) Xeon(R) Gold 6138 CPU @ 2.00GHz
$ cat /proc/cpuinfo | grep process| wc -l
80
$ sudo mokutil --sb-state
SecureBoot disabled
$ grep --color vmx /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear flush_l1d
请告诉我我的 ubuntu-20.04 LTS 系统出了什么问题?
答案1
原始评论者巧妙脚本的修复版本解决了我在最新的 PopOS 21.10 Ubuntu 上的问题
#!/usr/bin/env bash
VMWARE_VERSION="workstation-$(vmware -v||vmplayer -v|grep -oE "[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"| head -n1)" # this is detect the version you have VMware Workstation 16.2.1 build-18811642
TMP_FOLDER=/tmp/patch-vmware
rm -fdr $TMP_FOLDER
mkdir -p $TMP_FOLDER
cd $TMP_FOLDER || exit
git clone https://github.com/mkubecek/vmware-host-modules.git
cd $TMP_FOLDER/vmware-host-modules || exit
git checkout "$VMWARE_VERSION"
git fetch
make
sudo make install
sudo rm /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo /etc/init.d/vmware restart
不起作用的原因。正则表达式不起作用
❯ vmware -v|grep [0-9.]* -o|head -n 1
~ at 10:48:19
❯ vmware -v
VMware Workstation 16.2.1 build-18811642
~ at 10:48:33
切换到此项即可正确将其提取出来。
❯ vmware -v|grep -oE "[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"| head -n1
16.2.1
~ at 10:49:53
例子:
❯ chmod +x /home/mike/Documents/dev/bash_scripts/vmware_kernels.sh
~ at 10:50:51
❯ bash /home/mike/Documents/dev/bash_scripts/vmware_kernels.sh
Cloning into 'vmware-host-modules'...
remote: Enumerating objects: 3388, done.
remote: Counting objects: 100% (851/851), done.
remote: Compressing objects: 100% (701/701), done.
remote: Total 3388 (delta 403), reused 538 (delta 149), pack-reused 2537
Receiving objects: 100% (3388/3388), 1.70 MiB | 631.00 KiB/s, done.
Resolving deltas: 100% (2422/2422), done.
Branch 'workstation-16.2.1' set up to track remote branch 'workstation-16.2.1' from 'origin'.
Switched to a new branch 'workstation-16.2.1'
make -C vmmon-only
make[1]: Entering directory '/tmp/patch-vmware/vmware-host-modules/vmmon-only'
Using kernel build system.
make -C /lib/modules/5.16.11-76051611-generic/build/include/.. M=$PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= modules
make[2]: Entering directory '/usr/src/linux-headers-5.16.11-76051611-generic'
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/linux/driver.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/linux/driverLog.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/linux/hostif.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/apic.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/comport.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/cpuid.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/crosspage.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/memtrack.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/moduleloop.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/phystrack.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/sharedAreaVmmon.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/statVarsVmmon.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/task.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/common/vmx86.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/bootstrap/bootstrap.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/bootstrap/monLoader.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/bootstrap/monLoaderVmmon.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/bootstrap/vmmblob.o
LD [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/vmmon.o
MODPOST /tmp/patch-vmware/vmware-host-modules/vmmon-only/Module.symvers
CC [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/vmmon.mod.o
LD [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/vmmon.ko
BTF [M] /tmp/patch-vmware/vmware-host-modules/vmmon-only/vmmon.ko
Skipping BTF generation for /tmp/patch-vmware/vmware-host-modules/vmmon-only/vmmon.ko due to unavailability of vmlinux
make[2]: Leaving directory '/usr/src/linux-headers-5.16.11-76051611-generic'
make -C $PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= postbuild
make[2]: Entering directory '/tmp/patch-vmware/vmware-host-modules/vmmon-only'
make[2]: 'postbuild' is up to date.
make[2]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmmon-only'
cp -f vmmon.ko ./../vmmon.o
make[1]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmmon-only'
make -C vmnet-only
make[1]: Entering directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
Using kernel build system.
make -C /lib/modules/5.16.11-76051611-generic/build/include/.. M=$PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= modules
make[2]: Entering directory '/usr/src/linux-headers-5.16.11-76051611-generic'
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/driver.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/hub.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/userif.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/netif.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/bridge.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/procfs.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/smac_compat.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/smac.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vnetEvent.o
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vnetUserListener.o
LD [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vmnet.o
MODPOST /tmp/patch-vmware/vmware-host-modules/vmnet-only/Module.symvers
CC [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vmnet.mod.o
LD [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vmnet.ko
BTF [M] /tmp/patch-vmware/vmware-host-modules/vmnet-only/vmnet.ko
Skipping BTF generation for /tmp/patch-vmware/vmware-host-modules/vmnet-only/vmnet.ko due to unavailability of vmlinux
make[2]: Leaving directory '/usr/src/linux-headers-5.16.11-76051611-generic'
make -C $PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= postbuild
make[2]: Entering directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
make[2]: 'postbuild' is up to date.
make[2]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
cp -f vmnet.ko ./../vmnet.o
make[1]: Leaving directory '/tmp/patch-vmware/vmware-host-modules/vmnet-only'
install -D -t /lib/modules/5.16.11-76051611-generic/misc vmmon-only/vmmon.ko vmnet-only/vmnet.ko
strip --strip-debug /lib/modules/5.16.11-76051611-generic/misc/vmmon.ko /lib/modules/5.16.11-76051611-generic/misc/vmnet.ko
if test -z ""; then /sbin/depmod -a 5.16.11-76051611-generic; fi
Stopping VMware services:
VMware Authentication Daemon done
Virtual machine monitor done
Starting VMware services:
Virtual machine monitor done
Virtual machine communication interface done
VM communication interface socket family done
Virtual ethernet done
VMware Authentication Daemon done
Shared Memory Available done
~ took 15s at 10:51:18
❯
之前我遇到过很多类似下面的问题
In file included from /usr/lib/vmware/modules/source/vmmon-only/linux/driverLog.h:33,
from /usr/lib/vmware/modules/source/vmmon-only/linux/driver.c:46:
/usr/lib/vmware/modules/source/vmmon-only/./include/vm_assert.h:43:10: fatal error: stdarg.h: No such file or directory
43 | #include <stdarg.h>
| ^~~~~~~~~~
compilation terminated.
答案2
检查处理器是否支持硬件虚拟化(Intel 处理器为 VT-x,AMD 处理器为 AMD-V)。
来自终端问题
grep --color vmx /proc/cpuinfo ## for an Intel processor
grep --color svm /proc/cpuinfo ## for an AMD processor
如果未启用,则在 BIOS 中包含虚拟化、虚拟化技术 (VT-x)、SVM、VMX。