How to install nvidia legacy 304 driver in Ubuntu 18.04

It is known that nvidia propietary 304.137 driver do not work in Ubuntu/Kubuntu 18.04 because of some breaking changes made to the 4.15 linux kernel. Also, nouveau drivers are not (yet) good enough.

Likely, Ubuntu is a derivative of Debian, and the good people of Debian have done an excellent work at keeping up to date the driver for newer kernel versions.

This is how I managed to install the Debian 9 “stretch” package for nvidia 304 driver into Ubuntu 18.04.1.

Before you proceed to change your system, please consider that I give no warranties on the results of executing this procedure in your system. Your mileage may vary.

Step 1: remove any previous versions of nvidia driver from the system:

sudo apt-get remove --purge nvidia-*

and remove any other packages no longer needed:

sudo apt autoremove

Step 2: Install linux kernel headers of the current kernel version

Type the following to install the headers of the currently installed kernel in your system:

sudo apt-get --install-suggests --allow-unauthenticated install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//')

Step 3: Add a Debian repository containing the nvidia-legacy-304xx-driver package and comment Ubuntu’s repositories

Edit the /etc/apt/sources.list file and add the following line, which will incorporate a Debian 9 Stretch repository containing the driver’s package. Is important the [trusted=yes] addition to avoid dealing with signing and authentication issues.

deb [trusted=yes] stretch main contrib non-free

Comment ALL other Ubuntu specific repositories with a # at the beginning of the line. For example:

# deb bionic main restricted multiverse universe

Save the file and update by executing:

sudo apt update

Step 4: Remove ubuntu-drivers-common package

This package does not allow to install the driver, so uninstall it:

sudo apt remove --purge ubuntu-drivers-common

Step 5: Install the nvidia-legacy-304xx-driver package

Type this to install the nvidia driver:

sudo apt install nvidia-legacy-304xx-driver

Step 6: Reboot the computer

Reboot the system, then confirm the driver is correctly installed, by typing:

grep "X Driver" /var/log/Xorg.0.log

it should display something like:

[ 94.923] (II) NVIDIA dlloader X Driver 304.137 Thu Sep 14 13:52:41 PDT 2017

Step 7: Confirm the windows manager works as expected.

In my case, my computer have an onboard GeForce 7025 / nForce 630a nvidia graphics, running a Kubuntu (the version of Ubuntu with a preinstalled KDE windows manager), and found out that running with the OpenGL 2.0 engine was not working properly and freezed the desktop. I solved it by changing the rendering engine to XRender, by editing the


and changing the line with




Save the file then reboot the system. Next time you log in it will render the desktop with the XRender engine which is more than enough for most applications.


I wonder why Ubuntu is not updating their repositories as Debian did to support NVIDIA old graphics cards. They may be old and legacy products, but as a user like me that most of the time is surfing the web, editing documents, watching videos on youtube, or developing web applications in Java with the Eclipse IDE, those old card capabilities are powerful enough for these work requirements.

Leave a comment

Your email address will not be published. Required fields are marked *