Installing Nvidia's Latest Drivers in Ubuntu using a Custom Compiled Kernel
I compiled the latest kernel 3.7.9 in my Ubuntu 10.04 Lucid following this guide here: http://www.howopensource.com/2011/08/how-to-compile-and-install-linux-kernel-3-0-in-ubuntu-11-04-10-10-and-10-04/
Everything worked properly, but I ran into problems when attempting to install Nvidia's latest drivers (version NVIDIA-Linux-x86-310.32). The DKMS build would not work and I received errors like "Unable to determine the target kernel version", "bad exit status 2", and "kernel header file does not exist" in the make.log file (along with others) in the /var/lib/dkms/nvidia folder. The installer would always fail. So, here's how to get the latest drivers installed and working properly with DKMS support.
First, we need to remove anything Nvidia that may already be installed. There may be some Nvidia packages that are already installed on your system even though you've yet to install the Nvidia drivers!
Step 1: Download Nvidia Driver and Blacklist Other Drivers:
You can download the Nvidia drivers from http://www.geforce.com/drivers
Nvidia Drivers will only install if you are not running X, so you'll have to install this in a terminal. Stop GDM before running the rest of the commands.
sudo service gdm stop
Now, we'll need to Blacklist some drivers. To do this, launch a terminal, and use the following commands:
sudo nano /etc/modprobe.d/blacklist.conf
Add the following entries to the bottom of the file:
blacklist vga16fb blacklist nouveau blacklist rivafb blacklist nvidiafb blacklist rivatv
Run the following command:
sudo apt-get --purge remove nvidia-*
Step 2: Creating Symbolic Links
For some reason, after compiling the latest kernel, the symbolic links the Nvidia installer relies on do not exist. We'll need to create them. Run the following commands in a terminal:
sudo ln -s /usr/src/linux-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-$(uname -r)/include/linux/version.h sudo ln -s /usr/src/linux-$(uname -r) /usr/src/linux
Step 3: Prerequisites
Install the following prerequisites by running these commands:
sudo apt-get install dkms
Step 4: Run the Nvidia Installer
Now, run the Nvidia installer and the DKMS module should build.
sudo sh NVIDIA-Linux-x86-310.32.run
Or whatever version you downloaded.