Friday, October 13, 2023

Legacy NVIDIA Driver for Ubuntu 20.04+

Summary

Either because an upgrade wrecked a working Linux install, or because the default drivers aren't performing very well, it may be necessary to install NVIDIA drivers for very old, "legacy" hardware on Ubuntu, or a similar Linux distribution.  This post is meant to help get that done without burning as much time searching for the right information and putting all the pieces together.

Symptoms

  • After an update / upgrade, Linux stalls mid-boot with a black screen and a blinking text cursor in the upper left corner.
  • Linux installed on a machine with older / legacy NVIDIA hardware is running too slow to be usable, and the graphics driver is suspected as the cause.

Elements of the Problem

  • Recent versions of Ubuntu install a kernel version that is no longer compatible with older NVIDIA drivers.
  • The default, generic driver doesn't perform very well (or at all) with older NVIDIA graphics card hardware.

Getting to a Terminal

When/if the X-Window / GUI Startup failed and stopped the bootup, it may be necessary to switch to another tty/terminal.  There are typically several of them started with Linux, and they can be accessed using CTRL+ALT+F2 (or F3, F4, ...).  From the blank / black screen with the blinking cursor, use that key combo to switch over and directly log-in to a terminal / tty, where the commands below can be executed.

Diagnostic Steps

  • Verify old NVIDIA hardware
    • Command:   sudo lspci | grep VGA
      • Should display information about the NVIDIA hardware (e.g. GeForce 9600M GT)
  • Verify old, no longer working, NVIDIA driver version is installed - (e.g. 340.108)
    • Command: dkms status
    • Command: apt list --installed | grep nvidia
      • Should show the NVIDIA driver package version (e.g. nvidia-340 ... 340.108)
  • Verify NVIDIA driver is malfunctioning
    • Command: nvidia-smi
      • Should report a failure to communicate with graphics hardware.
  • Check NVIDIA settings
    • Command: nvidia-settings
      • May report config errors, etc. and/or other useful info.

Elements of the Solution

  • Add the PPA repository from user kelebek333 which contains a version of the NVIDIA drivers that has been patched to work with newer kernel versions.
    • See: https://launchpad.net/~kelebek333/+archive/ubuntu/nvidia-legacy
    • Command: sudo add-apt-repository ppa:kelebek333/nvidia-legacy
  • Run command: sudo apt-get update
    • This should report that one or more packages (which include patched NVIDIA driver) are upgradable.
      • Verify w/ command: apt list --upgradable
  • Run command: sudo apt upgrade nvidia-340
    • This may report that there is a public key missing.  If so, run the following command replacing {key-value} with the key that is reported in the error message from apt upgrade...
      • Command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys {key-value}
  • Reboot - If this resolved the NVIDIA driver issues, the X Window system should start normally again.