openEuler 24.03’s /proc/version uses the format gcc_old (GCC), which is not recognized by VMware. When starting VMware Workstation, it reports that gcc cannot be found.
Temporary Fix Method 1
Temporarily replace /proc/version and use VMware’s built-in tool vmware-modconfig. The AI-generated script is as follows:
Note: Requires administrator privileges
#!/bin/bash
set -euo pipefail
# Prerequisite check (essential)
if [ ! -d "/lib/modules/$(uname -r)/build" ]; then
echo "❌ Please run: sudo dnf install -y kernel-devel-$(uname -r)"
exit 1
fi
# Core: Replace 'gcc_old (GCC)' in /proc/version to make it recognizable
PROC_BAK=$(mktemp /tmp/proc_version_bak.XXXXXX)
cat /proc/version > "$PROC_BAK"
sed 's/gcc_old (GCC)/gcc version/' "$PROC_BAK" > /tmp/proc_version_fixed
# Temporarily mount the modified file
while mount | grep -q "/proc/version"; do umount /proc/version; done
mount --bind /tmp/proc_version_fixed /proc/version
# Use official tool to compile VMware modules (remove manual compilation fallback)
echo "✅ Using official tool to compile VMware modules"
vmware-modconfig --console --install-all
# Restore original /proc/version and clean up temporary files
umount /proc/version && rm -f "$PROC_BAK" /tmp/proc_version_fixed
# Restart VMware service
sudo pkill -f vmware-authdlauncher || true
sudo systemctl restart vmware
# Verify result
echo -e "\n===== Fix Verification Complete ====="
sudo lsmod | grep -E "vmmon|vmnet" && echo "✅ Module loaded successfully" || echo "⚠️ Module failed to load, try re-running the script"
sudo systemctl status vmware --no-pager | grep Active
Temporary Fix Method 2
Manually compile the affected modules vmmon and vmnet. The AI-generated script is as follows:
#!/bin/bash
set -euo pipefail
KERNEL_VERSION=$(uname -r)
MODULE_SRC="/usr/lib/vmware/modules/source"
MODULE_DEST="/lib/modules/${KERNEL_VERSION}/misc"
# Check if module exists and version matches
check_module() {
local mod_path="$1"
if [ ! -f "$mod_path" ]; then
return 1
fi
# Get module vermagic
local vermagic
vermagic=$(modinfo -F vermagic "$mod_path" 2>/dev/null | head -1)
if [ -z "$vermagic" ]; then
return 1
fi
# Check if vermagic contains current kernel version
if [[ "$vermagic" == *"${KERNEL_VERSION}"* ]]; then
return 0
else
return 1
fi
}
if check_module "${MODULE_DEST}/vmmon.ko" && check_module "${MODULE_DEST}/vmnet.ko"; then
echo "VMware modules for current kernel already exist and match version, skipping compilation."
exit 0
fi
# Check for kernel headers
if [ ! -d "/lib/modules/${KERNEL_VERSION}/build" ]; then
echo "❌ Kernel headers not found. Please run: sudo dnf install kernel-devel-${KERNEL_VERSION}"
exit 1
fi
# Enter source directory
cd "${MODULE_SRC}"
# Clean up old extracted directories
rm -rf vmmon-only vmnet-only
# Compile vmmon
echo "🔨 Compiling vmmon..."
tar xf vmmon.tar
cd vmmon-only
make
cd ..
# Compile vmnet
echo "🔨 Compiling vmnet..."
tar xf vmnet.tar
cd vmnet-only
make
cd ..
# Create destination directory
mkdir -p "${MODULE_DEST}"
# Copy modules
cp vmmon-only/vmmon.ko "${MODULE_DEST}/vmmon.ko"
cp vmnet-only/vmnet.ko "${MODULE_DEST}/vmnet.ko"
# Update module dependencies
depmod -a
# Clean up temporary directories
rm -rf vmmon-only vmnet-only
echo "✅ Compilation complete. Modules installed to ${MODULE_DEST}"
Automatic Startup Handling
Create a systemd service to automatically run the manual compilation script at boot. The AI-generated one-click installation and test script is as follows:
#!/bin/bash
# VMware Module Auto-Compile Deployment Script (Manual Build + systemd)
#适用于 openEuler / RHEL / CentOS 等使用 dnf 的发行版
set -euo pipefail
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} VMware Module Auto-Compile Script ${NC}"
echo -e "${GREEN}========================================${NC}"
# Check root privileges
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run this script as root (use sudo).${NC}"
exit 1
fi
# Check if VMware is installed (by checking module source files)
VMWARE_SRC="/usr/lib/vmware/modules/source"
if [ ! -f "$VMWARE_SRC/vmmon.tar" ] || [ ! -f "$VMWARE_SRC/vmnet.tar" ]; then
echo -e "${RED}Error: VMware module source files not found. Please install VMware Workstation first.${NC}"
exit 1
fi
echo -e "${GREEN}✅ VMware module source files detected.${NC}"
# Install dependencies
echo -e "${YELLOW}Installing dependencies (kernel-devel, make, gcc, elfutils-libelf-devel)...${NC}"
dnf install -y kernel-devel-$(uname -r) make gcc elfutils-libelf-devel
echo -e "${GREEN}✅ Dependencies installed.${NC}"
# Create manual build script
echo -e "${YELLOW}Creating build script /usr/local/bin/vmware-manual-build.sh...${NC}"
cat > /usr/local/bin/vmware-manual-build.sh << 'EOF'
#!/bin/bash
set -euo pipefail
KERNEL_VERSION=$(uname -r)
MODULE_SRC="/usr/lib/vmware/modules/source"
MODULE_DEST="/lib/modules/${KERNEL_VERSION}/misc"
# Check if module exists and version matches
check_module() {
local mod_path="$1"
if [ ! -f "$mod_path" ]; then
return 1
fi
# Get module vermagic
local vermagic
vermagic=$(modinfo -F vermagic "$mod_path" 2>/dev/null | head -1)
if [ -z "$vermagic" ]; then
return 1
fi
# Check if vermagic contains current kernel version
if [[ "$vermagic" == *"${KERNEL_VERSION}"* ]]; then
return 0
else
return 1
fi
}
if check_module "${MODULE_DEST}/vmmon.ko" && check_module "${MODULE_DEST}/vmnet.ko"; then
echo "VMware modules for current kernel already exist and match version, skipping compilation."
exit 0
fi
# Check for kernel headers
if [ ! -d "/lib/modules/${KERNEL_VERSION}/build" ]; then
echo "❌ Kernel headers not found. Please run: sudo dnf install kernel-devel-${KERNEL_VERSION}"
exit 1
fi
# Enter source directory
cd "${MODULE_SRC}"
# Clean up old extracted directories
rm -rf vmmon-only vmnet-only
# Compile vmmon
echo "🔨 Compiling vmmon..."
tar xf vmmon.tar
cd vmmon-only
make
cd ..
# Compile vmnet
echo "🔨 Compiling vmnet..."
tar xf vmnet.tar
cd vmnet-only
make
cd ..
# Create destination directory
mkdir -p "${MODULE_DEST}"
# Copy modules
cp vmmon-only/vmmon.ko "${MODULE_DEST}/vmmon.ko"
cp vmnet-only/vmnet.ko "${MODULE_DEST}/vmnet.ko"
# Update module dependencies
depmod -a
# Clean up temporary directories
rm -rf vmmon-only vmnet-only
echo "✅ Compilation complete. Modules installed to ${MODULE_DEST}"
EOF
chmod +x /usr/local/bin/vmware-manual-build.sh
echo -e "${GREEN}✅ Build script created successfully.${NC}"
# Create systemd service unit
echo -e "${YELLOW}Creating systemd service /etc/systemd/system/vmware-manual-build.service...${NC}"
cat > /etc/systemd/system/vmware-manual-build.service << 'EOF'
[Unit]
Description=VMware Manual Module Build
After=local-fs.target
Before=vmware.service
ConditionPathExists=/lib/modules/%v/build
ConditionPathExists=/usr/lib/vmware/modules/source/vmmon.tar
ConditionPathExists=/usr/lib/vmware/modules/source/vmnet.tar
[Service]
Type=oneshot
ExecStart=/usr/local/bin/vmware-manual-build.sh
RemainAfterExit=no
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd
systemctl daemon-reload
# Enable service (auto-start at boot)
systemctl enable vmware-manual-build.service
echo -e "${GREEN}✅ Systemd service enabled.${NC}"
# Run immediately (test)
echo -e "${YELLOW}Running build script immediately for testing...${NC}"
systemctl start vmware-manual-build.service
# Check service status (using ExecMainStatus)
EXIT_CODE=$(systemctl show -p ExecMainStatus --value vmware-manual-build.service)
if [ "$EXIT_CODE" = "0" ]; then
echo -e "${GREEN}✅ Build service executed successfully.${NC}"
else
echo -e "${RED}⚠️ Build service may have failed. Check logs: journalctl -u vmware-manual-build.service${NC}"
fi
# Restart VMware service (if installed)
if systemctl list-unit-files | grep -q vmware.service; then
echo -e "${YELLOW}Restarting VMware service...${NC}"
systemctl restart vmware.service || true
fi
# Final message
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Deployment complete!${NC}"
echo -e "Build script location: ${YELLOW}/usr/local/bin/vmware-manual-build.sh${NC}"
echo -e "Systemd service: ${YELLOW}vmware-manual-build.service${NC}"
echo -e ""
echo -e "The VMware module will be automatically checked and compiled for the current kernel on every boot."
echo -e "Manual run: ${YELLOW}sudo systemctl start vmware-manual-build.service${NC}"
echo -e "View logs: ${YELLOW}sudo journalctl -u vmware-manual-build.service${NC}"
echo -e "${GREEN}========================================${NC}"
Testing Automatic Startup Handling
The auto-start script includes one automatic compilation at boot. To test:
- Delete the compiled
vmmon.koandvmnet.komodules. - Start VMware — it will fail with “gcc not found”.
- Reboot the system — VMware should now start normally.
Script to delete vmmon and vmnet modules:
#!/bin/bash
# Find all vmmon/vmnet module files across kernel versions
sudo find /lib/modules -name "vmmon.ko*" -o -name "vmnet.ko*" 2>/dev/null
# Delete all found files (use with caution to avoid accidental deletion)
sudo find /lib/modules -name "vmmon.ko*" -o -name "vmnet.ko*" -exec rm -f {} \;
# Rebuild module dependencies (recommended)
sudo depmod -a
```### Remove files left by the boot-time automatic processing script, and restore the system
```bash
#!/bin/bash
# VMware manual build automation cleanup script
set -euo pipefail
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} VMware Automatic Build Cleanup Script ${NC}"
echo -e "${GREEN}========================================${NC}"
# Check for root privileges
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run this script as root (using sudo).${NC}"
exit 1
fi
# Define service name and script path
SERVICE_NAME="vmware-manual-build.service"
SCRIPT_PATH="/usr/local/bin/vmware-manual-build.sh"
# 1. Stop and disable the service (if it exists)
if systemctl list-unit-files | grep -q "$SERVICE_NAME"; then
echo -e "${YELLOW}Stopping and disabling $SERVICE_NAME...${NC}"
systemctl stop "$SERVICE_NAME" 2>/dev/null || true
systemctl disable "$SERVICE_NAME" 2>/dev/null || true
echo -e "${GREEN}✅ Service has been stopped and disabled.${NC}"
else
echo -e "${YELLOW}Service $SERVICE_NAME does not exist, skipping.${NC}"
fi
# 2. Remove the service unit file
if [ -f "/etc/systemd/system/$SERVICE_NAME" ]; then
echo -e "${YELLOW}Removing service unit file...${NC}"
rm -f "/etc/systemd/system/$SERVICE_NAME"
echo -e "${GREEN}✅ Service unit file has been removed.${NC}"
else
echo -e "${YELLOW}Service unit file does not exist, skipping.${NC}"
fi
# 3. Reload systemd
systemctl daemon-reload
echo -e "${GREEN}✅ systemd has been reloaded.${NC}"
# 4. Remove the build script
if [ -f "$SCRIPT_PATH" ]; then
echo -e "${YELLOW}Removing build script $SCRIPT_PATH...${NC}"
rm -f "$SCRIPT_PATH"
echo -e "${GREEN}✅ Build script has been removed.${NC}"
else
echo -e "${YELLOW}Build script does not exist, skipping.${NC}"
fi
# 5. Ask whether to delete installed module files
echo -e "${YELLOW}Do you want to delete the installed VMware module files (located in /lib/modules/$(uname -r)/misc/)?${NC}"
echo -e "${YELLOW}Note: After deletion, VMware will not start unless the modules are recompiled.${NC}"
read -p "Enter y/N: " -r choice
if [[ "$choice" =~ ^[Yy]$ ]]; then
MODULE_DEST="/lib/modules/$(uname -r)/misc"
if [ -d "$MODULE_DEST" ]; then
echo -e "${YELLOW}Removing module files...${NC}"
rm -f "$MODULE_DEST"/vmmon.ko "$MODULE_DEST"/vmnet.ko
echo -e "${GREEN}✅ Module files have been removed.${NC}"
# Update module dependencies
depmod -a
echo -e "${GREEN}✅ Module dependencies have been updated.${NC}"
else
echo -e "${YELLOW}Module directory does not exist, skipping.${NC}"
fi
else
echo -e "${YELLOW}Keeping installed module files.${NC}"
fi
# 6. Completion message
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Cleanup complete!${NC}"
echo -e "To redeploy, run the installation script again."
echo -e "${GREEN}========================================${NC}"