Black screen at boot after Nvidia driver installation on Ubuntu 18.04.2 LTS
I'm posting an answer to my question as I managed to solve the problem (thanks to the AskUbuntu community). This may not be a completely generic answer, but I will explain the steps which I followed in case it helps someone else. Here's how I did it:
1. Connecting to a terminal
I followed the instructions to edit the commands before booting, namely replacing quiet splash
with nomodeset
and then pressing F10
or Ctrl+X
to boot (instructions are provided here). After I booted, I pressed Ctrl+Alt+F1
, Ctrl+Alt+F6
and Ctrl+Alt+F7
repeatedly one after the other. After several tries (had to reboot and retry several times), I eventually got a terminal with ultra low resolution where I had to enter my login and password, which I did.
2. Uninstalling the wrong Nvidia driver
I used the command provided by Marmayogi to uninstall the incorrect Nvidia driver:
sudo apt-get purge nvidia*
The next time I rebooted Ubuntu, I was able to access the login page and GUI in ultra low resolution, like before I installed the wrong Nvidia driver.
3. Installing the correct Nvidia driver
Here I followed the instructions provided by Marmayogi in his comment to my question, except for the installation command of the Nvidia driver which was incorrect as it has changed (see the answer by Kerry Kobashi in this post for details):
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-driver-410
(this is the new command, also check version number of driver first!)- Reboot.
After rebooting the GUI was in a normal resolution (except GRUB which was still in low resolution, but it's less of a problem). To check that everything went well, I issued the following command: lsmod | grep nvidia
, and there was output, so the installation was successful.
Here I am want to stress out that you need to check which version of the Nvidia driver you need (i.e. which is compatible with your graphics card). You can check on the Nvidia website which products are supported by each driver (the latest one is usually the best if you have a recent graphics card). Not doing so and blindly following instructions in another post which did not specify this is what led me to having all these problems in the first place (unfortunately, this point is too often ignored in a lot of posts I've seen on the subject). Also when choosing the version, I read somewhere that you only need to write the main version (don't bother about the number after the point, so if latest driver is 418.56, just write 418).
Here is a detailed procedure to blacklist Nouveau followed by the installation of nvidia driver. You may read this as a continuation of @johnwolf1987 answer since blacklisting Nouveau was not covered over there.
Step-1: Obviously starting with an update and upgrade
$ sudo apt-get update
$ sudo apt-get upgrade
Step-2: Then remove all Nvidia packages (skip this if your OS is fresh installed) :
$ sudo apt-get remove nvidia*
$ sudo apt autoremove
Step-3: Install these packages for building the kernel:
$ sudo apt-get install dkms build-essential linux-headers-$(uname -r)
Step-4: Now block and disable Nouveau kernel driver:
$ echo "# Disable the default Nouveau kernel driver" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "# -----------------------------------------" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "blacklist nouveau" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "blacklist lbm-nouveau" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "alias nouveau off" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
$ echo "alias lbm-nouveau off" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
To list the contents of the /etc/modprobe.d/blacklist-nouveau.conf
file, issue the following command:
$ cat /etc/modprobe.d/blacklist-nouveau.conf
Figure-1: Contents of blacklist-nouveau.conf file
Step-5: Disable the Kernel mode setting (KMS) by issuing this command:
$ echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
To list the contents of the /etc/modprobe.d/nouveau-kms.conf
file, issue the following command:
$ cat /etc/modprobe.d/nouveau-kms.conf
Figure-2: Contents of nouveau-kms.conf file
Note: FYI, the file nouveau-kms.conf
may not exist.
Step-6: Enter the following linux command to regenerate the kernel initramfs:
$ sudo update-initramfs -u
Step-7: Reboot the system.
Step-8: After the reboot you need to exit the X Server, for that we need to stop LightDM, press Ctrl+Alt+F1
to open up a console screen, log in with your user and password, after that:
$ sudo service lightdm stop
Step-9: Now install your Nvidia driver:
$ sudo apt-get install nvidia-VERSION
Note: The value of nvidia-VERSION
could be nvidia-410
, nvidia-412
, nvidia-418
, and so on, but you must be careful in locating correct Nvidia Display Driver. Ignoring this, may result in blank screen upon reboot.
Step-10: Reboot the system.
Step-11: To show which loadable kernel modules are currently loaded, issue the following command:
$ lsmod | grep nvidia
If there is an output, then the installation of nvidia
is successful!
Step-12: Now issue the following command to know which display driver is loaded:
$ sudo lshw -c video | grep 'configuration'
Figure-3: Display driver i915 has been loaded (This desktop does not have Nvidia GPU).
I encountered the same issue on my Ubuntu 20.04. Also I figured out that nvidia-driver-4xx will result in this issue, and the latest-known-good driver is nvidia-driver-390.
So my workaround is installing nvidia-driver-390 instead of the latest one.
- Switch to tty1
Press ctl+alt+F1. (cannot see the screen but we can actually change to tty1)
- Reboot to recovery mode
ctl+alt+del to reboot, and select advance -> recovery mode
- Start X with nomodeset
Firstly enable network, and select resume to boot into GUI, then select and install nvidia-driver-390.
After reboot, you should be able to enter your desktop.