skip to content
Hiiruki's lab
Table of Contents

Intro

Recently, I’ve installed Arch Linux on my laptop with GNOME as the desktop environment. But I noticed that it was using Xorg as the display server instead of Wayland. So I decided to switch to Wayland with NVIDIA GPU. Here’s how I did it.

My System

Steps

Kernel Mode Setting (KMS)

Configuration

Kernel mode setting (KMS) is a method for setting display resolution and depth in the kernel space rather than user space). It can be used in conjunction with the framebuffer device. KMS also enables newer technologies (such as DRI2) which will help reduce artifacts and increase 3D performance, even kernel space power-saving.

Because I generated the grub config using the grub-mkconfig tool and have the default configuration, I don’t have the vga= or video= neither drivers that make conflicts with native resolution enabled by KMS. So, I’m good to go.

Late KMS start

Intel, Nouveau, ATI and AMDGPU drivers already enable KMS automatically for all chipsets, but the proprietary NVIDIA driver does not. To enable KMS for the NVIDIA driver, we need to manually enabled it.

DRM kernel mode setting

To enable it, set the modeset=1 kernel module parameter for the nvidia_drm module.

Terminal window
$ sudo nano /etc/default/grub

Edit the GRUB_CMDLINE_LINUX_DEFAULT line to include nvidia-drm.modeset=1:

Save the file and regenerate the grub config:

Terminal window
$ sudo grub-mkconfig -o /boot/grub/grub.cfg

in my case the path is /boot/efi so the command will be:

Terminal window
$ sudo grub-mkconfig -o /boot/efi/grub/grub.cfg

Early KMS start (Optional)

KMS is typically initialized after the initramfs stage. However, it is possible to enable KMS already during the initramfs stage. Add the required module for the video driver to the initramfs configuration file:

nvidia nvidia_modeset nvidia_uvm nvidia_drm for the out-of-tree nvidia and nvidia-open drivers.

mkinitcpio

Configure the mkinitcpio to include the NVIDIA modules:

Terminal window
$ sudo nano /etc/mkinitcpio.conf

Add the nvidia nvidia_modeset nvidia_uvm nvidia_drm modules to the MODULES array:

Save and regenerate the initramfs using mkinitcpio, because I’m using the linux-zen kernel, so the command will be:

Terminal window
$ sudo mkinitcpio -p linux-zen

Make sure to replace linux-zen with your kernel name. Like linux, linux-lts, linux-hardened, etc. You can check the kernel name using the uname -r command.

For the full kernel list you can check in Arch Wiki Kernel page.

or you can use the -P flag to regenerate all preset file in /etc/mkinitcpio.d directory:

Terminal window
$ sudo mkinitcpio -P

pacman hook

To ensure that the initramfs is always updated when the NVIDIA driver is updated, create a pacman hook that will regenerate the initramfs automatically.

First, create the hook directory:

Terminal window
$ sudo mkdir -p /etc/pacman.d/hooks

Then create the hook file:

Terminal window
$ sudo nano /etc/pacman.d/hooks/nvidia.hook

Paste the following content:

nvidia.hook
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
# Uncomment the installed NVIDIA package
Target=nvidia
#Target=nvidia-open
#Target=nvidia-lts
# If running a different kernel, modify below to match
Target=linux-zen
[Action]
Description=Updating NVIDIA module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux*) exit 0; esac; done; /usr/bin/mkinitcpio -P'

Make sure to edit the Target line to match your NVIDIA driver package and kernel name. In my case, I’m using the nvidia package and linux-zen kernel.

Install GNOME (If you haven’t)

Terminal window
$ sudo pacman -S gnome

In selection prompt, just press Enter to install all the packages. (default=all)

GDM Configuration

/etc/gdm/custom.conf (Optional)

If you want to use Wayland as the default session, you can edit the /etc/gdm/custom.conf file:

Terminal window
$ sudo nano /etc/gdm/custom.conf

Uncomment the WaylandEnable line and set it to true:

This step is often skipped that will cause the GDM only to use Xorg. To fix this, you need to symlink the GDM rules:

Terminal window
$ sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules

Reboot

After all the steps above, reboot your system:

Terminal window
$ sudo reboot

Check

After rebooting in the login screen, you can check if you’re using Wayland by clicking the gear icon and see if there’s a GNOME on Wayland or just GNOME but the old one is GNOME on Xorg.

You can also check the XDG_SESSION_TYPE environment variable:

Terminal window
$ echo $XDG_SESSION_TYPE

Also you can check the about section in the settings.

Like this:

You can use tools like neofetch, screenfetch or fastfetch to check the NVIDIA GPU.

Terminal window
$ fastfetch

Summary

Now you have successfully enabled Wayland on GNOME with NVIDIA GPU in Arch Linux. You can check the References for more information.

References