|
How to switch back and forth between nouveau and nvidia drivers - the solution
I finally had some time to get back to this and figure out how to do it.
The key to using either nouveau or nvidia drivers are whether two files exist and have the right content. These files are created when the nvidia rpms are installed from rpmforge. The files are:
/etc/X11/xorg.conf
/etc/X11/xorg.conf.d/00-nvidia.conf
If these two files do not exist, then the nouveau driver can be used. If they do exist, then they override the probing done by X when it starts. Rather then moving these in and out of place, I chose to rename them and then add or remove symbolic links to them depending on whether I want to run the nouveau or nvidia drivers. This approach will allso continue to work after the packages are updated by yum and the files replaced.
Of course, you also have to handle having the driver load if it's blacklisted, as happens when installing the nvdia driver from rpm forge. I wrote two scripts to make switching back and forth easier and to preserve the original files. Here they are to use or modify as you see fit. The noveau driver usually gets locked in memory once loaded, so expect to have to reboot after running one script or the other. Of course, the nouveau and nvidia driver RPMs must both be installed before using it.
[root@localhost ~]# cat nouv.sh
#!/bin/bash
# To use the nouveau driver, the files xorg.conf and 00-nvidia.conf
# should not exist. We rename the original files, if not already done,
# The renaming will only be done once.
if [ -f /etc/X11/xorg.conf.d/00-nvidia.conf ]
then
# If the nvidia .conf file is a file and not a link, rename and link it.
# Files in /etc/X11/xorg.conf.d are only read if they have the extension .conf
mv /etc/X11/xorg.conf.d/00-nvidia.conf /etc/X11/xorg.conf.d/00-nvidia.conf.nvidia
fi
if [ -f /etc/X11/xorg.conf ]
then
# If the xorg .conf file is a file and not a link, rename and link it.
# This file tells X11 to use the nvidia driver.
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia
fi
# Remove the symbolic links, if they exist.
if [ -h /etc/X11/xorg.conf.d/00-nvidia.conf ]; then rm /etc/X11/xorg.conf.d/00-nvidia.conf; fi
if [ -h /etc/X11/xorg.conf ]; then rm /etc/X11/xorg.conf; fi
# Remove nvidia kernel module
modprobe -r nvidia
# Add nouveau kernel module
modprobe -a nouveau
[root@localhost ~]# cat nvid.sh
#!/bin/bash
# To use the nvidia driver, the files xorg.conf and 00-nvidia.conf have
# to exist and be in the right place. We rename the original files and
# create symbolic links to them. The renaming will only be done once.
#
# If the nvidia .conf file is a file and not a link, rename and link it.
# Files in /etc/X11/xorg.conf.d are only read if they have the extension .conf
if [ -f /etc/X11/xorg.conf.d/00-nvidia.conf ]
then
mv /etc/X11/xorg.conf.d/00-nvidia.conf /etc/X11/xorg.conf.d/00-nvidia.conf.nvidia
fi
#
# If the xorg .conf file is a file and not a link, rename and link it.
# This file tells X11 to use the nvidia driver.
if [ -f /etc/X11/xorg.conf ]
then
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia
fi
# Create link so that nvidia .conf file is found.
ln -s /etc/X11/xorg.conf.d/00-nvidia.conf.nvidia /etc/X11/xorg.conf.d/00-nvidia.conf
# Create link so that xorg .conf file is found.
ln -s /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
# Make sure the nvidia driver is loaded
modprobe -a nvidia
# My experience is that if the nouveau driver has been loaded, it can not
# be removed.
# Remove the nouveau driver
modprobe -r nouveau
|