HOWTO nVidia Drivers

出自Gentoo Linux Wiki

跳转到: 导航, 搜索
这篇文章属于 HOWTO 系列的一部分。
安装方法 架构/平台 内核 & 硬件 Portage 系统相关 网络 & 服务器 X服务器 软件 游戏 非x86平台

目录

[编辑] 介绍

First off, why this guide when there is already an official one? The answer is that the official one leaves out some stuff, and well, the wiki is really where this should all be.

[编辑] 说明: Legacy and Current

The nVidia Unified Driver Architecture is a single set of drivers that support all nVidia graphics cards. Well, at least that's how it used to be. Now there are two classes of the UDA. Current and Legacy.

[编辑] Current

The current drivers are the 75-series and 80-series drivers which would more aptly be named the 8000-series since the drivers are all on a x.x.xxxx format versioning system where the last for digits are what nVidia currently uses for primary distinction seeing as the first two have been 1.0 for a really long time. Most nVidia cards are supported by these drivers.

If you are running a stable system then the current drivers are still 1.0.6629. To gain access to either the legacy (70) or current (80) series packages you will need to add: #echo "media-video/nvidia-kernel ~x86" >> /etc/portage/package.keywords

  1. echo "media-video/nvidia-glx ~x86" >> /etc/portage/package.keywords
Note: The ~x86 is not 100% required as it is assumed if you leave it out, but here it makes it obvious what you are doing - unmasking an unstable package.

[编辑] Legacy

The Legacy drivers are the 6x-series and 70-series drivers. Please note that 70 is just how nVidia puts it. In truth, it should be the 71-series as the only drivers that fall under this catagory are all version 1.0.71xx. The gentoo.org official guide tells legacy users to do a >media-video/nvidia-kernel-1.0.6629-r4 and >media-video/nvidia-glx-1.0.6629-r7 hard mask but that leaves you with 6x-series drivers which have been proven rather unreliable, and in many cases completely broken(my system falls under this catagory with a GeForce2 Pro). nVidia recommends the 70-series drivers and so do I as the compatibility doesn't break untill 7500(which doesn't actually exist but makes for a nice breaking point). Users of the following cards must use the Legacy drivers - applying the hard mask will be discussed later on.

  • TNT2
  • TNT2 Pro
  • TNT2 Ultra
  • TNT2 Model 64 (M64)
  • TNT2 Model 64 (M64) Pro
  • Vanta
  • Vanta LT
  • GeForce 256
  • GeForce DDR
  • GeForce2 GTS
  • GeForce2 Pro
  • GeForce2 Ti
  • GeForce2 Ultra
  • GeForce2 MX Integrated graphics
  • Quadro
  • Quadro2 Pro
  • Quadro2 EX

[编辑] Preparing Your System

The nVidia UDA supplies its own kernel and xorg modules, these are respectively held in the ebuilds 'nvidia-kernel' and 'nvidia-glx'. You therefore, need to make sure your kernel is set up to support module loading. The kernel module also requires access to MTRRs(Memory Type Range Registers) so we need to make sure that both these are enabled in your kernel.

[编辑] Making sure you've got the right kernel selected

Before merging anything, you should make sure that your /usr/src/linux symlink is pointed to the right kernel sources. Basically, just make sure the output from 'uname' and 'ls -l /usr/src/linux' match.

代码: Figure out which kernel is currently running
#uname -r
2.6.15-no4
代码: Get the value of the symlink
 #ls -l /usr/src/linux
 lrwxrwxrwx  1 root root 16 Feb 17 13:33 /usr/src/linux -> linux-2.6.15-no4

Now, if the results match, like in the above examples, then you're good, and can move on to Required Kernel Settings. If not, then we need to point the symlink in the right direction.

代码: Get a list of sources available
#ls -l /usr/src
total 2
lrwxrwxrwx  1 root root   16 Feb 17 13:33 /usr/src/linux -> linux-2.6.15-no4
drwxr-xr-x 20 root root 1360 Feb 18 21:17 /usr/src/linux-2.6.15-no4
drwxr-xr-x 20 root root 1360 Feb 18 22:34 /usr/src/linux-2.6.15-ck2


代码: Point the symlink to the right source
#ln -snf /usr/src/linux-2.6.15-ck2 /usr/src/linux

Your /usr/src/linux symlink should now point to the right place.

[编辑] 内核的必选项

