how to switch between nouveau and nvidia driver at boot time

The initramfs/initrd is definitely not modified during boot.

The article also describes fully in much better details and words than myself that indeed, GRUB loads the VESA driver (from BIOS) and does not hand over to the more advanced video driver until much later when the framebuffer interface is initialized…

Forget about GRUB.
GRUB is not part of the OS, it only starts the OS.

The problem is this:

   378.544] Parse error on line 3 of section Device in file /etc/X11/xorg.conf.d/20-nouveau.conf

        This section must have an Identifier line.

   378.544] (EE) Problem parsing the config file

   378.544] (EE) Error parsing the config file


So add an identifier to the generated 20-nouveau.conf in the script and try again:

#Check graphics mode fix symlinks

if  `grep -c "nouveau" /proc/cmdline` -gt 0 ]; then
    update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
    /sbin/ldconfig /usr/lib64
    /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END 
Section "Device"
Identifier "Default Device"
Driver "nouveau"
EndSection
END

Strange though that you’d get the same error when booting without “nouveau” afterwards. The script should delete 20-nouveau.conf in that case…
Maybe Xorg wasn’t even started and you grabbed the exact same log from the previous boot?

so, only to have a beautyful spashscreen we have to do all this mess??? :slight_smile:

No.
You have to do all this mess because nvidia replaces the system’s (Mesa’s) OpenGL libraries with their own incompatible versions.
And maybe because they do not support the open source driver development.

FYI -
This Gentoo article which looks like it should work.

https://wiki.gentoo.org/wiki/Nouveau_%26_nvidia-drivers_switching

Options described…
And note, as I described sometimes you will likely have to blacklist nvidia to work properly.

Dupe the kernel (so you have two instances of the same kernel), install a different video driver into each kernel. Now you can switch between kernels.
Using a single kernel, the hprofile utility to switch.
Use systemd (full steps described). Includes creating the GRUB menu entries (Just change the displayed text).

TSU

second try
added Identifier “Default Device” to the script
activated the script, inserted nouveau after vga=791 in the line:
“linux /boot/vmlinuz-4.1.27-27-default root=UUID167d3751-360f-4d2e-b342-27f62b8b16b7 resume=/dev/disk/by-label/swap splash=silent quiet showopts \vga=791 nouveau”
leap 42.1 boot and works !!! :wink: but with nvidia drivers
Xorg.0-after-nvidia-installation-and-script-activated-boot3-ok-2016-08-15_20e51.log
booted without activating the script, I get a text login window
Xorg.0-after-nvidia-installation-and-script-notactivated-boot4-ok-2016-08-15_21e11.log

may be but I think not, the first (boot1) start with 378.542] and have a creation time 19:05
the second (boot2) start with 46.991] and have a cration time 20:51

manythanks, ciao, pier

too early ;), only the first time worked, now I get text login inserting nouveau.
and not inserting nouveau I get a workimg nvidia login window, plasma start, first time black screen, but second time it works… partially, the folder view plasmoid gives “the process for the file protocol died unexpectedly” error and it is blank, logout and login solved the plasmoid error.

Hm, the first log shows that “nouveau” is part of the boot options, still Xorg loads the nvidia driver (but Xorg’s libglx is used, so OpenGL doesn’t work).
So apparently you did not boot without “nouveau” in this case.

The second log tries to load “nouveau” (and fails because KMS is “disabled”). You probably did not remove the generated /etc/X11/xorg.conf.d/20-nouveau.conf that tells Xorg to load nouveau.
Note that you cannot just disable the script (in particular if you used nouveau the previous boot), the system will be broken unless you repair it manually. (it removes some stuff that’s needed to use the nvidia driver, to handle that itself)

Also, can you try both cases with “plymouth.enable=0”, to prevent an interference?

The Xorg log from this failed boot would probably be interesting.

Well, I haven’t looked at it in detail yet, but it seems to use a few Gentoo specific things, especially the part that chooses the OpenGL libraries.
And all in all, the single kernel case seems not to be handled much different than we try here…

And note, as I described sometimes you will likely have to blacklist nvidia to work properly.

There’s not really a point in blacklisting nvidia IMHO.
It should only get loaded, if Xorg loads/uses the nvidia driver, as nvidia doesn’t use/support the kernel’s KMS (they do something similar though in their kernel module).

Dupe the kernel (so you have two instances of the same kernel), install a different video driver into each kernel. Now you can switch between kernels.

