Switch in boot.local between intel GPU and Nvidia GPU / Nouveau

Folks,

I’m sick of that ****ed Nvidia GPU in my notebook. Fortunately there is an integrated Intel GPU. In the BIOS there is a switch: use either the integrated GPU, the discrete GPU or Optimus. If I switch to the integrated GPU, boot.local tells the kernel which driver to load. Usually I stick to the integrated GPU, but if I need the DisplayPort, I reboot, changing the BIOS to Nvidia at the restart.

To make the kernel load the correct driver, I installed the proprietary NVIDIA driver, but that is not a stable thing. So I’d like to try whether the nouveau driver is mature enough. To this end, I need to adapt the boot.local. Instead of the path to the NVIDIA driver it needs to point to the nouveau driver. Right now it looks like this:


#! /bin/sh
#
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.  All rights reserved.
#
# Author: Werner Fink, 1996
#         Burchard Steinbild, 1996
#
# /etc/init.d/boot.local
#
# script with local commands to be executed from init on system startup
#
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#

mode=$(/sbin/lspci | egrep 'VGA|3D');

#Make shure 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  


#Check graphics mode and take apropriate action
if  `echo $mode | grep -c "Intel" ` -gt 0 ]; then
      /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
      /sbin/ldconfig
      if  -e /etc/X11/xorg.conf ]; then
          mv /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia
      fi
fi 


if  -e /usr/X11R6/lib64/libGL.so.1 ]; then
    /bin/rm /usr/X11R6/lib64/libGL.so.1
fi    


if  -e /usr/X11R6/lib/libGL.so.1 ]; then
    /bin/rm /usr/X11R6/lib/libGL.so.1
fi    


if  `echo $mode | grep -c "NVIDIA" ` -gt 0 ]; then
    /usr/sbin/update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so 
    /sbin/ldconfig /usr/X11R6/lib64
    /sbin/ldconfig /usr/X11R6/lib
    if  -e /etc/X11/xorg.conf.nvidia ]; then
        mv /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
    fi
fi


So how to adapt this to use the nouveau driver?

Not sure if I understand you correctly, but if you want to switch between intel and nvidia in the BIOS and load the corresponding driver (intel or nouveau), there should not be any problem I think.

Just uninstall the nvidia driver, and remove that boot script. (and probably remove the /etc/X11/xorg.conf if it exists)

Xorg and the kernel should load the correct driver automatically.

That script is basically just needed because nvidia breaks Mesa, which in turn is needed for the open source drivers like intel and nouveau.

OK, and I do not even need the xorg.conf or something for nouveau?

IMHO, no.

Again, Xorg should choose the correct driver automatically, if you don’t specify one yourself in a config file.

But, I cannot guarantee you that all will work for you as expected.

As already mentioned elsewhere, I don’t have your system (or any Optimus system at all), so I cannot test it.
I only try to suggest things that sound plausible to me, according to my experience and understanding (which mainly includes open source radeon/intel, and strict nvidia systems, not Optimus).