This tutorial is to install the genuine Nvidia drivers from Nvidia's site (not the kmod or dkms) on Centos 6/RHEL. It is actually easier (and slightly quicker) this way than using the modified ones in the repos. The genuine Nvidia Linux drivers are, unequivocally, the best ones to use if you have an Nvidia card.
We will not be using any repositories and if you have installed your Centos 6 as per this tutorial and set up the kernel correctly you should not get any errors about the wrong compiler.
We are changing the defaults in /etc/inittab because 'telinit 3' and 'Ctl+Alt+F4" do not always disable X server properly and the Nvidia script complains.
I have also put the section on kernels at the bottom of this page so you can fix them, if necessary, before proceeding. It is not difficult to do, simply a matter of removing the out of date ones and updating/installing the matching kernel-headers/kernel-devel files.
You will need
We will not be using any repositories and if you have installed your Centos 6 as per this tutorial and set up the kernel correctly you should not get any errors about the wrong compiler.
We are changing the defaults in /etc/inittab because 'telinit 3' and 'Ctl+Alt+F4" do not always disable X server properly and the Nvidia script complains.
I have also put the section on kernels at the bottom of this page so you can fix them, if necessary, before proceeding. It is not difficult to do, simply a matter of removing the out of date ones and updating/installing the matching kernel-headers/kernel-devel files.
You will need
- The Genuine Nvidia Driver/Script from Nvidia
- A disable-nouveau.conf file (which you will create)
- A line in /etc/grub.conf to disable nouveau from loading.
$ uname -r
$ rpm -qa kernel-devel
If the numbers don't match scroll down to the bottom of this page to the kernels section, follow it and return here.
Install compile tools if not already installed.
If the numbers don't match scroll down to the bottom of this page to the kernels section, follow it and return here.
Install compile tools if not already installed.
$ sudo yum -y install gcc gcc-c++ automake autoconf make
Getting the Nvidia Driver
Go to http://www.nvidia.com/Download/index.aspx?lang=en-us and select your driver, it will have a .run or .sh extension, download to your home directory. The one I used is NVIDIA-Linux-x86-295.49.run
$ chmod u+x NVIDIA-Linux-x86-295.49.run make it executable
(substitute the above file for your version of it)
Leave it in your home directory.
Blacklisting nouveau driver.
$ sudo vi /etc/modprobe.d/disable-nouveau.conf enter
blacklist nouveau options nouveau modeset=0
and save the file
See Vim Editor for vi commands
$ sudo cp /etc/grub.conf /etc/grub.conf.bak backup grub.conf
$ sudo vi /etc/grub.conf and find this section
kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/vg_centos-lv_root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 rhgb quiet crashkernel=auto rd_LVM_LV=vg_centos/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.el6.i686.img
After the line rhgb or somewhere appropriate enter this line
rdblacklist=nouveau nouveau.modeset=0
Save the file. Now change the run level
$ sudo vi /etc/inittab
Scroll down and change default to '3'
Save, exit & reboot.
Login as root in console mode.
Installing the driver
Go to the Nvidia script in your home directory.
# cd /home/<user_name>
# ./N + tab key
# ./NVIDIA-Linux-x86-295.49.run hit enter to run it
Substitute the above file for your version of it.
Follow the dialogue box, largely 'accept' and 'write to xorg.conf' at the end, and your drivers are installed. If you get an error message about the wrong compiler version then scroll down to the bottom of this page and follow the section on how to update the kernel in Centos6/RHEL
# vi /etc/inittab change back to '5'
Reboot (Not telinit 5)
Log on as a normal user and open up this tutorial to finish off your settings.
$ lspci | grep VGA shows current video hardware
Setting up with Nvidia settings
Open a terminal
$ su -c 'nvidia-settings' enter password
The Nvidia settings dialogue box will open so you can adjust resolutions and refresh rates etc in the 'X Server Configurations' tab and save everything to xorg.conf to make it permanent and keep the same setup on reboot.
A thread on Nouveau & Modeset in Slackware.
To reverse the procedure if you have to use a different graphics card then just
$ sudo rm /etc/X11/xorg.conf /etc/modprobe.d/disable-nouveau.conf
$ sudo cp /etc/grub.conf.bak /etc/grub.conf
Switch cards on a Laptop.
If using a laptop with both onboard and dedicated cards then you can use Bumblebee, which enables you to switch between them.
Bumblebee is in both Elrepo & Atrpms repos as 'bbswitch', so install one of them and issue the command
$ sudo yum -y --enablerepo=elrepo install bbswitch
Atrpms repo may also add a new kernel so you can either keep it and remove old/update to new as below, or just remove it and keep your current ones.
If you don't wish to install the repos you can just download the package from either one, in Elrepo it is listed as 'bumblebee'.
Kernels
To ensure smooth compiling lets fix the kernels, you should do this before you install Nvidia drivers.
There may have been a kernel update since the last release
meaning you have got 2 different ones installed
$ rpm -qa | grep kernel
shows the kernel files you have, as below, typically
kernel-firmware-2.6.32-279.1.1.el6.noarch
dracut-kernel-004-284.el6_3.noarch
kernel-2.6.32-279.1.1.el6.i686 New
kernel-2.6.32-279.el6.i686 Old
With old from the original install
and new fom the epel repo
(The new one should match your kernel-firmware)
Reboot, press space bar + boot from new kernel
remove the old one
$ sudo yum -y remove kernel-2.6.32-279.el6.i686
And add matching headers and devel
$ sudo yum -y install kernel-headers kernel-devel
Repeat the command to check they match as below
kernel-devel-2.6.32-279.1.1.el6.i686
kernel-headers-2.6.32-279.1.1.el6.i686
kernel-firmware-2.6.32-279.1.1.el6.noarch
dracut-kernel-004-284.el6_3.noarch
kernel-2.6.32-279.1.1.el6.i686
Now you have a correct /usr/src/kernels folder
Then you can install gcc etc
$ sudo yum -y install gcc gcc-c++ automake autoconf make
You should be able to compile without kernel errors.
IMPORTANT Once you have got a full set of matching kernel files on a running machine, take care not to update unless absolutely necessary OR you are very experienced, as it can result in boot problems.
Go to http://www.nvidia.com/Download/index.aspx?lang=en-us and select your driver, it will have a .run or .sh extension, download to your home directory. The one I used is NVIDIA-Linux-x86-295.49.run
$ chmod u+x NVIDIA-Linux-x86-295.49.run make it executable
(substitute the above file for your version of it)
Leave it in your home directory.
Blacklisting nouveau driver.
$ sudo vi /etc/modprobe.d/disable-nouveau.conf enter
blacklist nouveau options nouveau modeset=0
and save the file
See Vim Editor for vi commands
$ sudo cp /etc/grub.conf /etc/grub.conf.bak backup grub.conf
$ sudo vi /etc/grub.conf and find this section
kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/vg_centos-lv_root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 rhgb quiet crashkernel=auto rd_LVM_LV=vg_centos/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.el6.i686.img
After the line rhgb or somewhere appropriate enter this line
rdblacklist=nouveau nouveau.modeset=0
Save the file. Now change the run level
$ sudo vi /etc/inittab
Scroll down and change default to '3'
Save, exit & reboot.
Login as root in console mode.
Installing the driver
Go to the Nvidia script in your home directory.
# cd /home/<user_name>
# ./N + tab key
# ./NVIDIA-Linux-x86-295.49.run hit enter to run it
Substitute the above file for your version of it.
Follow the dialogue box, largely 'accept' and 'write to xorg.conf' at the end, and your drivers are installed. If you get an error message about the wrong compiler version then scroll down to the bottom of this page and follow the section on how to update the kernel in Centos6/RHEL
# vi /etc/inittab change back to '5'
Reboot (Not telinit 5)
Log on as a normal user and open up this tutorial to finish off your settings.
$ lspci | grep VGA shows current video hardware
Setting up with Nvidia settings
Open a terminal
$ su -c 'nvidia-settings' enter password
The Nvidia settings dialogue box will open so you can adjust resolutions and refresh rates etc in the 'X Server Configurations' tab and save everything to xorg.conf to make it permanent and keep the same setup on reboot.
A thread on Nouveau & Modeset in Slackware.
To reverse the procedure if you have to use a different graphics card then just
$ sudo rm /etc/X11/xorg.conf /etc/modprobe.d/disable-nouveau.conf
$ sudo cp /etc/grub.conf.bak /etc/grub.conf
Switch cards on a Laptop.
If using a laptop with both onboard and dedicated cards then you can use Bumblebee, which enables you to switch between them.
Bumblebee is in both Elrepo & Atrpms repos as 'bbswitch', so install one of them and issue the command
$ sudo yum -y --enablerepo=elrepo install bbswitch
Atrpms repo may also add a new kernel so you can either keep it and remove old/update to new as below, or just remove it and keep your current ones.
If you don't wish to install the repos you can just download the package from either one, in Elrepo it is listed as 'bumblebee'.
Kernels
To ensure smooth compiling lets fix the kernels, you should do this before you install Nvidia drivers.
There may have been a kernel update since the last release
meaning you have got 2 different ones installed
$ rpm -qa | grep kernel
shows the kernel files you have, as below, typically
kernel-firmware-2.6.32-279.1.1.el6.noarch
dracut-kernel-004-284.el6_3.noarch
kernel-2.6.32-279.1.1.el6.i686 New
kernel-2.6.32-279.el6.i686 Old
With old from the original install
and new fom the epel repo
(The new one should match your kernel-firmware)
Reboot, press space bar + boot from new kernel
remove the old one
$ sudo yum -y remove kernel-2.6.32-279.el6.i686
And add matching headers and devel
$ sudo yum -y install kernel-headers kernel-devel
Repeat the command to check they match as below
kernel-devel-2.6.32-279.1.1.el6.i686
kernel-headers-2.6.32-279.1.1.el6.i686
kernel-firmware-2.6.32-279.1.1.el6.noarch
dracut-kernel-004-284.el6_3.noarch
kernel-2.6.32-279.1.1.el6.i686
Now you have a correct /usr/src/kernels folder
Then you can install gcc etc
$ sudo yum -y install gcc gcc-c++ automake autoconf make
You should be able to compile without kernel errors.
IMPORTANT Once you have got a full set of matching kernel files on a running machine, take care not to update unless absolutely necessary OR you are very experienced, as it can result in boot problems.
Thanks!
ReplyDeleteThank you for this article. Very helpfull.
ReplyDeleteI have a comment to make. I think it is safer to modify/backup the file /boot/grub/grub.conf instead of /etc/grub.conf. The last file is a link to the first one. Μodifying /etc/grub.conf it is possible to lose this link. This happened to me and caused me problems...
Hi, yes you are probably right, Thanks.
ReplyDelete