Files
local-ci-cd-system/deploy/systemd/vmware-modules-rebuild.sh
T
Simone 19186981a5 fix(host): bring up VMware host stack at boot via native systemd units
Build VMs stopped starting after a reboot into a new kernel: vmmon/vmnet
were left unloaded and vmnet1/vmnet8 (DHCP/NAT) never came up, so
vmware-vmx died (status=237/KEYRING) and clones got no IP. Root cause:
the LSB->systemd sysv-generated vmware.service intermittently fails to
generate at early boot ("systemd-sysv-generator: Cannot find unit
vmware.service"), and the existing module-rebuild guard only builds the
modules -- it never loads them or starts vmnet networking.

Add a native vmware-host.service that runs `/etc/init.d/vmware start`
(loads vmmon/vmci + brings up vmnet), ordered after the rebuild guard,
and mask the flaky sysv vmware.service so the native unit is the sole
owner. Provisioned by scripts/install-vmware-host-services.sh and wired
into setup-host-linux.sh (new step 8/9). VMware ships no native unit and
no kernel postinst hook, so this native wrapper around VMware's own
tools is the reliable boot path.

Verified: linked clone boots and gets a vmnet8 DHCP IP.
2026-07-19 19:47:16 +02:00

29 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Rebuild VMware host modules (vmmon/vmnet) for the running kernel if absent.
# VMware Workstation does not register these with DKMS, so a kernel upgrade
# leaves them unbuilt until the GUI or vmware-modconfig is run. This runs at
# boot, before vmware-host.service, and self-heals using VMware's own builder.
set -eu
KVER="$(uname -r)"
if /sbin/modinfo vmmon >/dev/null 2>&1 && /sbin/modinfo vmnet >/dev/null 2>&1; then
# Module objects already present for the running kernel — nothing to do.
exit 0
fi
logger -t vmware-modules-rebuild "vmmon/vmnet missing for kernel ${KVER} — rebuilding via vmware-modconfig"
if ! command -v vmware-modconfig >/dev/null 2>&1; then
logger -t vmware-modules-rebuild "ERROR: vmware-modconfig not found"
exit 1
fi
# vmware-modconfig builds against the running kernel's headers.
if /usr/bin/vmware-modconfig --console --install-all; then
logger -t vmware-modules-rebuild "rebuild complete for kernel ${KVER}"
else
logger -t vmware-modules-rebuild "ERROR: vmware-modconfig failed (headers for ${KVER} installed?)"
exit 1
fi