3.7.7内核的nVidia驱动安装

Posted on Feb 17, 2013

更新3.7.7内核之后,nVidia显卡驱动需要重新编译,但是这次和以前不一样,安装时报错导致无法继续。

问题分析

根据报错的信息,可以打开日志文件查看详细的原因:

    less /var/log/nvidia-installer.log

日志信息如下:

-> Kernel source path: ‘/lib/modules/3.7.7-201.fc18.i686.PAE/source’ -> Kernel output path: ‘/lib/modules/3.7.7-201.fc18.i686.PAE/build’ ERROR: If you are using a Linux 2.4 kernel, please make sure you either have configured kernel sources matching your kernel or the correct set of kernel headers installed on your system.

If you are using a Linux 2.6 kernel, please make sure you have configured kernel sources matching your kernel installed on your system. If you specified a separate output directory using either the “KBUILD_OUTPUT” or the “O” KBUILD parameter, make sure to specify this directory with the SYSOUT environment variable or with the equivalent nvidia-installer command line option.

Depending on where and how the kernel sources (or the kernel headers) were installed, you may need to specify their location with the SYSSRC environment variable or the equivalent nvidia-installer command line option. ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

大概原因是安装脚本无法确认系统版本,因而没有指定KBUILD_OUTPUT之类的参数。

解决方案

因为需要对驱动的安装脚本作修改,因此需要解压缩安装包

    ./NVIDIA-Linux-x86-310.19.run -x

修改文件 contest.sh

    cd NVIDIA-Linux-x86-310.19/
    vi kernel/conftest.sh

修改:1697行附近的代码,如下:

# kernel older than 2.6.6, that's all we require to
# build the module.
#
VERSION=$(grep "^VERSION =" $MAKEFILE | cut -d " " -f 3)
PATCHLEVEL=$(grep "^PATCHLEVEL =" $MAKEFILE | cut -d " " -f 3)
SUBLEVEL=$(grep "^SUBLEVEL =" $MAKEFILE | cut -d " " -f 3)

if [ -n "$VERSION" -a $VERSION -ge 3 ] || 
   [ -n "$PATCHLEVEL" -a $PATCHLEVEL -ge 6 
		 -a -n "$SUBLEVEL" -a $SUBLEVEL -le 5 ]; then
	 SELECTED_MAKEFILE=Makefile.kbuild
	 RET=0
fi

修改:160行附近的代码,如下:

if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]; then
  CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include"
  CFLAGS="$CFLAGS -I$SOURCES/arch/x86/include/uapi"
  CFLAGS="$CFLAGS -I$OUTPUT/arch/x86/include/generated"
  CFLAGS="$CFLAGS -I$OUTPUT/arch/x86/include/generated/uapi"
保存文件并运行安装:

	./nvidia-installer

现在应该可以通过正常安装了。


参考资料

  1. https://bugs.archlinux.org/task/33827
  2. http://forums.fedoraforum.org/showthread.php?t=288869
  3. http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/x11-drivers/nvidia-drivers/files/nvidia-drivers-313.18-linux-3.7%2B.patch?revision=1.1