You don’t install a video driver into the kernel.
There’s also the Xorg driver, and the OpenGL part, which both are totally unrelated to the kernel.
But those two parts are crucial as well.

Ok, I thought about the kernel module (and plymouth) problematic a bit more, and had an idea:
We should probably try the other way, i.e. use nouveau by default and switch to nvidia via a “special” boot option (and let’s use “nomodeset” for that, as that also disables loading the nouveau kernel module completely:wink: )

So, change the boot.local script to this:

#Make sure we are in command of /usr/X11R6/libif  -e /etc/ld.so.conf.d/nvidia-gfxGO*.conf ]; then
    /bin/rm /etc/ld.so.conf.d/nvidia-gfxGO*.conf
fi

if  -e /etc/modprobe.d/nvidia-*.conf ]; then
  #remove blacklist, we don't need it
  /bin/rm /etc/modprobe.d/nvidia-*.conf
  mkinitrd
fi

#Check graphics mode fix symlinks
if  `grep -c "nomodeset" /proc/cmdline` -eq 0 ]; then
     update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
     /sbin/ldconfig /usr/lib64
     /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END
Section "Device"
Identifier "Default Device"
Driver "nouveau"
EndSection
END
    # use Mesa's libGL
     ln -sf  /usr/lib64/libGL.so.1.2.0 /usr/lib64/libGL.so.1
fi

if  `grep -c "nomodeset" /proc/cmdline` -gt 0 ]; then
     update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so
     /sbin/ldconfig /usr/X11R6/lib64
     /bin/rm /etc/X11/xorg.conf.d/20-nouveau.conf
     # use nvidia's libGL
     ln -sf  /usr/X11R6/lib64/libGL.so.1 /usr/lib64/libGL.so.1
fi

(changes are in red)

Then delete the blacklist file (should be /etc/modprobe.d/nvidia-default.conf), and run “sudo mkinitrd” to add the nouveau kernel module to the initrd.

You should now be able to switch to nvidia by adding “nomodeset” (not “noveau”) to the boot options.
If you use /etc/grub.d/10-linux-nouveau to create the additional boot menu entries, change it to add “nomodeset” instead of “nouveau” (and change the title accordingly to say “nvidia” instead of “nouveau”… :wink: )

I hope it will work this way then, and there should be no need to disable nouveau (nomodeset has immediate effect from the point the kernel is loaded).

ok, before to read your proposal to change the script and use nouveau as default (I like more nouveau as default :wink: ) I did this test

third try
boot without inserting nouveau
leap 42.1 boot, graphic nvidia login, plasma5 start, it seems to works, the cube effect doesn’t works
boot again, twice, without inserting nouveau (to verify the previous strange behaviour)
the same as previous leap 42.1 boot, graphic nvidia login, plasma5 start, it seems to works, the cube effect doesn’t works
the log should be the same for the three, like this
Xorg.0-after-nvidia-installation-and-script-notactivated-boot5-6-7-ok-nocube-2016-08-16_10e56.log
boot inserting nouveau three times
leap 42.1 boot, text login, plasma5 doesn’t start, the logs are these
Xorg.0-after-nvidia-installation-and-script-activated-boot5-fail-textlogin-2016-08-16_11e06.log
Xorg.0-after-nvidia-installation-and-script-activated-boot6-fail-textlogin-2016-08-16_11e23.log
Xorg.0-after-nvidia-installation-and-script-activated-boot7-fail-textlogin-2016-08-16_11e28.log

boot without inserting nouveau
leap 42.1 boot, text login, plasma5 doesn’t start, the log is this
Xorg.0-after-nvidia-installation-and-script-notactivated-boot8-fail-textlogin-2016-08-16_11e33.log

boot without inserting nouveau
leap 42.1 boot, graphic nvidia login, plasma5 start, it seems to works, the cube effect doesn’t works
Xorg.0-after-nvidia-installation-and-script-notactivated-boot9-ok-nocube-2016-08-16_11e35.log

it seems that the first boot without inserting nouveau after having inserted nouveau fails and the second and the other are ok

fourth try
changed the script to have nouveau default and activate nvidia with nomodeset
the new boot.local script is this

#Make sure we are in command of /usr/X11R6/libif  -e /etc/ld.so.conf.d/nvidia-gfxGO*.conf ]; then
    /bin/rm /etc/ld.so.conf.d/nvidia-gfxGO*.conf
fi


if  -e /etc/modprobe.d/nvidia-*.conf ]; then
  #remove blacklist, we don't need it
  /bin/rm /etc/modprobe.d/nvidia-*.conf
  mkinitrd
