Reconfigure Nvidia driver for the new kernel
As you know, when you're upgrading your Linux Kernel and restart, your nvidia driver need to be compile for the new kernel ( This is only apply to manual installed Nvidia driver, if you installed your driver from Hardware Drivers, so you don't have to recompile it )
In this post, I'll show you how to automatically compile nvidia driver when you installed a new kernel.
Firstly, you'll need the driver, you can get it from nvidia.com, or as you manually installed nvidia drivers, it should be downloaded already. Move this file to /usr/src/ folder and rename it make a symbolic link named nvidia-driver. For example, when you have the beta driver 185.19:
sudo install NVIDIA-Linux-185.pkg.run /usr/src sudo ln -s /usr/src/NVIDIA-Linux-185.pkg.run /usr/src/nvidia-driver
So you had the property driver, each time you upgrade your driver, remember to edit the symbolic link to the new file. And now, open your favorite editor and copy those code.
#!/bin/bash # # Set this to the exact path of the nvidia driver you plan to use # It is recommended to use a symlink here so that this script doesn't # have to be modified when you change driver versions. DRIVER=/usr/src/nvidia-driver # Build new driver if it doesn't exist if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then echo "NVIDIA driver already exists for this kernel." >&2 else echo "Building NVIDIA driver for kernel $1" >&2 sh $DRIVER -K -k $1 -s -n 2>1 > /dev/null if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then echo " SUCCESS: Driver installed for kernel $1" >&2 else echo " FAILURE: See /var/log/nvidia-installer.log" >&2 fi fi exit 0
Save it as update-nvidia and then
sudo mkdir -p /etc/kernel/postinst.d sudo install update-nvidia /etc/kernel/postinst.d
And now, each time you upgraded a new kernel version, your nvidia driver will recompile.
But what if you've upgraded a new kernel and the driver stopped working. I know that whenever you restart your PC, the driver will not get compile ( because the kernel will not call postinst anymore ). So the solution is: Run update-nvidia manually
sudo sh update-nvidia `uname -r`
Remember that `uname -r` is required for the script.
That's all, restart your computer and enjoy with nvidia ![]()

Comments