Bash scripts to automate installation of NVIDIA proprietary driver

Scripts for installing NVIDIA Proprietary Driver on Linux

Based on the tutorial by Clear Linux, I created four bash scripts that will automate the installation, and uninstallation, of NVIDIA proprietary driver.

All of them needs root privilege to be executed.

They’re available on my GitHub repo. I’ve tried all of those scripts on my own computer and feedback is needed.


This script would install kernel-native-dkms or kernel-lts-dkms bundle based on your kernel type. Then it will update Clear Linux OS bootloader and prompt the user to reboot.

Note: This shall only need to be executed for once.


This script do the followings:

  • Set up ld config file to include libraries that are going to be installed by NVIDIA drivers.
  • Disable nouveau driver.
  • Locate NVIDIA driver installer
    • If it cannot find the installer under current directory or ~/Downloads, it will open the download page via the default web browser of the user. Before it exits, it also shows the display adapters currently identified in the OS.
    • If there are multiple installers found, it chooses the newest one according to the version number.
  • Install the driver with the following options:
     --utility-prefix=/opt/nvidia \
     --opengl-prefix=/opt/nvidia \
     --compat32-prefix=/opt/nvidia \
     --compat32-libdir=lib32 \
     --x-prefix=/opt/nvidia \
     --documentation-prefix=/opt/nvidia \
     --no-precompiled-interface \
     --no-distro-scripts \
     --force-libglx-indirect \
     --dkms \
    • I removed --no-nvidia-modprobe because it’s needed for CUDA toolkit to work properly.
  • Before exiting, it will remind user to run the


This script will list the NVIDIA kernel modules loaded on the system, which shall not be empty or otherwise the installation is not successful.

It also calls swupd verify --fix to verify the integrity of OpenGL library, which is likely to be altered by NVIDIA installer.


This script re-enables nouveau driver before it uninstalls NVIDIA proprietary driver via the official uninstaller, nvidia-uninstall. It also prompts the user to reboot.


I wrote my own version of this and tested it a few hours ago. Everything seemed to be working during the install, but GNOME Shell crashed reproducibly. :frowning: So I backed it out until I have a troubleshooting plan.

My GNOME Shell crashed for a few times and now it’s working.

Maybe it’s because I didn’t run swupd verify --fix --bundles=lib-opengl, which is suggested in the tutorials.

I did that - it still crashed. I ran out of troubleshooting energy and re-installed the laptop. I’ll take another run at it Wednesday.

Don’t forget the --quick switch otherwise swupd verify behavior is not intuitive with the --bundles paramter.

I verify that ‘swupd verify --fix’ doesn’t break the system.

If you’d like to share your codes, I can take a look to see what might have caused the problem

I had problems not being able to open the gnome-control-center after installing the nvidia drivers. I had an issue with loading opengl libraries. It appeared to be a conflict with the loader, as described in this stack overflow post:

I followed the advice from that post and removed the conflicting libraries that weren’t the nvidia ones (which I was pretty nervous about doing). I have a feeling that running the swupd verify --fix will restore them.

I don’t know what the “right” solution here is in terms of either having both exist and making sure the right library is loaded in the right situation, but my solution at least worked to get me able to open gnome-control-center again.

I had that same swrat steam error message installing Nvidia on the Ubuntu 19.04 distro. The solution I found there was just to run the installer a second time and everything worked out alright. I used to see this problem back in the day too.

Why not blacklist anything else?
blacklist nvidiafb
blacklist nv

I can now see kernel modules from nvidia under lsmod. Yet I still get that white screen with error message telling me to press enter. I ran the but now notice Firefox won’t allow me to watch any videos on dailymotion saying something about a mime type problem. I suspect it has to do with video acceleration either vdpau or ffmpeg libraries. Nope I’m lacking pepper flash.

Edit: My laptop of 5 years recently died. I suspect the systemic failures to be the cause of my problems with the drivers.


I have also problems installing the nvidia driver. I tried the manual way from the clear linux tutorial and also the automatic shell scripts. Both brought me to the same result. A white screen with the message:


So I guess the modules are not loaded correctly. I cannot remember the lsmod | grep ^nvidia output.

I’m on a thinkpad p72 with quadro 5200.