fi


#Check graphics mode fix symlinks
if  `grep -c "nomodeset" /proc/cmdline` -eq 0 ]; then
     update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
     /sbin/ldconfig /usr/lib64
     /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END
Section "Device"
Identifier "Default Device"
Driver "nouveau"
EndSection
END
    # use Mesa's libGL
     ln -sf  /usr/lib64/libGL.so.1.2.0 /usr/lib64/libGL.so.1
fi


if  `grep -c "nomodeset" /proc/cmdline` -gt 0 ]; then
     update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so
     /sbin/ldconfig /usr/X11R6/lib64
     /bin/rm /etc/X11/xorg.conf.d/20-nouveau.conf
     # use nvidia's libGL
     ln -sf  /usr/X11R6/lib64/libGL.so.1 /usr/lib64/libGL.so.1
fi

deleted the blacklist file /etc/modprobe.d/nvidia-default.conf
ran mkinitrd as superuser
reboot not inserting nomodeset
seems to boot with nouveau becouse resolution is high (small characters)
hangs at “starting show plymouth boot screen…” a lot of time
then I get a “general protection fault: 0000 #1] PREEMPT SMP”
“Modules linked in: nf_log_ipv6 and many others…”
“CPU: 4 PID: 16263 COMM: Xorg Tained: P W O 4.1.27-27default #1
and many other numbers
tried again
hangs at “starting show plymouth boot screen…”
[OK]“Reached target system inizialization” many time
and after much time give the same error as previously
the log should be this, after the reboot inserting nomodeset I found an Xorg.0.old and copied as
Xorg.0-2-nouveau-default-script-nonomodeset-failed-2016-08-16_12e28.old.log

switch to nvidia by adding “nomodeset”
leap 42.1 boot, nvida splash, nvidia login window, plasma5 start, it seems to works, the cube effect doesn’t works
my impression is that it takes more time than usual
the log is this
Xorg.0-2-nouveau-default-script-yesnomodeset-boot2.2-ok-nocube-2016-08-16_12e31.log

manythanks, ciao, :slight_smile: pier

Well, it doesn’t mention that it added nouveau (I’m not sure if it should though).

You ran that while using the nvidia driver, right?
Maybe nouveau is only inserted if you are actually using it…

Try to add “plymouth.enable=0” to the boot options (to prevent a boot problem), and then run mkinitrd again.
This should really add nouveau to the initrd.
Or add “nouveau” to the INITRD_MODULES line in /etc/sysconfig/kernel (and run mkinitrd afterwards) to force it being added.

the log should be this, after the reboot inserting nomodeset I found an Xorg.0.old and copied as
Xorg.0-2-nouveau-default-script-nonomodeset-failed-2016-08-16_12e28.old.log

Strange enough, this still shows that nvidia’s libglx is loaded.

Please make this change to rule out a possible problem with the path:

#Make sure we are in command of /usr/X11R6/lib
if  -e /etc/ld.so.conf.d/nvidia-gfxG0*.conf ]; then
    /bin/rm /etc/ld.so.conf.d/nvidia-gfxG0*.conf
fi

if  -e /etc/modprobe.d/nvidia-*.conf ]; then
  #remove blacklist, we don't need it
  /bin/rm /etc/modprobe.d/nvidia-*.conf
  /sbin/mkinitrd
fi

#Check graphics mode fix symlinks
if  `grep -c "nomodeset" /proc/cmdline` -eq 0 ]; then
     /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
     /sbin/ldconfig /usr/lib64
     /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END
Section "Device"
Identifier "Default Device"
Driver "nouveau"
EndSection
END
    # use Mesa's libGL
     ln -sf  /usr/lib64/libGL.so.1.2.0 /usr/lib64/libGL.so.1
fi

if  `grep -c "nomodeset" /proc/cmdline` -gt 0 ]; then
     /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so
     /sbin/ldconfig /usr/X11R6/lib64
     /bin/rm /etc/X11/xorg.conf.d/20-nouveau.conf
     # use nvidia's libGL
     ln -sf  /usr/X11R6/lib64/libGL.so.1 /usr/lib64/libGL.so.1
fi

Maybe the update-alternatives command is not found because /usr/sbin/ is not in the path.

Oh, and you typed a letter O instead of the number 0 in the 2nd and 3rd line.
This could cause problems as well, as applications might still use nvidia’s libGL then even with nouveau… :wink:

The nvidia log looks good though.
Maybe kwin just disabled desktop effects previously because of the “broken” boot with nouveau.

