[Centos] nVIDIA on CentOS 3.3

Thu Sep 23 22:42:22 UTC 2004
John Newbigin <jn at it.swin.edu.au>

We prefer to nvidia cards with CentOS-2.  I have never had the problem 
of a monitor not being detected, though if you have tv out and no 
monitor plugged in then tv out will be used when the machine is powered on.

I have an RPM which I wrote which rebuilds the driver (if necessary) and 
loads it at boot time.  Because it contains the nvidia package I don't 
know if I can redistribute it (have not checked) but here is my source 
part (Not tested with CentOS-3):

nvidia.spec
===========
Summary: NVIDIA driver for XFree86
Name: nvidia
Version: 5336
Release: 1
Vendor: Nvidia
Distribution: Premonition
Packager: John Newbigin <jn at it.swin.edu.au>
License: Unknown
Group: Applications/System
BuildRoot: /var/tmp/%{name}-root
Source0: NVIDIA-Linux-x86-1.0-%{version}-pkg1.run
Source1: nvidia.rc

%description
NVIDIA driver for XFree86

%prep
if [ -d nvidia ] ; then
   rm -rf nvidia
fi
mkdir nvidia
cd nvidia
sh %{SOURCE0} -x

rm NVIDIA-Linux-x86-1.0-*/usr/src/nv/precompiled/*

%build

%install
cd nvidia
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/opt/nvidia
cp -r NVIDIA-Linux-x86-1.0-*/* ${RPM_BUILD_ROOT}/opt/nvidia
cp -r NVIDIA-Linux-x86-1.0-*/.manifest ${RPM_BUILD_ROOT}/opt/nvidia
mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/init.d
cp %{SOURCE1} ${RPM_BUILD_ROOT}/etc/rc.d/init.d/nvidia

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-, root, root, 0755)

/etc/rc.d/init.d/nvidia
/opt/nvidia/.manifest
/opt/nvidia/*

%post
if [ "$1" = "1" ] ; then
    chkconfig --add nvidia
    service nvidia start
    service nvidia configure
else
    service nvidia stop
    service nvidia uninstall
    service nvidia start
fi

%preun
if [ "$1" = "0" ] ; then
    service nvidia stop
    service nvidia uninstall
    chkconfig --del nvidia
fi

%changelog
* Wed May 19 2004 John Newbigin <jn at it.swin.edu.au>
- First Cut


nvidia.rc
=========
#!/bin/bash
#
# chkconfig: 5 85 15
# description: Builds the nvidia kernel module for X11

# source function library
. /etc/rc.d/init.d/functions

RETVAL=0

start() {
    NEED_BUILD=1
    if [ -f /lib/modules/`uname -r`/kernel/drivers/video/nvidia.o ] ; then
       echo -n $"Loading nvidia driver"
       modprobe nvidia > /dev/null 2>/dev/null
       if grep -q nvidia /proc/modules ; then
          success $"Loading nvidia driver"
          echo
          NEED_BUILD=0
       else
          failure $"Loading nvidia driver"
          echo
       fi
    fi

    if [ $NEED_BUILD == 1 ] ; then
       echo -n $"Building nvidia driver"
       cd /opt/nvidia
       ./nvidia-installer --silent --no-precompiled-interface 
--no-network >/dev/null 2>/dev/null

       if grep -q "is now complete" /var/log/nvidia-installer.log ; then
          success $"Building nvidia driver"
          echo
          echo -n $"Loading nvidia module"
          modprobe nvidia > /dev/null 2>/dev/null
          if grep -q nvidia /proc/modules ; then
             success $"Loading nvidia module"
             echo
          else
             failure $"Loading nvidia module"
             echo
          fi
       else
          failure $"Building nvidia driver"
          echo
       fi
    fi
}

stop() {
         echo -n $"Unloading nvidia module: "
         rmmod nvidia > /dev/null 2>/dev/null
         # we don't care if it does not work...?
         success
         RETVAL=$?

         echo
}
configure() {
    echo -n "Configuring XFree86-4 for nvidia"

    if [ ! -f /etc/X11/XF86Config-4.prenvidia ] ; then
       cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.prenvidia
    fi
#replace the line:
#        Driver "nv"
#    (or Driver "vesa")
#
#with
#
#        Driver "nvidia"
#
#In the Module section, make sure you have:
#
#        Load   "glx"
#
#You should also remove the following lines:
#
#        Load  "dri"
#        Load  "GLcore"

/usr/bin/perl -pi -e "s|Driver[[:space:]]*\"nv\"|Driver 
\"nvidia\"|" /etc/X11/XF86Config-4
if ! grep -q "^[[:space:]]*Load[[:space:]]*\"glx\"" 
/etc/X11/XF86Config-4 ; then
    echo "We need to add Load   \"glx\""
fi
if grep -q "^[[:space:]]*Load[[:space:]]*\"dri\"" /etc/X11/XF86Config-4 
; then
    /usr/bin/perl -pi -e "s|Load[[:space:]]*\"dri\"|#Load \"dri\"|" 
/etc/X11/XF86Config-4
fi
if grep -q "^[[:space:]]*Load[[:space:]]*\"GLcore\"" 
/etc/X11/XF86Config-4 ; then
    /usr/bin/perl -pi -e "s|Load[[:space:]]*\"GLcore\"|#Load 
\"GLcore\"|" /etc/X11/XF86Config-4
fi
         success
         echo
}

uninstall() {
    cd /opt/nvidia
    ./nvidia-installer --silent --uninstall
}

case "$1" in
   start)
         start
         ;;
   stop)
         stop
         ;;
   configure)
         configure
         ;;
   uninstall)
         uninstall
         ;;
   *)
         echo $"Usage: $0 {start|stop|configure|uninstall}"
         exit 1
esac

exit $RETVAL


C.M. Connelly wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> An option to installing the nVidia drivers with nVidia's installer
> is to get the dell-nvidia and dkms packages from Dell's support
> website (search for dell-nvidia and dkms).  The best thing about
> this approach is that the driver will be recompiled when the
> machine is rebooted with a new kernel.
> 
> As a (perhaps irrelevant) data point, I'm running a PowerEdge
> 400SC with an nVidia Corporation GeForce3 Ti 200 and a DVI
> connection to a Dell 2000FP monitor at the full 1600x1200
> resolution.  Works great with the nVidia drivers; only the analog
> connection works for X with the XFree driver.
> 
> I have a GeForce4 card with the same monitor at home in my Debian
> system; works great with the Debian-packaged nVidia drivers.
> 
>    Claire
> 
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
>   Claire Connelly                              cmc at math.hmc.edu 
>   Systems Administrator                          (909) 621-8754   
>   Department of Mathematics                 Harvey Mudd College
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
> 
> iD8DBQFBUb57B0pE8d7vd8wRAobXAJ9fLysDccEY3nn4f+xPkA3ZeEFGMgCggz80
> vhQ1XyztGmoIG7s7w3Vo9kY=
> =/1P5
> -----END PGP SIGNATURE-----
> _______________________________________________
> CentOS mailing list
> CentOS at caosity.org
> http://www.caosity.org/mailman/listinfo/centos
> 
> 
> 


-- 
John Newbigin - Computer Systems Officer
School of Information Technology
Swinburne University of Technology
Melbourne, Australia
http://www.it.swin.edu.au/staff/jnewbigin