@specter and @Sumdewd

I’ve seen this white screen before after I finished the installation of NVIDIA driver but still had my moniter connected to the integrated GPU on the motherboard.
As long as I connect the display to my NVIDIA GPU, this white screen disappears.
@specter, does your laptop comes with a NVIDIA GPU and a motherboard GPU as well? If so, you might need to disable the latter one first.

In a previous edition of the tutorial, there was an installation flag that will tells the installer not to create any opengl files.
I had tried once with the installer creating those opengl files, and some applications will crash.
My scripts follows the current edition of Clear Linux documentation, with only one exception that I allowed the installer to create mod-probe, which is a dependency to CUDA. But it shall not affect the opengl library.
I also think it might be swupd verify --fix that restored them. Was the GitHub issue on the libGL error created by you?

I removed the* under /usr/lib64 directory and the gnome-control-center works now.

So somewhere it is loading the wrong libGL. I see many files include RPATH/RUNPATH to /usr/lib64 (mainly RUNPATH due to --enable-new-dtags). I have experienced the same issue which was resolved by stopping it adding -Wl,-rpath,/usr/lib64 to the linker.

Is someone able to run an strace when loading gnome-control-center and it fails to load with that error? (and then want the contents of /tmp/gcc-strace.log)

strace -f -o /tmp/gcc-strace.log gnome-control-center

This is related to
I already deleted the mesa libGL. Would you post your findings in the GitHub issue?

Thanx doct0rHu for taking the time. The P72 has the following gpu’s:

lspci -v | grep VGA
0:02.0 VGA compatible controller: Intel Corporation Device 3e94 (prog-if 00 [VGA controller])
01:00.0 VGA compatible controller: NVIDIA Corporation GP104GLM [Quadro P5200 Mobile] (rev a1) (prog-if 00 [VGA controller])

The intel gpu uses:

lspci -vs 00:02.0
00:02.0 VGA compatible controller: Intel Corporation Device 3e94 (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 2269
Flags: bus master, fast devsel, latency 0, IRQ 130
Memory at 404a000000 (64-bit, non-prefetchable) [size=16M]
Memory at 80000000 (64-bit, prefetchable) [size=256M]
I/O ports at 3000 [size=64]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] Process Address Space ID (PASID)
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] Page Request Interface (PRI)
Kernel driver in use: i915

So I tried to blacklist the i915 but that doesn’t seem to work. The Nvidia GPU was using the nvidia driver and not the nouveau but at startup there was the white error screen.

Interesting is, when i open terminal (strg+F2) and startx, the gnome fallback dm starts.

I cannot disable the intel gpu because this is a corporate laptop and I don’t have access to the bios.

Hope you have any further ideas!


I think this might be helpful. The author of that post failed to blacklist i915 module and changed the grub configuration and made that work.
I’m not sure whether this could be applied to Clear Linux, so please backup first.

Thanks. I did not create the GitHub issue, but I will follow its resolution. This is a pretty stupid problem to have. Install NVidia driver…no longer have the right driver linked for simple things like the gnome control center. I can’t imagine the pain of people who actually need openGL to work properly.

Hi doct0rHu,

thanx for the link! I think this points to the right direction. So, the problem seems to be that the kernel module i915 is compiled into the kernel and so it cannot be blacklisted as a loaded module. This makes absolutely sense for an intel centric distribution:

cat /lib/modules/$(uname -r)/modules.builtin


the problem now is, how to remove / prevent the module being loaded. This needs to be done in systemd.boot and not in grub. I mounted efi to boot and edited Clear-linux-native-5.0.18-767.conf but couldn’t find a way to prevent loading the i915.

Maybe someone has a hint for an kernel option in systemd.boot to prevent loading the module?


You can also blacklist modules from the bootloader.

Simply add module_blacklist=i915 to your bootloader’s kernel line.

So to add new parameter do:

sudo mkdir -p /etc/kernel/cmdline.d/
echo "module_blacklist=i915" | sudo tee /etc/kernel/cmdline.d/blacklist.conf
sudo clr-boot-manager update

and reboot.

1 Like

This is great. We shall incorporate this into the NVIDIA driver tutorial if this is confirmed to work.