Updated: November 30, 2013
All right. Until recently, I have never had an opportunity slash bothered to try Fedora on a system with Nvidia drivers. I did a similar thing with other RedHat family distros, like CentOS and Scientific. But not Fedora, and I did encounter some issues.
In this guide, I will show you several methods how to safely install Nvidia drivers in your Fedora distribution so that you can make the best use of your graphics card. Today you will learn how to approach the problem and get the system up and running, as well as recover from potential bodges that may arise. Anyhow, enough teasing, after me, lads.
The very first thing you will want to do, once your Fedora boots, is to fully update the system. This is crucial, because you want the running kernel and kernel headers, identified by the kernel-devel package, to be identical before installing the Nvidia drivers, otherwise the procedure may fail. Repeat until no more updates are available.
If you browse the Web carefully, you will notice many guides telling you how you can discover whether your machine is Nvidia-capable so to speak. I will skip this step, because the whole reason you're here is because you know that your machine has an Nvidia card, and this is why you want the appropriate drivers for your system. However, if you still feel somewhat insecure, check my general Linux guide first.
Now, on Nvidia-enabled systems, by default, you will have the open-source Nouveau driver running. It will have to go before you can use your Nvidia driver. But we will not try anything manually for now. We will attempt simple, automatic methods first.
You will need to configure additional repositories before you can search and install the desired drivers, because Fedora only ships with FOSS stuff by default. I have highlighted how you can configure repositories in a RedHat-family friendly repo guide, originally written for Scientific, but still quite useful here.
Alternatively, you can use a tool like easyLife, which will do the same thing for you. It will automatically configure the extra repositories, like RPMforge, renamed RepoForge, and then allow you to install the Nvidia graphics drivers.
If you do not feel comfortable using this tool, you can then install the drivers on your own using the yum package manager from the command line. Basically, what you need is:
yum install akmod-nvidia xorg-x11-drv-nvidia-libs
The first package, akmod-nvidia, will automatically recompile your kernel module for new kernels on every boot, if necessary, which means you will not have to manually reinstall drivers every time there's a kernel update. You can also try kmod-nvidia, for that matter, only you might not have the comfort of automatic driver updates.
After the driver is installed, you can reboot. In theory, you can just stop the graphical interface, unload the Nouveau driver and load the Nvidia driver, but that's too much hassle for most people, so reboot is a much simpler option. Indeed, if everything went well, you should have your Nvidia driver up and running.
You may end up with a black screen instead of a lovely, usable desktop session. There are many reasons why this could happen, but in your cause, it's probably a conflict between graphical drivers or the desktop session configurations. You will need to work on one of the virtual consoles (Ctrl + Alt + F1-6) to try to resolve your problem at this stage.
To do that, you will need to use the lsmod command, best as root:
lsmod | grep nouveau
If you get any naughty output, it means the driver is loaded, which explains why Nvidia is not, which would explain why your desktop session is misbehaving. Therefore, we need to disable Nouveau. We will first try a one-time blacklisting from the GRUB command line before creating a permanent blacklist rule.
In the boot menu, edit the Fedora boot line, and add to the kernel (linux) entry the following string: rdblacklist=nouveau. Resume the boot. If the system enters the graphical session, and the Nvidia driver is properly loaded, then all is well. You will just need to add a manual rule that blacklists Nouveau from loading. Again, this can be done permanently by editing the GRUB command line, or by creating a module blacklist rule. For the first, you have more than extremely detailed GRUB and GRUB2 tutorials to get the desired results.
For the second, here's how it's done - backup and new initramfs creation:
mv /boot/initramfs-$(uname -r).img \
/boot/initramfs-$(uname -r).bak.img
dracut --omit-drivers nouveau \
/boot/initramfs-$(uname -r).img $(uname -r)
This method will have to be executed every time there's a kernel update. A more elegant way is a permanent blacklist. Every time dracut runs, it will consult the following list and make the necessary exceptions when creating the initramfs image. Of course, you will need to make the initramfs file the first time after creating the blacklist rule. Personally, I recommend the GRUB change, because it is so very easily reversible. And don't forget backups, because if something goes wrong, you will be able to recover easily.
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
ln -s /etc/modprobe.d/blacklist.conf \
/usr/lib/modprobe.d/blacklist.conf
dracut /boot/initramfs-$(uname -r).img $(uname -r)
Maybe your xorg.conf file is problematic. The file is created on Nvidia driver installation, or at least modified from whatever was configured earlier. The default location for the configuration file is /etc/X11/xorg.conf. It should read something like:
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:1:0:0"
EndSection
If it does not, then you might have a problem. To that, you might want to move this file aside, creating a backup, then restore Nouveau and boot, to see if this fixes the problem. It is also possible that you may have already moved this file aside, and now that Nouveau is disabled, Nvidia can load, but there's no configuration in place.
This is your last resort. However, luckily this procedure is identical for most distributions out there, including the Ubuntu family, CentOS and friends. You will need to install all the necessary build tools first. Then, you will need to drop into runlevel 3, followed by a manual installation of the Nvidia driver. Finally, load the graphical session.
Nvidia guide on RPM Fusion
Nvidia drivers installation in openSUSE
Nvidia drivers installation in Ubuntu Quetzal and Ringtail family
There you go, a very detailed, very step-by-step tutorial, which should keep all you Fedora hats happy, in case you want to use this specific distribution on hardware that includes some Nvidia products. That's the sensible way of doing, but you know.
Anyhow, this guide has taught you many things. First, how to add new repositories to our Fedora. Then, how to use easyLife or manually install Nvidia drivers. We also learned a bit about compilation and build tools and such. We then debugged driver problems, learned how to blacklist modules using GRUB command line or the system modprobe list, how to edit or fix the Xorg configuration file, manual install, and still more besides. And we have references for Ubuntu, openSUSE and CentOS, so it's all milk and honey from here on. Which makes this guide one hell of a useful thing to keep around.
Cheers.