Bless Nouveau, or about my torment with Nvidia Optimus. Part 1. The charm of Arch documentation

Before i start


Before starting the main narration, I would like to clarify a few points. The article is aimed primarily at owners of laptops with Nvidia Optimus technology who want to install GNU / Linux (hereinafter Linux). The material aims to ensure that the above Central Asia familiarizes itself with possible solutions to the issue and to facilitate and speed up its decision. In addition, the article is not the least motivating , and is aimed at understanding people of one simple truth: in Linux, as in life, there will always be a workaround, and if you give up, it will be better (in most cases) not.
Qui quaerit reperit
- Latin saying

Foreword


For the time being, I was an ordinary Linux user. Testil different distros, slowly learned new. Just because I was interested. As a rule, “knowledge” was limited to Ubuntu and its forks, as well as Fedora and a couple of “user-friendly” distributions. But, as another Latin saying goes, omnia fluunt, omnia mutantur, that is, everything flows, everything changes, and it is clear that this could not last forever.

It all started well


It should be noted that I didn’t have a lot of experimentation: a relatively weak PC, which barely pulled GNOME 3, and a slow Internet, which greatly complicated the overall situation. But then more for a boy of 12 years and was not necessary. In the end I was bored with experimenting, I installed Windows 10 and forgot about Linux for a few years.

As time went on, and after about 2 years, I realized that it was time to upgrade my mossy piece of PC iron , and started saving money. Something helped out from the sales of their belongings, something gave, more than half of the amount threw the parents, I even had to sacrifice to sell my Xbox (!) entertain your ChSV to improve skills in Linux. This time I decided to try to install Arch. I heard that he has very good documentation. And he began.

Arch documentation charm


Installation was quick and relatively painless. Again, thanks to the documentation. After installing the system and DE in the face of KDE Plasma, I tried to connect the laptop to my external monitor, since the monitor has a diagonal of 24 'and the laptop display has only 15.6'. Nothing happened, the signal was not received on the monitor. As always, I started to google. And after 30 minutes of searching, I discovered that the problem is related to the technology of Nvidia Optimus.

Little about Nvidia Optimus


Nvidia is a good company. During their 25-year history, they have implemented quite a few relatively good decisions. Nvidia Optimus is one of those. The subject is a hybrid technology to ensure the correct operation of two video cards (as a rule, powerful Nvidia graphics and integrated Intel) on laptops. If it works in Windows properly configured, it helps to save electricity and laptop resources. All this is excellent, but what prompted me to write this opus is that this most beautiful technology in Linux, according to the developers, works only partially , and according to mine, its tuning requires many, many nerves, time and effort.

The beauty of Arch documentation (continued)


After I learned about the true root of the problem, I initially was delighted that I determined “where the dog was buried” (the HDMI output was only on the Nvidia card), and my first step was to read the official Arch documentation. Its essence was to use Xorg.conf and .xinitrc to force X to use only the Nvidia card. After completing these steps and rebooting ... a black screen appeared. The documentation said that in such a case it was necessary to check whether .xinitrc had ampersands, and if not, use the “Alternate Configuration”, which made X use only the Intel card. This did not suit me, since the Intel card was already used by default and this option did not suit me. There were also options for various DM. They also did not come, since none of them for various reasons could not start the X-server.
To describe each of them separately would be a very long and meaningless exercise.

Qui quaerit reperit


This expression is translated from the Latin means "Who is looking for, finds." I knowingly placed it in the beginning, because as for me this expression would be the ideal moral for this article.

I was desperate. For two days I tried in vain to find a solution, scouring foreign forums (only on them, because the answer was this on the Orthodox LOR: You cannot run X through Nvidia. It is impossible, accept it). But still, on a cloudy morning on the third day of the search, I came across a thread (link in the basement) on the Nvidia developer forum, which described how Nvidia Optimus is implemented in Arch on Dell laptops. I immediately understood - I am saved! After completing the steps, I restarted and ... a black screen. Of course, I was upset, but then I remembered: I did not register in .xinitrc the lines for running DE. Having registered exec startkde, I restarted again and it all worked. X launched through Nvidia. It took me four days to install and configure Arch, and yet I did it!

Debriefing


Now let's take a look at the instructions from the above thread. Let's start:

First you need to enable KMS support (Kernel Mode Setting, method of setting permissions directly in the kernel), adding kernel parameters (/ etc / default / grub file) to GRUB_CMDLINE_LINUX_DEFAULT = parameter

nvidia-drm.modeset=1 

Then create a script for the DM (login manager). Consider the option with LightDM. Create the /etc/lightdm/display_setup.sh script with the following content:

 #!/bin/sh xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto 

This script, we specify the supplier and set the maximum possible screen resolution.

Let's make the created script executable:

 chmod +x /etc/lightdm/display_setup.sh 

Make LightDM execute the above script on startup. First, edit /etc/lightdm/lightdm.conf:

 nano /etc/lightdm/lightdm.conf 

Enter the parameter

 display-setup-script=/etc/lightdm/display_setup.sh 

Instructions for SDDM can be found in the thread I already mentioned, links in the basement.

Now we need to update the CPU microcode (more about the microcode from the links in the basement):

 sudo pacman -S intel-ucode 

After updating the microcode, install a bunch of Nvidia packages:

 sudo pacman -S lib32-mesa-demos mesa-demos libva-vdpau-driver nvidia nvidia-libgl lib32-nvidia-utils nvidia-settings lib32-opencl-nvidia 

Note: Some of the packages may not be available. In this case, install everything separately. Packets that are not available, skip.
Let's enable the nvidia.persistenced daemon, which is responsible for persistence (read the link in the basement more about it) of the work of the Nvidia driver:

 systemctl enable nvidia-persistenced.service 

Automatically configure GRUB:

 sudo grub-mkconfig -o /boot/grub/grub.cfg 

Create a bootable ramdisk:

 mkinitcpio -p linux 

Check .xinitrc:

 nano ~/.xinitrc 

If not entered, we will enter

 exec gnome-session 

for gnome and

 exec startkde 

for KDE Plasma.

Reboot:

 reboot 

After rebooting the laptop, log in with your account and enjoy the world of Arch.

About Bumblebee and Prime


You may have noticed that I did not say anything about “crutches” that are aimed at ensuring the correct operation of Nvidia Optimus in Linux: Bumblebee and PRIME.
In addition, I only had to get an Nvidia card with a proprietary driver, Nouveau did not work (therefore, the article is called “Bless Nouveau”.
As for my personal experience with them, it is small and deplorable: both crutches point blank did not see my Nvidia video card. If you are interested in them, in the basement you will find links to materials on them.

Afterword


If you read the entire article, then you are a hero (well, or a moderator) .

When writing an article, I tried to dilute it for you with relatively funny jokes to somehow justify the lack of pictures in it. Hope you reached zen after reading.

List of sources


About microcode: ru.wikipedia.org/wiki/ Microcode
About Bumblebee: wiki.archlinux.org/index.php/Bumblebee_ (Russian)
About PRIME: wiki.archlinux.org/index.php/PRIME
Tread : devtalk.nvidia.com/default/topic/1027679/linux/optimus-support-for-arch-linux-for-dell-i7559-dual-graphics-intel-nvidia-gtx-960m-laptop-/2
About persistence: ru.wikipedia.org/wiki/Persistency

Source: https://habr.com/ru/post/414061/


All Articles