Results 1 to 10 of 96

Thread: HOWTO: Automatically update manually installed NVidia drivers after kernel updates

Threaded View

  1. #1
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    HOWTO: Automatically update manually installed NVidia drivers after kernel updates

    Overview
    If you've manually installed the NVidia drivers from the NVidia website, when major kernel releases come out it's necessary to re-install the drivers for the new kernel. This guide aims to automate that process so that it happens when the new kernel is installed and requires no user intervention.

    This HOWTO assumes you have correctly installed the NVidia drivers from the website and that you have rebooted after installing them at least once (this is very important because, if you haven't installed them correctly, upon reboot they will not work). This guide is not aimed at users who have installed the drivers using EnvyNG or via the default Ubuntu mechanism.

    (Note: This has only been tested on 8.04 and may not work or be needed in later versions)

    Implementation

    Update: After finding an easier method to this, I've modified the directions slightly. People using the old method can continue to use it or, see this post to revert the changes from the old method.

    Another Update: I've changed the script very slightly to provide a status message depending on whether or not building the new driver worked. People can replace nvidia-update with this new script or continue to use the old. I've also changed the testing instructions slightly.

    The first thing I recommend doing this is to move the driver you are using to /usr/src and make a symlink to it. For example:

    Code:
    sudo mv NVIDIA-Linux-x86-173.14.05-pkg1.run /usr/src
    sudo ln -s /usr/src/NVIDIA-Linux-x86-173.14.05-pkg1.run /usr/src/nvidia-driver
    The reason for doing this is so that if you change the driver you are using, you can simply remove the symlink and point it at the new driver and not have to modify the script we are about to install.

    The script we will use to automate this process is here:

    Code:
    #!/bin/bash
    #
    
    # Set this to the exact path of the nvidia driver you plan to use
    # It is recommended to use a symlink here so that this script doesn't
    # have to be modified when you change driver versions.
    DRIVER=/usr/src/nvidia-driver
    
    
    # Build new driver if it doesn't exist
    if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then
        echo "NVIDIA driver already exists for this kernel." >&2
    else
        echo "Building NVIDIA driver for kernel $1" >&2
        sh $DRIVER -K -k $1 -s -n 2>1 > /dev/null
    
        if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then
            echo "   SUCCESS: Driver installed for kernel $1" >&2
        else
            echo "   FAILURE: See /var/log/nvidia-installer.log" >&2
        fi
    fi
    
    exit 0
    Essentially, what it does is check to see if the kernel we are installing has the proprietary nvidia driver installed. If not, it will build the module for that kernel.

    Name the script update-nvidia and install it with:

    Code:
    sudo mkdir -p /etc/kernel/postinst.d
    sudo install update-nvidia /etc/kernel/postinst.d
    That's it. The next time you install a kernel that doesn't have the NVidia driver, it will automatically build it for you at installation time.

    Testing
    You can test it by either waiting for the next kernel release or by temporarily installing the -386 kernel to verify that it really does work properly. If you choose the later method of testing, this is how to do it:

    Code:
    sudo apt-get install linux-image-386 linux-headers-386
    You should see a long pause as it says it's building the nvidia driver for the -386 kernel and then a success message. If it works, you can then remove the -386 kernel we installed for testing with:

    Code:
    sudo apt-get remove linux-headers-2.6.24-19-386 linux-headers-386 linux-image-2.6.24-19-386 linux-image-386 linux-ubuntu-modules-2.6.24-19-386

    Comments/Questions/Suggestions welcome.
    Last edited by sdennie; December 6th, 2008 at 08:53 PM. Reason: Minor script update
    Don't try to make something "fast" until you are able to quantify "slow".

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •