SDB:NVIDIA the hard way

Jump to: navigation, search


Situation

Installing NVIDIA's proprietary driver using their installer (.run) is desired.

This is called "the hard way" because installing via zypp is easier.

Procedure

Create a system snapshot to rollback to if needed.

# snapper create

Install the minimum requirements

The following patterns contain the minimum requirements:

# zypper in -t pattern devel_C_C++ devel_kernel 
# zypper in dkms

The kernel-source package (548M) in devel_kernel is needed according to chapter 4 of the official installation guide; however, you might investigate --add-this-kernel (in that same chapter).

Get the hardware information

In a terminal:

# lspci | grep VGA
$ lscpu | grep Arch

Alternatively:

# hwinfo --gfxcard | grep Model
# hwinfo --arch

There is also YaST2 -> Hardware Information.


Download the driver installer

These all seem to be official sources:

Direct links can be found at:

Changes in the kernel, Mesa, and Xorg can break driver compatibility, i.e. download the lastest driver before an upgrade.


Boot without nouveau

Reboot and press E at GRUB2 (the GRUB screen should look something like this: UEFI, and BIOS), then append nomodeset and 3 to the line where there's something like this:

 linux /boot/vmlinuz-5.14.21-150400.20-default ... splash=silent ... quiet ...

Note that "..." means there will be other parameters.

So, for example, that previous line should look something like this:

linux /boot/vmlinuz-5.14.21-150400.20-default ... splash=silent ... quiet ... nomodeset 3
  • nomodeset ensures the Nouveau driver won't be loaded, since Nouveau requires kernel mode-setting (KMS).
  • 3 ensures that the system boots to a virtual console (3, the famous black screen with texts) instead of to a display manager / Wayland or X session, in other words: without loading a graphical environment.

These options will not be saved for the next boot. For that, take a look at using YaST2 or editing /etc/default/grub directly as root.

Alternatively, you could try booting in IGFX (integrated graphics) mode from BIOS. For desktops this requires connection of a monitor to a motherboard video output port.

Blacklist nouveau

The proprietary driver installer will blacklist Nouveau; therefore, you can usually skip this section, but it doesn't hurt to double check it.

The installer creates the file /etc/modprobe.d/nvidia.conf that contains:

blacklist nouveau

Other versions might also add:

options nouveau.modeset=0

To double check the presence of the file and its content use:

$ cat /etc/modprobe.d/nvidia.conf

Install the driver

First, log in as root (the superuser).

To view a list of all options:

# sh /home/<username>/Downloads/<NVIDIA*.run> -A

Normal installation:

# sh /home/<username>/Downloads/<NVIDIA*.run>

When the installer indicates nouveau might have just been blacklisted, you can continue without rebooting (if you booted as suggested).

Allowing the installer to configure /etc/X11/xorg.conf creates a copy (/etc/X11/xorg.conf.nvidia-xconfig-original) of the current version, which it will restore on uninstallation.

Once the installation is complete, you might need to recreate the initrd by running:

# dracut -f

That will add /etc/modprobe.d/nvidia.conf to the initial ramdisk. To verify, run:

# lsinitrd | grep nvidia

Restart the computer:

# shutdown -r now

To check the driver's status:

 # hwinfo --gfxcard
 ...
 Driver Info #0:
   Driver Status: nouveau is not active
   Driver Activation Cmd: "modprobe nouveau"
 Driver Info #1:
   Driver Status: nvidia_drm is active
   Driver Activation Cmd: "modprobe nvidia_drm"
 Driver Info #2:
   Driver Status: nvidia is active
   Driver Activation Cmd: "modprobe nvidia"
# lsmod | grep nvidia
nvidia_drm             49152  1 
nvidia_modeset       1097728  4 nvidia_drm
nvidia              14344192  223 nvidia_modeset
ipmi_msghandler        53248  1 nvidia
drm_kms_helper        155648  2 i915,nvidia_drm
drm                   397312  6 i915,drm_kms_helper,nvidia_drm

Expert mode

Alternatively, there is an "expert" installation mode with more questions:

# sh /home/<username>/Downloads/<NVIDIA*.run> -e

Kernel updates and driver compatibility

Please note: you will have to repeat these steps whenever you update the kernel. This is necessary because, unlike with the NVIDIA driver from the NVIDIA's openSUSE repos, this driver isn't copied to directories for KMPs which remains valid across kernel updates.

Installing NVIDIA with Secure Boot

If you are dual booting or just lazy to disable secure boot on your computer, you can actually install NVIDIA with secure boot enabled. The steps are similar as above but with some modifications. We will use openssl to create a key pair and mokutil to enroll those keys/signature to our MOK list. Make sure you create a snapshot before following the steps:

Step 1.

 openssl req -new -x509 -newkey rsa:2048 -keyout PATH_TO_PRIVATE_KEY -outform DER -out PATH_TO_PUBLIC_KEY -nodes -days 36500 -subj "/CN=Graphics Drivers"]

Step 2.

 sudo mokutil --import PATH_TO_PUBLIC_KEY

then

 sudo mokutil --enable-validation

Step 3.

 sudo sh ./NVIDIA-Linux-x86_64-<NVIDIA version>.run -s --module-signing-secret-key=<PATH TO YOUR PRIVATE KEY FILE e.g. Nvidia.key> --module-signing-public-key=<PATH TO YOUR PUBLIC KEY FILE e.g. Nvidia.der> --module-signing-script=/usr/src/linux-obj/x86_64/default/scripts/sign-file

