Nvidia-340 legacy driver for newer kernel series.
---------------------------------
Notes for kernel 5.11.x and newer versions:
Following lines may need to be added to a configuration file for Nvidia driver to be enabled with the 5.11 update of the kernel. These lines added to /usr/share/X11/xorg.conf.d/nvidia-drm-outputclass-ubuntu.conf by default on nvidia-340 package.
---
Section "Files"
ModulePath "/usr/lib/nvidia-340/xorg"
ModulePath "/usr/lib/xorg/modules"
EndSection
Section "Device"
Identifier "Nvidia Card"
Driver "nvidia"
VendorName "NVIDIA Corporation"
EndSection
---
If you have created /etc/X11/xorg.conf config file, it will overwrite the default configuration file as it has priority. You can delete the xorg.conf file with the command below to get workaround.
sudo rm -f /etc/X11/xorg.conf
Or, you can find a solution by adding the following lines to xorg.conf file.
---
Section "Files"
ModulePath "/usr/lib/nvidia-340/xorg"
ModulePath "/usr/lib/xorg/modules"
EndSection
---
Or you can install the xorg-modulepath-fix package from PPA repository with the following command to do this for you. This package will automatically add the above lines to xorg.conf file. This package also allows the above lines to be automatically added to the xorg.conf file when you run nvidia-xconfig command.
sudo apt install xorg-modulepath-fix