How to remove Nouveau kernel driver (fix Nvidia install error)



WARNING This tutorial could break your system, make sure you backup your system before following the steps.

Installing the Offial nvidia drivers will return an error if the Nouveau kernel driver is currently in use. We will explain how to fix the error and install the official drivers.

ERROR: The Nouveau kernel driver is currently in use by your system.  This driver is incompatible with the NVIDIA driver, and must be disabled before proceeding.  Please consult the NVIDIA driver README and
         your Linux distribution's documentation for details on how to correctly disable the Nouveau kernel driver.

Step 1: Cleanup all nvidia package

At this step we will remove all nvidia related packages.

sudo apt-get remove nvidia* && sudo apt autoremove

If you get the following error it means that you never had an nvidia package installed and is ok:

no matches found: nvidia*

Now install some required dependencies:

sudo apt-get install dkms build-essential linux-headers-generic

Step 2: Black list nouveau driver

now block and disable nouveau kernel driver:

sudo vim /etc/modprobe.d/blacklist.conf

And append the follow lines to the blacklist.conf:

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

Step 3: Update initramfs

Disable the Kernel nouveau by typing the following commands:

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf build the new kernel by:

Finally update and reboot:

sudo update-initramfs -u