This is a guide as well as more of a reference for myself and friends who need it in the future.
1. Setup modules for initramfs:
sudo nano /etc/mkinitcpio.conf
where it says MODULES= add these like this:
MODULES="nvidia nvidia_modeset"
2. Find your nvidia BusID:
sudo lspci -k | grep -A 2 -E "(VGA|3D)"
Output should be something like:
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
Subsystem: Dell Device 0706
Kernel driver in use: i915
--
02:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960M] (rev a2)
Subsystem: Dell Device 0706
Kernel driver in use: nvidia
Here, our BusID for NVIDIA is 2:0:0.
3. Create xorg config.:
sudo nano /etc/X11/xorg.conf
Section "Module"
Load "modesetting"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:2:0:0"
Option "AllowEmptyInitialConfiguration"
EndSection
4. Create a bash script that makes xrandr output to your integrated display using nvidia.
First install xrandr if you don’t have it:
sudo pacman -S xorg-xrandr
Now create the script to make nvidia output to the modesetting device.
sudo nano /etc/X11/xinit/xinitrc.d/nvidia-script.sh
#!/bin/sh
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
sudo chmod a+x /etc/X11/xinit/xinitrc.d/nvidia-script.sh
5. Set your Display Manager’s autostart to run xrandr on bootup. This will make your NVIDIA card output to your integrated display.
First, find which display manager you’re using:
cat /etc/systemd/system/display-manager.service | grep '/usr/bin'
it should display something like this:
ExecStart=/usr/bin/lightdm
For gdm (Gnome Display manager):
Nothing necessary, GDM will execute scripts in xinitrc.d
For lightdm:
LightDM only executes scripts in xinitrc.d for the session after login. We need to make it execute the script for the login screen as well:
sudo nano /etc/lightdm/lightdm.conf
find
[Seat:*]
and somewhere underneath it should be:
#display-setup-script=
change it to:
display-setup-script=/etc/X11/xinit/xinitrc.d/nvidia-script.sh
Make sure you remove the # sign.
6. Install the nvidia drivers,=
sudo pacman -S nvidia-dkms nvidia-utils lib32-nvidia-utils opencl-nvidia lib32-opencl-nvidia nvidia-settings
we use nvidia-dkms so that it is interchangeable with different kernels.
7. Create a pacman hook so that you do not have to run mkinitcpio after every kernel update:
/etc/pacman.d/hooks/nvidia.hook
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia-dkms
[Action]
Depends=mkinitcpio
When=PostTransaction
Exec=/usr/bin/mkinitcpio -P
REBOOT!
NOTES REGARDING DRM AND TEARING:
To get rid of tearing, you need to enable nvidia-drm. This periodically breaks, just be warned. If you do an update and get a black screen, you’ll want a usb stick with arch on it so you can edit these files in case drm breaks. To enable drm:
sudo nano /boot/loader/entries/arch.conf
at the end of your options line, add:
nvidia-drm.modeset=1
save, close. then:
sudo nano /etc/mkinitcpio.conf
add nvidia_drm and nvidia_uvm to modules. it should look like this:
MODULES="nvidia nvidia_modeset nvidia_drm nvidia_uvm"
Again, this sometimes breaks during driver updates. if it does, just remember to remove them from /boot/loader/entries/arch.conf and /etc/mkinitcpio.conf
TROUBLESHOOTING:
-If you’re not sure the nvidia drivers installed, type modprobe nvidia in terminal. If you get no errors, they are installed.
-If at any time you get a blank black screen, ctrl+alt+f4 will drop you to tty terminal so that you can edit things you may have missed or done improperly.
-If at any time you get a looping screen (such as lightdm trying to load a misspelled script), boot from an Arch USB stick, then mount your root partition and arch-chroot into it, proceed to re-apply the steps above.
-If you are able to drop to tty/command screen, you can test your nvidia-script via startx. You can test your lightdm/gdm with sudo systemctl restart gdm/lightdm.
sudo pacman -S xrandr
gives error: target not found
the packge name is xorg-xrandr
but when i type
sudo xrandr –listproviders
it only gives
No protocol specified
Can’t open display :0
any idea why ?
its –listproviders
two —
also – you need to be in an X session to run xrandr. if you dont get any errors with modprobe nvidia the default NVIDIA-0 should work fine without having to use listproviders
updated, sorry, used the wrong editor and it messed up the formatting
updated, sorry, used the wrong editor and it messed up the formatting
cat /etc/systemd/system/display-manager.service | grep ‘/usr/bin’
It shows some error telling that the file does not exist
[drm:wait_panel_status [i915]] *ERROR* PPS state mismatch
what is problem ? what should I do ?
i am using bumblebee .
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev06)
Subsystem: ASUSTeK Computer Inc. 4th Gen Core Processor Integrated Graphics Controller
Kernel driver in use: i915
—
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 850M] (rev a2)
Subsystem: ASUSTeK Computer Inc. GM107M [GeForce GTX 850M]
Kernel driver in use: nvidia
follow my guide step by step, and don’t use bumblebee. uninstall bumblebee. gpu switching does not work properly in linux except with ubuntu.
i did . but I’m getting the same error again. uninstall bumblebee and install nvidia
and $ groups : wheel bumblebee storage power users
how delete bumblebee in groups ?
Hi, GloriousEggroll . I install nvidia prime . Should I install the xf86-video-Intel package?
Hi, for some reason when I try the commands you put in the .sh file I get “Could not find provider with name modesetting” and any game I try (now that I uninstalled Bumblebee and Primus) they run with the Intel GPU (I know because of the performance I get with Xcom2 which I use for testing this, with bumblebee and using primusrun it actually runs with the NVIDIA GPU) also as a side note, Nvidia X server settings won’t run for some reason
Hi, I did exactly as you said in this guide, but whenever I open a game, like XCom2 the GPU being used is the Intel one (I know because of the performance, when I ran it with primusrun it ran ways better), so I know it didn’t work, also, whenever I run the command `xrandr –setprovideroutputsource modesetting NVIDIA-0` present in the .sh file, I get:
~~~
Could not find provider with name modesetting
~~~~
Also the Nvidia x server settings don’t run and the command `nvidia-settings` sends:
~~~
ERROR: Unable to find display on any available system
~~~~