Arch Linux NVIDIA Prime laptop guide 2017 (using nvidia package with fairly new laptops.)

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_drm nvidia_modeset nvidia_uvm"

2. Add nvidia-drm.modeset=1 to your kernel boot loader entry.
For systemd-boot:
sudo nano /boot/loader/entries/arch.conf
add this to the options line:
It should look something like this:
options root=PARTUUID=a3abb4c8-a931-45ac-ac4b-54199b4449e6 rw nvidia-drm.modeset=1

sudo nano /etc/default/grub
and add your kernel options to the GRUB_CMDLINE_LINUX_DEFAULT line:
And then automatically re-generate the grub.cfg file with:
sudo grub-mkconfig -o /boot/grub/grub.cfg

3. 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.

4. Create xorg config.:
sudo nano /etc/X11/xorg.conf

Section "Module"
        Load "modesetting"

Section "Device"
        Identifier "nvidia"
        Driver "nvidia"
        BusID "PCI:2:0:0"
        Option "AllowEmptyInitialConfiguration"

5. 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/

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

sudo chmod a+x /etc/X11/xinit/xinitrc.d/

6. 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:


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
and somewhere underneath it should be:
change it to:


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.


-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.


  1. 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 ?

    1. 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

Leave a Reply

Your email address will not be published. Required fields are marked *