Step 4.

 sudo dracut -f

then reboot.

For versions 520.56.06 and onwards

If you have the .run files and run them with only the --module-signing-script=/usr/src/linux-obj/x86_64/default/scripts/sign-file flag, NVIDIA automatically generates a key pair for you and stores the public key in /usr/share/nvidia/nvidia-modsign-crt-<some gibberish>.der, therefore, you can skip step one and proceed to step 2.


Configuration

The installer provides two command line utilities:

# man nvidia-settings
# man nvidia-xconfig

nvidia-settings run without arguments will open a graphical user interface.


Multiple monitors

Multiple monitors might work without configuration. If not, then see chapters 12-14 of the official documentation.


Tearing

One solution for persistent tearing is:

nvidia-settings -> x server display configuration -> advanced -> force composition pipeline

Warning: Saving this to /etc/X11/xorg.conf via the nvidia-settings GUI might adversely affect loading your desktop.

Alternatively, a simple script can be used to turn it on from the command line. For example:

Create /home/<username>/bin/fcp

nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceCompositionPipeline = $1 }"
xrefresh

Make it executable:

chmod +x /home/<username>/bin/fcp

Turn it on:

fcp 1

Turn it off:

fcp 0

xrefresh can be installed via zypper. It might be needed to avoid a blank screen.

Ctrl+Alt+F1 then Ctrl+Alt+F7 can also help in that situation.


GRUB2 and virtual terminal resolution

Unlike with nouveau, virtual terminals will be low resolution.

One way to fix this is with a GRUB2 setting, which will also increase GRUB2's resolution.

yast2 > Boot Loader > Kernel Parameters > Console resolution

Alternatively, to manually achieve the same thing:

From GRUB2 you can press C, and then check the supported resolutions with: vbeinfo

After booting you can edit /etc/default/grub

Change

GRUB_GFXMODE="auto"

to

GRUB_GFXMODE=1920x1080x32
GRUB_GFXPAYLOAD_LINUX=keep

Using a resolution you found with vbeinfo. (more on gfxmode)

Then run:

# grub2-mkconfig -o /boot/grub2/grub.cfg

Enabling NVIDIA modesetting

For PRIME to work, you need to either enable the kernel parameter nvidia-drm.modeset to 1.

You can do this by adding these to your modprobe configuration or in your GRUB_CMDLINE_LINUX_DEFAULT:

  • nouveau.modeset=0
  • modprobe.blacklist=nouveau
  • rd.driver.blacklist=nouveau
  • nvidia-drm.modeset=1

The first three ensures that nouveau is really disabled. You can choose one or just copy all three. The fourth one is the needed kernel parameter to enable NVIDIA modesetting. You can check that it is working by running

 cat /sys/module/nvidia_drm/parameters/modeset

This should output "Y".


Plymouth

Plymouth, the loading screen between GRUB2 and the display manager, might not show.

To see the boot messages instead, uninstall plymouth (or add plymouth.enable=0 to the kernel parameters) and remove the kernel parameters:

splash=silent quiet

For fewer messages, set the log level:

loglevel=5

Uninstall and use modesetting or nouveau DDX

Boot with "nomodeset" and "3", like for installation.

The installer is also used to uninstall:

# sh <NVIDIA*.run> --uninstall

/etc/modprobe.d/nvidia.conf will be deleted.

/etc/X11/xorg.conf will be replaced with /etc/X11/xorg.conf.nvidia-xconfig-original (a pre-installation copy).

You might need to run dracut -f after uninstalling (more).

The default DDX modesetting has been provided by the server package since version 1.17.0 in 2015. When package xf86-video-nouveau is installed, the nouveau DDX should be utilized automagically instead.


Xorg Configuration for Optimus Setups

Taken from the Arch Wiki, just adding a file named 10-nvidia-drm-outputclass.conf to /etc/X11/xorg.conf.d/ containing

 Section "OutputClass"
   Identifier "intel"
   MatchDriver "i915"
   Driver "modesetting"
 EndSection
 Section "OutputClass"
   Identifier "nvidia"
   MatchDriver "nvidia-drm"
   Driver "nvidia"
   Option "AllowEmptyInitialConfiguration"
   Option "PrimaryGPU" "yes"
   ModulePath "/usr/lib/nvidia/xorg"
   ModulePath "/usr/lib/xorg/modules"
 EndSection

Make sure that nvidia-drm.modeset is set to 1.

Troubleshooting

There are times when using the NVIDIA installer removes the kernel modules and sources, thus, running

 sudo zypper info kernel-default 

after an installation results to have the line "Installed" to "Installed: No" like so:

 Information for package kernel-default:
 ---------------------------------------
 Repository     : Main Repository (OSS)
 Name           : kernel-default
 Version        : 6.2.1-1.1
 Arch           : x86_64
 Vendor         : openSUSE
 Installed Size : 299.3 MiB
 Installed      : No
 Status         : up-to-date
 Source package : kernel-default-6.2.1-1.1.nosrc
 Upstream URL   : https://www.kernel.org/
 Summary        : The Standard Kernel
 Description    : 
     The standard kernel for both uniprocessor and multiprocessor systems.
 
 
     Source Timestamp: 2023-02-27 11:39:51 +0000
     GIT Revision: 69e0e95118afe307ac9da57c2cc7f80673a41423
     GIT Branch: stable

To fix this, you need to reinstall kernel-default again by running

 sudo zypper install -f kernel-default 

Otherwise, you will have no kernel to boot into after a reboot.

See also

Related articles

External links