What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

If you use VMWare Workstation or player on a Linux host, then you may need (from time to time) to recompile several kernel modules when you update or change your kernel (for example).

Usually you'll know when you need to do this when attempting to start a guest, it complains about vmmon not existing.

To recompile the required kernel modules:

sudo vmware-modconfig --console --install-all

Recompiling on each reboot

On one of my machines running the 5.4 kernel, I needed to use the patched vmware modules from mkubecek to get wmare workstation to work.  This worked but required me to recompile the modules after each boot (i.e. run the above command after each boot).

So, I created a quick and dirty systemd service to do this for me - that is recompile modules after each boot automatically.

Create a systemd service file in /etc/systemd/system with your preferred editor (I use vim here):

sudo vim /etc/systemd/system/vmware-modules-rebuild.service

and paste the following code into said file

/etc/systemd/system/vmware-modules-rebuild.service
[Unit]
Description=Recompiles vmware modules
Requires=vmware.service
Before=vmware.service
ConditionPathExists=!/dev/vmmon

[Service]
Type=oneshot
ExecStart=/usr/bin/vmware-modconfig --console --install-all

[Install]
WantedBy=multi-user.target

The above systemd service file assumes you have created/installed basic vmware systemd services, e.g. https://wiki.archlinux.org/index.php/VMware#systemd_services.

Once done reload systemd modules, then enable and start the service you just created:

sudo systemctl daemon-reload
sudo systemctl enable vmware-modules-rebuild
sudo systemctl start vmware-modules-rebuild

References

  1. https://kb.vmware.com/s/article/1002411
  2. https://github.com/mkubecek/vmware-host-modules
  3. https://wiki.archlinux.org/index.php/VMware#systemd_services