Skip to content

Instantly share code, notes, and snippets.

@non7top
Created May 9, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non7top/8f26b37144349a13a81d to your computer and use it in GitHub Desktop.
Save non7top/8f26b37144349a13a81d to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the latest kernel installed
NEW_VERSION=`ls -tA1 /lib/modules | head -n 1`
# Check if the module is already present, if not- continue
if [ ! -e /lib/modules/$NEW_VERSION/misc/pvscsi.ko ]; then
# Log output to show version we're fixing
echo "Fixing VMware Paravirtual Drivers for reboot. Kernel: $NEW_VERSION"
# Find the current running kernel
OLD_VERSION=`uname -r`
if [ -f /lib/modules/$OLD_VERSION/pvscsi.ko ]; then
# Copy the existing module to new kernel tree
cp /lib/modules/$OLD_VERSION/pvscsi.ko /lib/modules/$NEW_VERSION -v
elif [ -f /lib/modules/$OLD_VERSION/misc/pvscsi.ko ]; then
# Copy the existing module to new kernel tree
mkdir /lib/modules/$NEW_VERSION/misc
cp /lib/modules/$OLD_VERSION/misc/pvscsi.ko /lib/modules/$NEW_VERSION/misc -v
else
echo "Old pvsci module not found, please install VMware tools"
fi
# Rebuild our modules cache
depmod -a $NEW_VERSION
# Create a new initrd, including the new pvscsi module
mkinitrd -f --with=pvscsi /boot/initrd-$NEW_VERSION.img $NEW_VERSION
else
# This would occur when module is already present
echo "VMware Paravirtual Drivers Fix Installed"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment