-
-
Save RobertCNelson/7626ad7fcd1df541bc2aab0d530a2fc6 to your computer and use it in GitHub Desktop.
Permanently fix VMWare kernel module sources for Kernel 4.6+ and (re-)build them (can be run multiple times)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
KMAJ="$(uname -r | cut -d. -f1)" | |
KMIN="$(uname -r | cut -d. -f2)" | |
if [ "${KMAJ}" != "4" ]; then | |
echo "This script has to be run on a 4.x kernel." 1>&2 | |
exit 1 | |
fi | |
VM_SRC_DIR=/usr/lib/vmware/modules/source | |
cd $VM_SRC_DIR | |
if [ ! -f vmmon.tar.bak ] ; then | |
cp vmmon.tar vmmon.tar.bak | |
else | |
rm -rf vmmon.tar | |
cp vmmon.tar.bak vmmon.tar | |
fi | |
if [ ! -f vmnet.tar.bak ] ; then | |
cp vmnet.tar vmnet.tar.bak | |
else | |
rm -rf vmnet.tar | |
cp vmnet.tar.bak vmnet.tar | |
fi | |
tar -xf vmmon.tar | |
tar -xf vmnet.tar | |
# if running on a 4.8 kernel | |
if [ "${KMIN}" -ge "8" ]; then | |
echo "Detected 4.8 Kernel. Patching NR_ANON_PAGES->NR_ANON_MAPPED..." 1>&2 | |
sed -i -e 's/NR_ANON_PAGES/NR_ANON_MAPPED/g' vmmon-only/linux/hostif.c | |
else | |
echo "Detected NO 4.8 Kernel. Will not apply 4.8 patches" 1>&2 | |
fi | |
# if running on a 4.7 kernel | |
if [ "${KMIN}" -ge "7" ]; then | |
echo "Detected 4.7 Kernel. Patching 'dev->trans_start'..." 1>&2 | |
sed -i -e 's/dev->trans_start = jiffies/netif_trans_update\(dev\)/g' vmnet-only/netif.c | |
else | |
echo "Detected NO 4.7 Kernel. Will not apply 4.7 patches" 1>&2 | |
fi | |
# if running on a 4.6 kernel | |
if [ "${KMIN}" -ge "6" ]; then | |
echo "Detected 4.6+ Kernel." 1>&2 | |
sed -i 's/get_user_pages(/get_user_pages_remote(/' vmmon-only/linux/hostif.c | |
sed -i 's/get_user_pages(/get_user_pages_remote(/' vmnet-only/userif.c | |
else | |
echo "Detected NO 4.6 Kernel. Will not apply patches" 1>&2 | |
fi | |
tar -cvf vmmon.tar vmmon-only | |
rm -rf vmmon-only | |
tar -cvf vmnet.tar vmnet-only | |
rm -rf vmnet-only | |
# now (re-) build kernel modules with | |
sudo vmware-modconfig --console --install-all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment