Skip to content

Instantly share code, notes, and snippets.

@shadowbq
Last active March 11, 2018 22:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadowbq/5897002b620b093ca7578b5f13c3f3a1 to your computer and use it in GitHub Desktop.
Save shadowbq/5897002b620b093ca7578b5f13c3f3a1 to your computer and use it in GitHub Desktop.
AskUbuntu SO #966585 - Post Kernel Upgrade
#!/usr/bin/env bash
# Must be run as root / sudo
# Reference: https://askubuntu.com/questions/966585/ubuntu-17-10-upgrade-broke-vmware-workstation-12-5
if [ $(dpkg-query -W -f='${Status}' linux-headers-generic 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Kernel Headers Package Missing"
echo "apt-get install linux-headers-generic";
exit 1
fi
if [ ! -d "/usr/lib/vmware/modules/source/vmmon-only/" ]
then
echo "Failed to find expanded source vmmon"
exit 1
if [ ! -d "/usr/lib/vmware/modules/source/vmnet-only/" ]
then
echo "Failed to find expanded source vmnet"
exit 1
fi
fi
current_kernel=$(uname -r)
kern_dir=$(find /lib/modules/ -maxdepth 1 -type d|sort -n|tail -1)
latest_kern=${kern_dir##*/}
if [ $latest_kern == $current_kernel ]
then
echo "Running current kernel: $current_kernel "
else
echo "Current Running kernel, and latest downloaded kernel do not match."
echo "Running kernel: $current_kernel "
echo "Latest kernel downloaded: $latest_kern "
echo "Reboot likely required!..exiting"
exit 1
fi
if [ ! -f "$kern_dir/misc/vmmon.ko" ]
then
echo "Building New kernels modules"
mkdir -p $kern_dir/misc/
cd /usr/lib/vmware/modules/source/vmmon-only/
make clean
make
cp ./vmmon.ko $kern_dir/misc/
cd /usr/lib/vmware/modules/source/vmnet-only/
make clean
make
cp ./vmnet.ko $kern_dir/misc/
else
echo "Found Kernel Modules"
modinfo $kern_dir/misc/vmmon.ko
modinfo $kern_dir/misc/vmnet.ko
fi
kernel_count=$(lsmod|grep 'vm[mon|net]'|wc -l)
if [[ $kernel_count -lt 2 ]];
then
echo "Reloading Kernel Modules"
rmmod -v vmmon.ko 2>/dev/null
insmod $kern_dir/misc/vmmon.ko
rmmod -v vmnet.ko 2>/dev/null
insmod $kern_dir/misc/vmnet.ko
lsmod |grep 'vm[mon|net]'
else
echo "Kernel Modules Loaded Already"
fi
vmnetwork_status=$(vmware-networks --status 2>/dev/null |grep 'is not running' |wc -l)
if [[ $vmnetwork_status -gt 0 ]];
then
echo "Starting VMware Networks"
vmware-networks --start
fi
if ! vmware-networks --status; then
echo "Error handling vmware-networks..exiting"
exit 1;
fi
#!/usr/bin/env bash
echo "Launching VMWare Workstation Wrapper"
echo "Starting VMkernel Prep"
if sudo /opt/vmware-kernel-hack/vmkernel_prep.sh; then
echo "Starting VMware Workstation"
/usr/lib/vmware/bin/vmware
else
echo "Error in vmware kernel prep"
exit 1
fi
@shadowbq
Copy link
Author

Running when only needing to do a check

sudo ./vmkernel_prep.sh 
Running current kernel: 4.13.0-32-generic 
Found Kernel Modules
filename:       /lib/modules/4.13.0-32-generic/misc/vmmon.ko
supported:      external
license:        GPL v2
description:    VMware Virtual Machine Monitor.
author:         VMware, Inc.
srcversion:     AEBBB319B859FEE8B426D01
depends:        
name:           vmmon
vermagic:       4.13.0-32-generic SMP mod_unload 
filename:       /lib/modules/4.13.0-32-generic/misc/vmnet.ko
supported:      external
license:        GPL v2
description:    VMware Virtual Networking Driver.
author:         VMware, Inc.
srcversion:     05614E77E7E46CC06B6048D
depends:        
name:           vmnet
vermagic:       4.13.0-32-generic SMP mod_unload 
parm:           vnet_max_qlen:Maximum queue length of the vmnet, default is 1024, maximum is 1024 (uint)
Kernel Modules Loaded Already
Bridge networking on vmnet0 is running
DHCP service on vmnet1 is running
Hostonly virtual adapter on vmnet1 is enabled
DHCP service on vmnet8 is running
NAT service on vmnet8 is running
Hostonly virtual adapter on vmnet8 is enabled
All the services configured on all the networks are running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment