3.4. 安装 Nvidia OpenGL 驱动程序

3.4.1. 安装 NVIDIA 内核驱动程序包

首先,解包内核驱动程序源代码。
	cd /usr/src
	tar -xvzf NVIDIA_kernel-1.0-2314.tar.gz
	tar -xvzf NVIDIA_GLX-1.0-2313.tar.gz
	cd NVIDIA_kernel-1.0-2314
	
现在,在构建和安装此内核驱动程序之前,它有一些 AGP 选项可能会影响性能。在首次尝试使您的显卡正常工作时,您真的不应该尝试使用这些选项,除非您使用的是非常新的 2.4 内核和最新的 nvidia 驱动程序。

Linux 内核源代码可以使用 AGP 字符设备进行编译,Nvidia 驱动程序可以使用该设备来获得更好的性能。如果您的内核没有为您的主板芯片组编译 AGP 驱动程序,那么如果您的显卡是 AGP 显卡,则 Nvidia 内核驱动程序会使用其内置的 AGP 支持。如果您想尝试 Linux 内核 AGP 支持,您应该能够使用适当的支持重新构建和安装您的内核
	cd /usr/src/linux
	make menuconfig
	# Go to Character devices and put a * by /dev/agpgart support
	# and also put a * by your motherboard chipset type.
	# Go to the Processor type and features and put a * by
	# MTTR support.
	# Save the config.
	make
	make modules
	make install
	make modules_install
	reboot
	

可以对文件进行进一步的调整os-registry.c在 NVIDIA 内核源代码中。查看此文件,您将看到许多标志变量(它们可以设置为 0 或 1)来控制影响性能和稳定性的选项!您应该首先使用未修改的文件尝试您的配置,以查看您的系统是否正常工作。如果可以,您可以尝试这些选项。您可以在此处尝试的选项包括

Tip

如果您在启动 X 时遇到问题,请参阅文件TNT_USERS_READMEM64_USERS_README。这些文件解释了如何调整内核驱动程序。它们是为修复 TNTTNT2 M64 显卡的问题而编写的,但据报告,这些调整也有助于 GeForce2 MX。尝试绕过 BIOS,如M64_USERS_README.

在您调整(或未调整)您的 Linux 内核和os-registry.c文件之后,您可以构建和安装内核模块。
	# The make command will build and install the driver:
	make
	
驱动程序加载后,您可以使用 cat /proc/nv/card0 查看驱动程序配置

3.4.2. 安装 NVIDIA GLX 包

安装 Nvidia OpenGL 库包并没有什么特别的。首先,您需要清理一些旧文件。
	# delete the libGL.* files that come with XFree86 / Mesa ...
	# the nvidia libGL.* should replace them
	# The more recent Nvidia Makefile installer does this for you.

	cd /usr/X11R6/lib
	rm libGL.*
	cd modules/extensions
	rm libGL*
	rm libglx*
	cd /usr/lib
	rm libGL.*
	

在冲突的旧文件被删除后,您可以开始安装。
	cd ..
	cd NVIDIA_GLX-1.0-2313
	make
	ldconfig

	# make might not install the C header files that come with
	# the libraries in the NVIDIA_GLX package so, do this:
	cd usr/include/GL
	cp *.h /usr/include/GL
	# usr/include/GL is a subdirectory in the NVIDIA_GLX package.
	# /usr/include/GL should be a symlink to /usr/X11R6/include/GL
	# so you could copy to there instead if you want.

	# Make a basic XF86Config file using the "nv" driver:
	cd /etc/X11
	xf86config
	# Follow the prompts and fill in the information xf86config asks for.
	# Select the Nvidia GeForce or appropriate name.
	# You can test X with this XF86Config file, or continue for OpenGL:

	# You must edit XF86Config and set the following:
	vi XF86Config
	#	Load "glx"
	#	Replace 'driver "nv"' with 'driver "nvidia"'
	#	Put "1600x1200" first (or your preferred screen resolution)
	#	Copy ttf fonts from Windows into a font directory and add a font path.
    #            Use ttmkfdir (check freshmeat.net) to a fonts.dir file.
	#	A good place to keep your own fonts is /usr/local/share/fonts ...

	# Nvidia drivers do NOT use the dri module - don't load it.

        # You may like to edit /etc/X11/xinit/xinitrc to have run "startkde"
        # or "gnome-session" instead of twm.

	# Note: /usr/include/GL should be a symlink to /usr/X11R6/include/GL
	

XF86Config中为驱动程序指定 “nvidia” 会使每次您 startx 时都生效。但是NVdriver内核驱动程序必须在您 startx 之前加载。可以使用以下命令加载:
		# to load it
		insmod NVdriver
		# If you need to unload it:
		rmmod NVdriver
	
您不应该手动使用 insmod。 NVdriver 安装应该已在/etc/modules.conf(或conf.modules)中插入了一行,如下所示:
                alias char-major-195 NVdriver
        
如果此行存在,NVdriverX 启动时会自动加载。您可以使用命令 lsmod 检查它是否已加载。

根据我的经验,如果您编译、加载和卸载 NVdriver 模块,您的视频系统将变得不稳定。您应该在重新构建此模块后重新启动系统,以帮助确保您的系统不会在 X 中锁定。可能会发生您的屏幕变黑并且键盘在切换 NVdriver 后变得无响应。建议始终有另一台具有 telnet 或 ssh 的计算机,您可以使用它来进入您的 Linux 机器并在发生这种情况时正确关闭它。