fifth try adding “plymouth.enable=0”
added “nouveau” to the INITRD_MODULES line in /etc/sysconfig/kernel
ran mkinitrd as superuser
mkinitrd fifth try 2016ago16.txt at
http://paste.opensuse.org/91054764
changed the script in boot.local as you proposed

#Make sure we are in command of /usr/X11R6/lib
if  -e /etc/ld.so.conf.d/nvidia-gfxG0*.conf ]; then
    /bin/rm /etc/ld.so.conf.d/nvidia-gfxG0*.conf
fi


if  -e /etc/modprobe.d/nvidia-*.conf ]; then
  #remove blacklist, we don't need it
  /bin/rm /etc/modprobe.d/nvidia-*.conf
  /sbin/mkinitrd
fi


#Check graphics mode fix symlinks
if  `grep -c "nomodeset" /proc/cmdline` -eq 0 ]; then
     /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
     /sbin/ldconfig /usr/lib64
     /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END
Section "Device"
Identifier "Default Device"
Driver "nouveau"
EndSection
END
    # use Mesa's libGL
     ln -sf  /usr/lib64/libGL.so.1.2.0 /usr/lib64/libGL.so.1
fi


if  `grep -c "nomodeset" /proc/cmdline` -gt 0 ]; then
     /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so
     /sbin/ldconfig /usr/X11R6/lib64
     /bin/rm /etc/X11/xorg.conf.d/20-nouveau.conf
     # use nvidia's libGL
     ln -sf  /usr/X11R6/lib64/libGL.so.1 /usr/lib64/libGL.so.1
fi

boot leap 42.1 adding “plymouth.enable=0”
seems to boot with nouveau becouse resolution is high (small characters)

start with [FAILED] Failed to start Load Kernel Modules
See "systemctl status system-modules-load.service" for details
hang a lot at
[OK] Found Device TOSHIBA_MQ01ABD1 susestable
then started dracut initqueue hook
then hang a lot at
[OK] Reached target Initrd Default Target
then continue but stop with error
"general protection fault: 0000 #1] PREEMPT SMP"
"Modules linked in: nf_log_ipv6 and many others..."
"CPU: 4 PID: 16263 COMM: Xorg Tained: P      W   O    4.1.27-27default #1"
and many other numbers

retry,
boot leap 42.1 adding “plymouth.enable=0”
the same as before hangs included but
leap 42.1 boot, nouveau login screen appear, plasma5 start with nouveau, it seems to works, the cube effect doesn’t works
system settings>display configuration>compositor> “enable compositor at startup” is checked
“rendering backend” was Xrender I changed in OpenGL 3.1
but the system seems very slow
reboot

it works but the system seems very slow and very hot
I have the impression that the thermal control doesn’t works well
system settings>display configuration>compositor> “enable compositor at startup” is checked
“rendering backend” was Xrender I changed in OpenGL 3.1 before but it is again at Xrender
the log is this
Xorg.0-2-nouveau-default-script-nonomodeset-yesdisableplymouth-boot2.2ok-nouveau-2016ago1622e37.log at
http://paste.opensuse.org/58387988
when I reboot it stops at

"[OK] Reached target Shutdown"

and hangs there, the hard disk continues to blink, after 3minutes I hard-shutdown

reboot with “plymouth.enable=0” and “nomodeset” to activate nvidia
seems to boot with nvidia resolution but I have a text login
the log should be this, after the reboot I found an Xorg.0.old and copied as
Xorg.0-2-nouveau-default-script-yesnomodeset-yesdisableplymouth-boot2.2fail-text-2016ago16_23e18.log.old.log at http://paste.opensuse.org/55503723

reboot again with “plymouth.enable=0” and “nomodeset”
leap 42.1 boot, nvidia splash, nvidia login, plasma5 start, it seems to works, the cube effect doesn’t works
system settings>display configuration>compositor> “enable compositor at startup” is checked
“rendering backend” was Xrender I changed in OpenGL 3.1 and the cube effect works
this is the log
Xorg.0-2-nouveau-default-script-yesnomodeset-yesdisableplymouth-boot2.2ok-nvidia-2016ago16_23e21.log at
http://paste.opensuse.org/33565889

at the end nouveau seems to not works properly, nvidia seems to works properly, both needs of a double reboot to works
have I to leave “nouveau” to the INITRD_MODULES line in /etc/sysconfig/kernel after have ran mkinitrd??

manythanks, ciao, pier :slight_smile: