Lack of knowledge to configure nvidia-prime in Leap 15.2

Hi folks

I’m so sorry. I couldn’t understand this gudie to configure nvidia-prime for my optimus based laptop using nvidia 390.xxx driver. Although installing nvdia-prime and switching between intel and nvidia card is straightforward enough, there are two additional steps to “blacklist nvidia module” and “installing systemd service” that confused me. I searched a lot but didn’t figure out where I should place those scripts and what I must do afterwards. Please someone provide a step by step guide for that two steps.

Sorry for my english and thank you in advance

Open konsole and become the super user by typing in

su

then type in your password then copy and paste the commands on the link you’ve shared. You don’t need to do anything special, just copy and paste

if  ! -s /etc/modprobe.d/09-nvidia-modprobe-bbswitch-G04.conf ]; then  cp 09-nvidia-modprobe-bbswitch-G04.conf /etc/modprobe.d && dracut -f fi

to blacklist nvidia. It is adding “09-nvidia-modprobe-bbswitch-G04.conf” in your /etc/modprobe.d/ and just copy and paste

if  ! -s /usr/lib/systemd/system/prime-select.service ]; then
  cp prime-select.service /usr/lib/systemd/system && \
  systemctl enable prime-select fi

to create and enable prime-select.

Thank you for the reply. So I just need to become root and copy and paste those 2 commands? I don’t need to update initrmfs and install prime-select service for systemd?

Be sure to download everything in your instructions page and run the commands fromt he directory where you downloaded everything. These commands require the scripts.

I can’t repeat it often enough: Plerase use

su -

Do not forget that ‘-’

Not necessarily, in this case: if you opened the terminal in the directory containing the downloaded files, you just want to “become superuser there”, not changing to “root’s home” which is what “su -” does.

Hi
That is not true, sure it changes to root users $HOME, but it also changes the login environment variables to root user, this is how people wind up breaking things since the users $HOME environment is used. Look at the output from env with or without the “-”

That’s correct in general, and thanks for pointing that out. The general rule of logging in as superuser by “su -” and then doing system maintenance is a good habit but…
unless I am mistaken this specific case just involves copying two downloaded config files to their right place and enabling a service so I think “su” does no harm here.

Anyway the best procedure (for any future reader) is:

  • login as superuser
su -
<enter root password>

-change to the directory where you downloaded the config files

cd /home/<username>/Downloads

(or whatever dir containing the files…)

  • issue the copy commands
if  ! -s /etc/modprobe.d/09-nvidia-modprobe-bbswitch-G04.conf ]; then  cp 09-nvidia-modprobe-bbswitch-G04.conf /etc/modprobe.d && dracut -f fi
if  ! -s /usr/lib/systemd/system/prime-select.service ]; then  cp prime-select.service /usr/lib/systemd/system && \
systemctl enable prime-select fi

done.

It does much more.

I do not give this advice (that is more then thirty years old) to those who think they can ignore it bcause they know exactly what it does and thus have calculated that leaving out those two (2!!!) characters in this particular case maybe harmless. Please feel free to carry on with your way of working.

This advice is to all others that follow advice “from the internet” blindless and never check what harm can be done in doing so. And to all that understand that having a good practise, burned in their human system as a habit, will save them from disaster in times of stress.