Submit News Alternative Tip Form

Automatically Install Your Nvidia Driver For New Kernels – Hands Free!

Notice: This post is more than a year old. It may be outdated.

If you manually install your Nvidia drivers- be they beta or stable releases – you’ll probably have noticed that you need to manually reinstall them every time you receive a kernel update via update manager.

Thankfully you can solve this annoyance with a simple script that automates the process of rebuilding your driver for a newer kernel. As such when a new kernel is released, your graphics driver updates too and you need to do next to nothing to benefit!

Kudos must first go to Ubuntuforums member sdennie who wrote the original guide from which I’m writing this.

Firstly this will only work for people who have manually download and installed their Nvidia drivers. If you’ve used EnvyNG or synaptic – this won’t work.

It also requires you to have successfully installed your driver prior to this; if you installed it and it works then you’re good to go; you can safely use this script from now on to take the hassle out of kernel updates.

  • Nvidia Linux Download Site 

Let’s Go!
First you’re going to need to get a copy of the driver you’re currently using from the Nvidia site. Save it to your home folder.

Now we’re going to move it and make a symlink to it. This is simply for ease of use if you change driver at some point.

  • sudo mv /usr/src
A tip is simply to tpye the first few letters of your driver’s name and then hit TAB. This will auto-complete it.
Mine looked like this: –
  • sudo mv  /usr/src/
Now we need to make the symlink
  • sudo ln -s /usr/src/ /usr/src/nvidia-driver
This is how mine looked: –

  • sudo ln -s /usr/src/ /usr/src/nvidia-driver

The Script

Download the script from my dropbox @
Alternatively grab the code from pastebin @
The script checks to see if the kernel to be installed has the Nvidia driver already installed supporting it. If not it will do the dirty for you and build it.
Install The Script
Make sure the script is in your home folder and is named ‘update-nvidia’. Then open the terminal and whack the following in. (Being careful, mind!)
  • sudo mkdir -p /etc/kernel/postinst.d
  • sudo install update-nvidia /etc/kernel/postinst.d
That, my jolly audience, is that!
Upon the next release of a major Kernel update the script will automatically build the driver to your kernel, requiring you to do naff all!