Note: If you built your kernel with genkernel then you should be able to skip this section.

There are only two options you need to make sure of here, but first, lets get you into the configuration menu.

代码: Access your kernel's config menu
#cd /usr/src/linux
#make menuconfig

Now that we're in the menu just find the following options and make sure they are enabled.

Linux Kernel Configuration: .config
Loadable Module Support --->
 [*] Enable Loadable Module Support

You'll probably want to enable module unloading as well:

Loadable Module Support --->
   [*] Module Unloading

Then back up and enable MTRR Support:

Processor Type and Features --->
 [*] MTRR (Memory Type Range Register) Support

If the options have already been set then you can skip the rest of this section. If not, then you'll need to remake your kernel and install it.

[编辑] Rebuilding and Reinstalling your Kernel

First make sure your boot partition is mounted then from /usr/src/linux directory, simply run the following code.

代码: Rebuild and Install Kernel
#make
#make modules_install
#cp arch/i386/boot/bzImage /boot/wmlinuz-2.6.15-no4{replace with your kernel}
#cp .config /boot/.config-2.6.15-no4{replace with your kernel}
Note: If you copied to a new file instead of overwriting the existing kernel then you'll need to point your bootloader to the right file.
Note: You need the make modules_install if you have changed your kernel to support module unloading, for example, because the old modules won't work and you get a crash on restart.

At this point you may want to reboot into the new kernel.

[编辑] Legacy Users Only: Applying Hard Mask to Packages

Applying a hard mask is insanely simple, just follow the commands below:

代码: Applying Hard Mask to nVidia Packages
#echo ">=media-video/nvidia-kernel-1.0.7500" >> /etc/portage/package.mask
#echo ">=media-video/nvidia-glx-1.0.7500" >> /etc/portage/package.mask

[编辑] 安装软件包

Now, we just merge the packages.

代码: Merging the Packages
#emerge nvidia-kernel nvidia-glx

Once your emerges are complete, you may have to run an etc-update to merge in the module settings then, if you're not using udev(which most gentoo users are) then move on to the next section. For those of you that are using udev, please skip ahead to the troubleshooting section under UDev Users: Fix Device Creation Problem.

[编辑] 配置 XOrg/X11

Configuring XOrg is relatively easy. The xorg.conf file is pretty straight forward, you just have to get used to the syntax.

[编辑] 切换到新的驱动

By default, most versions of X have an nvidia driver installed or at least available called 'nv'. For those of you thinking this might be enough, it offers no hardware acceleration whatsoever so, if this is the driver for you, then you might as well give your nVidia card to someone who'll use it -i.e. me(LTBoy) and pick up an old Cirrus card or something. Anyhow, if X is already up and running, then it's probably doing so under the 'nv' driver. So, let's just 'nano -w /etc/X11/xorg.conf'(please replace 'nano -w' with whatever text editor you use, if X is up and running then leafpad is a good choice).

Find the 'Device' section where your nVidia card is and simply replace the driver with 'nvidia'

代码: Change Driver to 'nvidia'

OLD:

 Section "Device"
  Identifier "GeForce2 Pro/GTS"
  Driver     "nv"
  VideoRam   65536
 EndSection

NEW:

 Section "Device"
  Identifier "GeForce2 Pro/GTS"
  Driver     "nvidia"
  VideoRam   65536
 EndSection

[编辑] 去除 nVidia Splash Screen

At this time, you may also want to disable that rather annoying nVidia splash screen:

代码: Disable Splash
 Section "Device"
  Identifier "GeForce2 Pro/GTS"
  Driver     "nvidia"
  VideoRam   65536
  Option     "NoLogo" "true"
 EndSection

[编辑] 激活 nVidia GLX

Now we need to activate the glx module:

代码: Enable GLX Module

Your 'Module' section probably looks like this:

 Section "Module"
  ...
 # Module "glx"
  Module "dri"
  ...
 EndSection

Just switch the two, killing DRI and enabling GLX

 Section "Module"
  ...
  Module "glx"
 # Module "dri"
  ...
 EndSection

Now, the module is enabled in configuration, but, in order for it to work, you must be running a 16 or 24-bit color mode.

The easiest way to do this is to set a DefaultDepth setting in the 'Screen' section. Please note that there must be 16-bit and/or 24-bit modes in the "Display" subsection of your "Screen" section.

