I generally try to avoid commercial software while running Linux. However, sometimes I just have to run VMWare. I particularly do not like how VMWare adds a bunch of unnecessary network interfaces at all times. Plus, its services are fairly resource intensive. So, I wrote a simple script to start and stop VMWare and all its services as I need them.
# Speed hack.
sudo su -c "echo never > /sys/kernel/mm/transparent_hugepage/enabled"
# Start VMWare services.
sudo systemctl start vmware-networks
sudo systemctl start vmware-usbarbitrator
sudo systemctl start vmware-hostd
# Run VMWare
# Stop VMWare services.
sudo systemctl stop vmware-networks
sudo systemctl stop vmware-usbarbitrator
sudo systemctl stop vmware-hostd
# Undo the speed hack.
sudo su -c "echo always > /sys/kernel/mm/transparent_hugepage/enabled"
The script first disables transparent hugepages. This is recommended on the Arch Wiki to improve the performance of VMWare. Transparent hugepages or THP is supposed to be an optimization itself. THP manages large pages of memory and speeds up allocations through techniques like defragmenting RAM. VMWare runs better without the OS trying to optimize memory allocation in the background.
After that, we just start the services and run the main program. Once the main program ends, we stop all the services and enable transparent hugepages again.
This is a simple script, but without it, I would be hesitant to put VMWare on my linux system. I want transparent hugepages running whenever I am not using VMWare because it usually speeds up the system. Similarly, I don’t want all the VMWare services running unless I am running VMWare itself. Sometimes the simplest scripts are the most useful.