Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: how to switch between nouveau and nvidia driver at boot time

  1. #1

    Default how to switch between nouveau and nvidia driver at boot time

    my system is running opensuse leap 42.1 with plasma 5.7.3:
    Laptop=Dell latitude E6510, RAM=8Gb, GPU=GT218 NVS 3100M, CPU=i7 Q 720 @ 1.60GHz
    upgraded 13.2 to leap 42.1, using wolfi repos. I'm running KDE 4.14.18 and plasma 5.7.3, KDE frameworks 5.24.0, KDE applications 16.04.3, Kernel 4.1.27-27-default

    nvidia drivers cons:
    -After resume from RAM keyboard doesn't works on many applications
    -sometimes not all icons are shown in the system tray
    -some graphical glitch after resume from RAM
    -do not works at full resolution 1920x1080
    nvidia drivers pros:
    -works well with dual monitor

    nouveau drivers cons:
    -I haven't tested now, but time ago it didn't works well with dual monitor
    nouveau drivers pros:
    -After resume from RAM keyboard works
    -all icons are shown in the system tray
    -works at full resolution 1920x1080
    -no graphical glitch after resume from RAM

    so I think it would be useful to have the possibility to easily switch between nouveau and nvidia to have a better working opensuse

    about switching I found this:
    Code:
    #Make sure we are in command of /usr/X11R6/lib
    if [ -e /etc/ld.so.conf.d/nvidia-gfxGO*.conf ]; then
        /bin/rm /etc/ld.so.conf.d/nvidia-gfxGO*.conf
    fi  
    
    #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
        /bin/cat > /etc/X11/xorg.conf.d/20-nouveau.conf << END 
    Section "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 "nouveau" /proc/cmdline` -eq 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
    and install two identical distro but the graphic drivers.
    I think to start with the script could be a good solution.
    but the script was for KDE4, and as said here:
    "....nvidia breaks Mesa's OpenGL... ...you'd need to set an environment variable..." so may be the script doesn't works with plasma5 or needs only to add something.
    how can I use the script and where I have to save it?
    is there a way to have two lines in grub to boot with nvidia and with nouveau??
    manythanks, ciao, pier :-)

  2. #2

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by pier_andreit View Post
    nvidia drivers cons:
    -After resume from RAM keyboard doesn't works on many applications
    -sometimes not all icons are shown in the system tray
    -some graphical glitch after resume from RAM
    At least the last one is a known common problem with the nvidia driver.
    Try to disable compositing before suspending. Should fix the graphical corruption at least.

    See also this thread https://forum.kde.org/viewtopic.php?f=111&t=121590

    -do not works at full resolution 1920x1080
    It should.

    nouveau drivers cons:
    -I haven't tested now, but time ago it didn't works well with dual monitor
    Should work AFAIK.

    nouveau drivers pros:
    -After resume from RAM keyboard works
    -all icons are shown in the system tray
    -works at full resolution 1920x1080
    -no graphical glitch after resume from RAM
    Your list doesn't look like you need the nvidia driver at all...

    so I think it would be useful to have the possibility to easily switch between nouveau and nvidia to have a better working opensuse
    That's not easily possible, as nvidia replaces some of Mesa's libraries with its own versions.
    Just having nvidia installed therefore breaks nouveau's OpenGL support (and even Mesa's software renderer).

    OTOH, OpenGL will not work with nvidia if you put back the original (i.e. Mesa's) libraries.

    about switching I found this:
    ...
    and install two identical distro but the graphic drivers.
    If you use that script to switch, you don't have to "install two identical distro but the graphic drivers".


    I think to start with the script could be a good solution.
    but the script was for KDE4, and as said here:
    "....nvidia breaks Mesa's OpenGL... ...you'd need to set an environment variable..." so may be the script doesn't works with plasma5 or needs only to add something.
    There's nothing KDE4 specific at all in that script.
    It should work regardless of the desktop you use.

    how can I use the script and where I have to save it?
    You need to start that script during boot, e.g. by putting it into /etc/init.d/boot.local.
    That's mentioned in the thread you linked to: https://forums.opensuse.org/showthre...82#post2675282

    Then you can switch to the nouveau driver by adding "nouveau" to the kernel parameters.

    Note that I never tried that script myself as I don't have any nvidia card, and that thread was about 13.2, things might have changed though I believe it should still work.

    is there a way to have two lines in grub to boot with nvidia and with nouveau??
    Yes.
    You could add a "nouveau" line manually (via /boot/grub2/custom.cfg e.g.).

    But I would probably create a copy of /etc/grub.d/10-linux.sh (name it /etc/grub.d/10-linux-nouveau.sh e.g.) that adds "nouveau" to the line starting with 'linux='/'linuxefi=' (i.e. the kernel parameters).
    This would create those entries automatically.
    Last edited by wolfi323; 13-Aug-2016 at 06:53.

  3. #3

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by wolfi323 View Post
    But I would probably create a copy of /etc/grub.d/10-linux.sh (name it /etc/grub.d/10-linux-nouveau.sh e.g.) that adds "nouveau" to the line starting with 'linux='/'linuxefi=' (i.e. the kernel parameters).
    This would create those entries automatically.
    there isn't /etc/grub.d/10-linux.sh
    Code:
    pla@suseST-pla:/etc/grub.d> ls
    00_header  10_linux-nouveau  30_os-prober  80_suse_btrfs_snapshot
    00_tuned   20_linux_xen      40_custom     90_persistent
    10_linux   20_memtest86+     41_custom     README
    I suppose it should be /etc/grub.d/10_linux
    and there isn't a line starting with 'linux='/'linuxefi='
    this is the content of /etc/grub.d/10_linux
    Code:
    #! /bin/sh
    set -e
    
    # grub-mkconfig helper script.
    # Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
    #
    # GRUB is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # GRUB is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
    
    prefix="/usr"
    exec_prefix="/usr"
    datarootdir="/usr/share"
    
    . "${datarootdir}/grub2/grub-mkconfig_lib"
    
    export TEXTDOMAIN=grub2
    export TEXTDOMAINDIR="${datarootdir}/locale"
    
    CLASS="--class gnu-linux --class gnu --class os"
    
    if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
      OS=GNU/Linux
    else
      OS="${GRUB_DISTRIBUTOR}"
      CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
    fi
    
    # loop-AES arranges things so that /dev/loop/X can be our root device, but
    # the initrds that Linux uses don't like that.
    case ${GRUB_DEVICE} in
      /dev/loop/*|/dev/loop[0-9])
        GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
      ;;
    esac
    
    # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
    # and mounting btrfs requires user space scanning, so force UUID in this case.
    if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
        || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
        || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
      LINUX_ROOT_DEVICE=${GRUB_DEVICE}
    else
      LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
    fi
    
    if [ "x$GRUB_CONMODE" != "x" ]; then
      GRUB_CMDLINE_LINUX="conmode=${GRUB_CONMODE} ${GRUB_CMDLINE_LINUX}"
    fi
    
    case x"$GRUB_FS" in
        xbtrfs)
        if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then
        GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}"
        else
        rootsubvol="`make_system_path_relative_to_its_root /`"
        rootsubvol="${rootsubvol#/}"
        if [ "x${rootsubvol}" != x ]; then
            GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
        fi
        fi;;
        xzfs)
        rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
        bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
        LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
        ;;
    esac
    
    title_correction_code=
    
    hotkey=1
    incr_hotkey()
    {
      [ -z "$hotkey" ] && return
      expr $hotkey + 1
    }
    print_hotkey()
    {
      keys="123456789abdfgijklmnoprtuvwyz"
      if [ -z "$hotkey" ]||[ $hotkey -eq 0 ]||[ $hotkey -gt 30 ]; then
        return
      fi
      echo "--hotkey=$(expr substr $keys $hotkey 1)"
    }
    
    linux_entry ()
    {
      os="$1"
      version="$2"
      type="$3"
      args="$4"
    
      if [ -n "${linux_root_device_thisversion}" ]; then
        root_device="root=${linux_root_device_thisversion}"
      else
        root_device=""
      fi
    
      if [ -z "$boot_device_id" ]; then
          boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
      fi
      if [ x$type != xsimple ] ; then
          case $type in
          recovery)
              title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;;
          *)
              title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;
          esac
          if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
          fi
          echo "menuentry '$(echo "$title" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
          hotkey=$(incr_hotkey)
      else
          echo "menuentry '$(echo "$os" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
          hotkey=$(incr_hotkey)
      fi      
      if [ x$type != xrecovery ] ; then
          save_default_entry | grub_add_tab
      fi
    
      # Use ELILO's generic "efifb" when it's known to be available.
      # FIXME: We need an interface to select vesafb in case efifb can't be used.
      if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
          echo "    load_video" | sed "s/^/$submenu_indentation/"
          if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \
          && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then
          echo "    set gfxpayload=keep" | sed "s/^/$submenu_indentation/"
          fi
      else
          if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then
          echo "    load_video" | sed "s/^/$submenu_indentation/"
          fi
          echo "    set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/"
      fi
    
      echo "    insmod gzio" | sed "s/^/$submenu_indentation/"
    
     if [ $PLATFORM != emu ]; then # 'search' does not work for now
      if [ x$dirname = x/ ]; then
        if [ -z "${prepare_root_cache}" ]; then
          prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
        fi
        printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/"
      else
        if [ -z "${prepare_boot_cache}" ]; then
          prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
        fi
        printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
      fi
     fi
      message="$(gettext_printf "Loading Linux %s ..." ${version})"
      if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args}
    EOF
      else
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linux    ${rel_dirname}/${basename} ${root_device} ${args}
    EOF
      fi
      if test -n "${initrd}" ; then
        # TRANSLATORS: ramdisk isn't identifier. Should be translated.
        message="$(gettext_printf "Loading initial ramdisk ...")"
        if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
          sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        initrdefi ${rel_dirname}/${initrd}
    EOF
        else
          sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        initrd    ${rel_dirname}/${initrd}
    EOF
        fi
      fi
      sed "s/^/$submenu_indentation/" << EOF
    }
    EOF
    }
    
    machine=`uname -m`
    case "$machine" in
        i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;;
        s390 | s390x)  klist="/boot/image-* /boot/kernel-*" ;;
        aarch64)       klist="/boot/Image-* /boot/kernel-*" ;;
        *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \
            /boot/kernel-*" ;;
    esac
    list=`for i in $klist; do
        if grub_file_is_not_garbage "$i" ; then
            echo -n "$i " ;
        fi
        done`
    
    case "$machine" in
        i?86) GENKERNEL_ARCH="x86" ;;
        mips|mips64) GENKERNEL_ARCH="mips" ;;
        mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
        arm*) GENKERNEL_ARCH="arm" ;;
        *) GENKERNEL_ARCH="$machine" ;;
    esac
    
    PLATFORM="native"
    if [ -d /sys/firmware/efi ]&&[ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
        PLATFORM="efi"
    else
        case "$machine" in
            s390*) PLATFORM="emu" ;;
        esac
    fi
    
    prepare_boot_cache=
    prepare_root_cache=
    boot_device_id=
    title_correction_code=
    
    # Extra indentation to add to menu entries in a submenu. We're not in a submenu
    # yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
    submenu_indentation=""
    
    is_top_level=true
    while [ "x$list" != "x" ] ; do
      linux=`version_find_latest $list`
      gettext_printf "Found linux image: %s\n" "$linux" >&2
      basename=`basename $linux`
      dirname=`dirname $linux`
      rel_dirname=`make_system_path_relative_to_its_root $dirname`
      if [ $PLATFORM != "emu" ]; then
        hotkey=0
      else
        if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
           [ "x${GRUB_FS}" = "xbtrfs" ] ; then
           rel_dirname="\${btrfs_subvol}$dirname"
        else
           rel_dirname="$dirname"
        fi
      fi
      version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
      alt_version=`echo $version | sed -e "s,\.old$,,g"`
      linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
    
      initrd=
      for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
           "initrd-${version}" "initramfs-${version}.img" \
           "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
           "initrd-${alt_version}" "initramfs-${alt_version}.img" \
           "initramfs-genkernel-${version}" \
           "initramfs-genkernel-${alt_version}" \
           "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
           "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
        if test -e "${dirname}/${i}" ; then
          initrd="$i"
          break
        fi
      done
    
      config=
      for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
        if test -e "${i}" ; then
          config="${i}"
          break
        fi
      done
    
      # try to get the kernel config if $linux is a symlink
      if test -z "${config}" ; then
        lnk_version=`basename \`readlink -f $linux\` | sed -e "s,^[^0-9]*-,,g"`
        if (test -n ${lnk_version} && test -e "${dirname}/config-${lnk_version}") ; then
          config="${dirname}/config-${lnk_version}"
        fi
      fi
    
      # check if we are in xen domU
      if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then
        # we're running on xen domU guest
        dmi=/sys/class/dmi/id
        if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then
          product_name=`cat ${dmi}/product_name`
          sys_vendor=`cat ${dmi}/sys_vendor`
          if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then
            # xen HVM guest
            xen_pv_domU=false
          fi
        fi
      else
        # we're running on baremetal or xen dom0
        xen_pv_domU=false
      fi
    
      if test "$xen_pv_domU" = "false" ; then
        # prevent xen kernel without pv_opt support from booting
        if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && ! grep -qx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then
          echo "Skip xenlinux kernel $linux" >&2
          list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
          continue
        fi
      fi
    
      initramfs=
      if test -n "${config}" ; then
          initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
      fi
    
      if test -n "${initrd}" ; then
        gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2
      elif test -z "${initramfs}" ; then
        # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
        # no initrd or builtin initramfs, it can't work here.
        linux_root_device_thisversion=${GRUB_DEVICE}
      fi
    
      if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
        linux_entry "${OS}" "${version}" simple \
        "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
    
        submenu_indentation="$grub_tab"
        
        if [ -z "$boot_device_id" ]; then
        boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
        fi
        # TRANSLATORS: %s is replaced with an OS name
        echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' $(print_hotkey) \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
        hotkey=$(incr_hotkey)
        is_top_level=false
      fi
    
      linux_entry "${OS}" "${version}" advanced \
                  "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
      if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
        linux_entry "${OS}" "${version}" recovery \
                    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_RECOVERY}"
      fi
    
      list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
    done
    
    # If at least one kernel was found, then we need to
    # add a closing '}' for the submenu command.
    if [ x"$is_top_level" != xtrue ]; then
      echo '}'
    fi
    
    echo "$title_correction_code"
    and the lines are many , where I have to add nouveau??
    manythanks

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,953
    Blog Entries
    2

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Just some musing...

    Wonder if a different approach that either uninstalls or installs the nVidia driver on boot (or with a reboot), invoked early in the boot sequence (ie. as a requirement to achieve multi-user.target, or before plymouth can start to load). The nVidia and nouveau files can be cached.

    This approach would likely be implemented as a GRUB menu option, and would avoid setting up an nVidia and nouveau configuration side by side (and would therefor not require a working update-alternatives).

    It would seem to me that this suggested approach would be a "more natural" approach that is consistent with the current architecture that requires only one or the other, and not both drivers to be installed (and used) at a time. This might also be a better approach now that today's GPU drivers are kernel-mode so have to be compiled on demand during boot instead of the very old days when User mode drivers can simply be switched. AFAIK from what I've observed, GPU drivers are compiled into the kernel during boot, not implemented as kernel loadable modules so I really doubt any approach that was described in the forum thread about creating a script to switch would work.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  5. #5

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by pier_andreit View Post
    there isn't /etc/grub.d/10-linux.sh
    Yes, I haven't verified.

    Yes, it's actually 10_linux that creates your Linux/openSUSE boot menu entry.

    I suppose it should be /etc/grub.d/10_linux
    and there isn't a line starting with 'linux='/'linuxefi='
    With "linux" *or* "linuxefi", they are in the linux_entry() function that creates a Linux boot menu entry.

    Code:
    #! /bin/sh
    set -e
    
    # grub-mkconfig helper script.
    # Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
    ...
    linux_entry ()
    {
    ...
    
      message="$(gettext_printf "Loading Linux %s ..." ${version})"
      if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args}
    EOF
      else
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linux    ${rel_dirname}/${basename} ${root_device} ${args}
    EOF
      fi
    ...
    append nouveau at the end of those two lines, after the "${args}".
    (of course there would also be other ways to do it... )

    And you would probably also want to modify the title, so that you can identify and select the correct one.
    Search for "title="...
    Last edited by wolfi323; 13-Aug-2016 at 13:18.

  6. #6

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by tsu2 View Post
    Wonder if a different approach that either uninstalls or installs the nVidia driver on boot (or with a reboot), invoked early in the boot sequence (ie. as a requirement to achieve multi-user.target, or before plymouth can start to load).
    plymouth is started even before / is mounted.

    But actually that script does some form of "uninstallation".
    It switches between nvidia's files and Mesa's.

    And TBH, personally I wouldn't want to have the nvidia driver being installed or uninstalled *during boot*, this can take minutes...

    This approach would likely be implemented as a GRUB menu option, and would avoid setting up an nVidia and nouveau configuration side by side (and would therefor not require a working update-alternatives).
    This would again require two independent systems, or some startup script that does the work you mentioned.

    So in the end it would be exactly the same.

    AFAIK from what I've observed, GPU drivers are compiled into the kernel during boot, not implemented as kernel loadable modules
    That's nonsense.

    THe GPU drivers' kernel modules are loadable modules like all other kernel modules, and are loaded during boot.
    In the case of the nvidia driver the kernel module is compiled at *installation* time, because the nvidia driver only comes with the kernel module's source code (it would be impossible to ship modules for all available kernel versions, flavors, and so on).
    But again, it will not be compiled *into* the kernel. It will be copied to /lib/modules/ then during installation, where the kernel can load it from (or not).
    Last edited by wolfi323; 13-Aug-2016 at 13:29.

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,953
    Blog Entries
    2

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by wolfi323 View Post
    plymouth is started even before / is mounted.

    But actually that script does some form of "uninstallation".
    It switches between nvidia's files and Mesa's.

    And TBH, personally I wouldn't want to have the nvidia driver being installed or uninstalled *during boot*, this can take minutes...


    This would again require two independent systems, or some startup script that does the work you mentioned.

    So in the end it would be exactly the same.


    That's nonsense.

    THe GPU drivers' kernel modules are loadable modules like all other kernel modules, and are loaded during boot.
    In the case of the nvidia driver the kernel module is compiled at *installation* time, because the nvidia driver only comes with the kernel module's source code (it would be impossible to ship modules for all available kernel versions, flavors, and so on).
    But again, it will not be compiled *into* the kernel. It will be copied to /lib/modules/ then during installation, where the kernel can load it from (or not).
    I'm not running an nvidia GPU at the moment, so haven't looked at this for a year or so...
    Are you sure that the GPU is compiled as a <loadable> kernel module?
    Today's Linux kernel loads as a base "monolithic" part where I thought the GPU is compiled into, and then during boot or sometimes later, the "second half" of the kernel which includes the <loadable> kernel modules are added only after then the boot sequence continues.

    Unless I didn't interpret what I've seen correctly, this is the reason why you you can't willy-nilly switch between display drivers without a reboot (because the GPU drivers have to be compiled into the monolithic part which can't change during that system session).

    Note that I'm not saying that display drivers aren't distributed as a package/module, I'm saying that the <type> of module is important, and that GPU drivers are not distributed as KLM (kernel loadable modules), or at least that was my educated guess which could turn out to be wrong(?!).

    If I'm wrong, a telling indicator would be that you can switch between nvidia and nouveau kernel mode drivers without a reboot.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  8. #8

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by tsu2 View Post
    Are you sure that the GPU is compiled as a <loadable> kernel module?
    Yes.

    Otherwise you'd need to recompile the module and the kernel on each kernel update.
    (To compile something *into* the kernel, you'd need to compile the kernel itself too)

    If I'm wrong, a telling indicator would be that you can switch between nvidia and nouveau kernel mode drivers without a reboot.
    The problem is that you cannot unload the kernel module while the device is in use (and normally it is in use even in "text" mode).
    And you maybe cannot completely reinitialize the graphics card if it is/was in use already (without a reboot).

    Other than that, it should indeed work to switch to text mode, install/uninstall the nvidia driver, and then start graphics mode again, to switch between nvidia and nouveau.
    But IMHO that's even more complicated, and as I said, (un)installing the nvidia driver (and compiling the kernel module) can take quite long.

  9. #9

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by wolfi323 View Post
    Yes, I haven't verified.

    Yes, it's actually 10_linux that creates your Linux/openSUSE boot menu entry.


    With "linux" *or* "linuxefi", they are in the linux_entry() function that creates a Linux boot menu entry.

    Code:
    #! /bin/sh
    set -e
    
    # grub-mkconfig helper script.
    # Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
    ...
    linux_entry ()
    {
    ...
    
      message="$(gettext_printf "Loading Linux %s ..." ${version})"
      if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args}
    EOF
      else
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
        linux    ${rel_dirname}/${basename} ${root_device} ${args}
    EOF
      fi
    ...
    append nouveau at the end of those two lines, after the "${args}".
    (of course there would also be other ways to do it... )

    And you would probably also want to modify the title, so that you can identify and select the correct one.
    Search for "title="...
    done, but it doesn't works, no new line in grub,
    so I added nouveau using grub editor (pressing "e" )
    I get a non-graphic login, so I uninstalled nvidia drivers
    but now I have a graphic-login but cannot login, plasma5 gives me this error:
    could not start kdeinit5, check your installation
    kde4 doesn't login, gnome doesn't login, icewm login but cannot start yast
    what can I do to have a working leap??

  10. #10

    Default Re: how to switch between nouveau and nvidia driver at boot time

    Quote Originally Posted by pier_andreit View Post
    done, but it doesn't works, no new line in grub,
    You need to run "sudo grub2-mkconfig -o /boot/grub2.cfg" afterwards to recreate the boot menu.

    But the good news is that this will be done automatically when you install kernel updates.

    so I added nouveau using grub editor (pressing "e" )
    I get a non-graphic login, so I uninstalled nvidia drivers
    Why did you uninstall the nvidia driver?

    Just reboot and do *not* add the "nouveau" option.

    Editing the boot menu in place (via pressing 'e') does not permanantly change anything.

    but now I have a graphic-login but cannot login, plasma5 gives me this error:
    could not start kdeinit5, check your installation
    kde4 doesn't login, gnome doesn't login, icewm login but cannot start yast
    what can I do to have a working leap??
    Find out what went wrong.

    As a first step, look at /var/log/Xorg.0.log.

    I would guess that you miss libglx or libGL though.
    Try to reinstall Mesa-libGL1 and run:
    Code:
    sudo update-alternatives --set libglx.so /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so
    to activate Xorg's libglx.

    PS: instead of reinstalling Mesa-libGL1, it should also suffice to run:
    Code:
    sudo ln -sf  /usr/lib64/libGL.so.1.2.0 /usr/lib64/libGL.so.1
    Last edited by wolfi323; 13-Aug-2016 at 15:17.

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •