首页 > 代码库 > Compile NVIDIA driver on Lenovo W520 with Debian
Compile NVIDIA driver on Lenovo W520 with Debian
Originally, I installed an Ubuntu using Wubi on my company‘s laptop (Lenovo W520). One purpose is for fun, the other is to use some instant messengers, which are blocked by default on our Windows system. Now, having come to Switzerland, Skype is no doubt the best tool for international communication, which can only be installed on Linux system however.
In order to have better system performance, I decided to change Wubi to Debian. Actually speaking, Debian has much worse user experience than Ubuntu. For example, it does not support NVIDIA graphic display by default. Therefore, I had to download the NVIDIA driver and compiled it into the Linux kernel. The following things must be prepared beforehand:
Check Linux kernel version and the gcc version which compiled this kernel
cat /proc/version
Linux version 2.6.32-5-amd64 (Debian 2.6.32-46) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Sun Sep 23 10:07:46 UTC 2012
My Linux kernel version is: 2.6.32-5-amd64 (Debian 2.6.32-46) (the corresponding package is linux-image-2.6.32-5-amd64 with a detailed version number 2.6.32-46). The version of gcc compiling this kernel is: 4.3.5 (Debian 4.3.5-4)
Install the gcc compiler with the above version 4.3.5 (Debian 4.3.5-4)
Usually, there may be a gcc compiler with a higher version than the one that compiled the kernel. For example, on my system, the default gcc version is 4.4.5 (Debian 4.4.5-8), which is higher than the kernel compiler 4.3.5 (Debian 4.3.5-4). Then, we should create a symbolic link gcc in /usr/bin to the compiler we want:
ln -sf /usr/bin/gcc-4.3 /usr/bin/gcc
Install corresponding linux-source package
For me, it is linux-source-2.6.32 with a detailed version number 2.6.32-46. The NVIDIA driver will be compiled through a kernel interface, which is special layer between the Linux kernel and the NVIDIA driver. This compilation requires this linux-source package installed.
NVIDIA kernel module
I‘ve also installed the package nvidia-kernel-195.36.31, which provides the non-free NVIDIA kernel module. With this installed, the video display is still not correct. Therefore, I‘m not sure what is its actual function. But for safety, just keep this package.
Download NVIDIA driver from its official website. The file for me is NVIDIA-Linux-x86_64-304.64.run.
With everything at hand, just run NVIDIA-Linux-x86_64-304.64.run to compile and install the NVIDIA kernel module. After that, run nvidia-xconfig to generate a xorg.conf file.
One more thing to be paid attention to is the BIOS option for graphics card. Instead of using OS detection for NVIDIA Optimus, we should use Discrete Graphics.