Compile Nvidia Driver 195.36.31 for Debian Squeeze with backported kernel

I’ve been trying to get a backported kernel to work on my installation of Debian Squeeze, but it seems some include files are not included in recent kernel versions. There are also some issues with Kernel version checks in the Nvidia Makefiles.

I finally got it to work by combining information from the Debian Wiki and Paul Goins’ blog at vultaire.net

For Kernels 2.6.32.x and below
1.apt-get install module-assistant nvidia-kernel-common
2. m-a auto-install nvidia-kernel${VERSION}-source
3. apt-get install nvidia-glx${VERSION}
4. Create an xorg.conf with the following content (if it doesn’t already exist):

Section "Module"
Load        "glx"
EndSection

Section “Device”
Identifier  “Video Card”
Driver              “nvidia”
EndSection

5. Restart the computer
6. Test that acceleration is working with:
glxinfo |grep rendering

********************************************************
IF you change the kernel (e.g upgrade from squeeze to wheezy), you have to redo step 1 and 2
See http://wiki.debian.org/NvidiaGraphicsDrivers#Libraries for details

For 2.6.38.x or 3.2.x
=========
1. Save the release number of your kernel in a couple of environment variables:

export KVERS=$(uname -r)
export KSRC=/usr/src/linux-headers-$KVERS
export KPKG_DEST_DIR=/usr/src

2. Install the kernel module source: run
apt-get install nvidia-kernel-source nvidia-kernel-common
3. This will give you a source tarball /usr/src/nvidia-kernel.tar.bz2. Unpack it with

cd /usr/src
tar -jxf nvidia-kernel.tar.bz2

4. Install the header files for your kernel:
apt-get install linux-headers-$KVERS

5. Make some amendments in the source files:
cd /usr/src/modules/nvidia-kernel

6. Paste the below at the bash prompt (as root)

# Create fake smp_lock.h
cd /lib/modules/$(uname -r)/source/include/linux
if [ ! -e "smp_lock.h" ]; then
touch smp_lock.h
echo "Created dummy smp_lock.h."
fi

# Link to relocated autoconf.h
cd /lib/modules/$(uname -r)/build/include/linux
ln -sv ../generated/autoconf.h

6.5 Download this patch file nvidia-3.x-kernel-module-patch, extract the patch file and copy it to /usr/src/modules/nvidia-kernel. Then run the commands below:

cd /usr/src/modules/nvidia-kernel
patch -Np1 -i nvidia-3.x-kernel-module-patch

N.B. The patch is based on http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html

7. Build the kernel module package:

debian/rules binary-modules

8. Install the kernel module. Use the fileglob below if you want, but watch out that you don’t have more than one nvidia-kernel package file lying around in /usr/src

dpkg -i /usr/src/nvidia-kernel-*.deb

9. Install the X driver and user-space libraries package

apt-get install nvidia-glx${VERSION}

10. Create an xorg.conf with the following content (if it doesnt already exist):
Section "Module"
Load        "glx"
EndSection

Section “Device”
Identifier  “Video Card”
Driver              “nvidia”
EndSection

11. Restart the computer
12. Test that acceleration is working with:
glxinfo |grep rendering

Print Friendly

1 Comment

  1. Rob says:

    I found this a lot easier to follow than all the bits scattered over the web. Installed the nVidia driver on Squeeze with the current 3.2.x branch backported kernel with no problems.

    Thank you for taking the time to write it 🙂

Leave a comment