Friday, 5 October 2007

Building the NVidia driver for multiple kernels

Well I am one of the lucky people who has a notebook that is so new the nvidia driver that comes with Kubuntu does not support the graphics card. Fortunately NVidia have invested time and money supporting the Linux community and have developed a Linux installer that compiles kernel modules with the relevant drivers for the cards. Sweet.
You can download the install from nvidia.com, my one is called NVIDIA-Linux-x86_64-100.14.11-pkg2.run but presumably this will be updated from time to time. It is dead simple, you can simply type:

sudo sh ./NVIDIA-Linux-x86_64-100.14.11-pkg2.run

and it does the biz but bear in mind that you have to make sure you have your linux kernel header packages installed because the run package will need them. The instructions on the nvidia site will suffice but I had another problem...
The installer by default builds the module for the currently running kernel which might be mostly fine but what do you do when either you are upgrading the kernel or you have several bootable kernels?
Once the run package is executed, it should install "nvidia-installer" and this is the baby that does the hard work. There are two switches that you should be aware of. Firstly if you are running the installer to build a driver for a kernel that is not running, you must use:

sudo nvidia-installer --kernel-name='2.6.22-10-generic'

The name is how the installer will look for the source directories so you have to get it right. If you don't install the linux-headers packages for the target kernel you will get an error.
The second switch that is important is for when you already have the driver installed for one kernel and you want to build it for another one without uninstalling the current one, use:

sudo nvidia-installer --kernel-module-only

You might need to combine the two flags depending on whether your current kernel image is the target.
If you want to build the driver for a new kernel after it is installed, simply press esc in the grub menu and boot the recovery mode for the kernel, you will be logged in as root. Type "telinit 3" which will boot you to a text login (you can theoretically do this with a broken X driver by pressing ctrl-F2 or something but it didn't work for me). Log in and then run the second flavour of nvidia-installer above and then you don't have to fuss about knowing the exact kernel name to pass to the installer. Once this is done, type "startx" and it should be fine.
Post a Comment