代码: Setting a Default Color Depth
 Section "Screen"
  ...
  DefaultDepth 24
  SubSection "Display"
   ...
  ...
 EndSection

Now, we just need to switch our opengl over to use the new nVidia driver.

代码: Switch the OpenGL Driver

The Old But Still Widely Used Way

 #opengl-update nvidia

The New Way(Use this if the above command says 'command not found')

 #eselect opengl set nvidia

[编辑] Wrap It Up

We're almost done. Now we just need to make sure you're part of the 'video' group and then (re)start X.

[编辑] Adding Users to the Video Group

Just repeat the following command for each user you want to add. Note that root has access to everything, so you don't need to add root to the video group.

代码: Adding a User to the Video Group
 #gpasswd -a <username> video

[编辑] (Re)Starting X

Now, if you're not already in X the run 'startx' to get the basic TWM layout and make sure everything works. If you are running X already, then just exit via your window manager/desktop environment and, if you use an XDM login manager(GDM,KDM,Entrance,etc...) X should restart with the new configuration. If it doesn't then a CTRL+ALT+Backspace ought to do the trick.

[编辑] Testing Your Configuration

Now we just need to make sure it's all set up right. If it is then you should get the following

代码: Testing Your Configuration
 #glxinfo | grep direct
 direct rendering: Yes

And if you really want, X has a simple benchmark tool called glxgears. Just run it from a terminal window and you can watch three gears spin around while it spits FPS data to your terminal.

[编辑] Troubleshooting

[编辑] UDev Users: Fix Device Creation Problem

UDev doesn't like nVidia... or maybe nVidia doesn't like UDev. Either way, you have to run 'NVmakedevices.sh' to build the character devices that allow your computer to access your card. Here's the rub. You'll probably have to run NVmakedevices.sh every time you boot up your computer. Which isn't difficult. Just do the following:

代码: Build nVidia Devices on Boot
 #echo 'NVmakedevices.sh' >> /etc/conf.d/local.start

Ok, problem solved. Your local.start script will run NVmakedevices.sh during boot, before the computer switches to your default runlevel so you're safe to have your computer boot into GDM or whatever graphical login manager you choose... Well, relatively safe - See: TIP Fix The Login Security Hole

[编辑] Getting 2D to work on machines with 4Gb or more memory

Copied From Gentoo.org Guide

If you are having troubles with the nVidia 2D acceleration it is likely that you are unable to set up a write-combining range with MTRR. To verify, check the contents of /proc/mtrr:

代码: Checking if you have write-combining enabled
 # cat /proc/mtrr

Every line should contain "write-back" or "write-combining". If you see a line with "uncachable" in it you will need to change a BIOS setting to fix this.

Reboot and enter the BIOS, then find the MTRR settings (probably under "CPU Settings"). Change the setting from "continuous" to "discrete" and boot back into Linux. You will now find out that there is no "uncachable" entry anymore and 2D acceleration now works without any glitches.

[编辑] I receive warnings about unsupported 4K stack sizes

Copied From Gentoo.org Guide

nvidia-kernel packages older than 1.0.6106 only support kernels using an 8K stack size. More recent kernels (2.6.6 and higher) have support for 4K stack size's as well. Do not select 4K stack size in your kernel configuration if you are using such an nvidia-kernel package. You can find this option in the section Kernel Hacking.

[编辑] When I attempt to load the kernel module I receive a "no such device"

Copied From Gentoo.org Guide

This usually occurs when you don't have a matching video card. Make sure that you have an nVidia-powered graphical card (you can double-check this using lspci).

If you are confident that you have an nVidia card, check your BIOS and see if the directive Assign IRQ to VGA is set.


[编辑] When I attempt to load the kernel module I receive a "insmod: error inserting ... Invalid module format"

This type of error can be diagnosed by running:

代码:

dmesg

The output from this command will indicate the source of the problem. In my case at least it was due a kernel misconfiguration
代码:

should be "<arch><kernel> preempt <gcc version>"

If the kernel is not compiled to be a preemptible kernel then trying to insert the nvidia.ko module will fail. To make the kernel preemptible use your favorite text editor to modify your kernel's configuration file (defaultly .config) and be sure to ammend:

代码: Adding or modifying the CONFIG_PREEMPT setting

CONFIG_PREEMPT=y

As well as commenting out all other CONFIG_PREEMPT type options.

Recompile, and installing the nvidia module should work successfully. --Pderry 18:45, 15 March 2006 (GMT)