Skip to main content

Setting up Wayland on Debian 12

·781 words·4 mins
Orlando Gentil
Author
Orlando Gentil
Jack of all trades, master of none
Table of Contents

Setting up Wayland on Debian 12.
#

Checking if Wayland is active
#

echo $WAYLAND_DISPLAY

If it returns something like wayland-0, you are running a Wayland session.

Check driver
#

nvidia-smi

Installing (GNOME already installed with Nvidia proprietary driver)
#

sudo apt install weston wayland-protocols xwayland

Troubleshooting
#

Some versions of the NVIDIA driver have had compatibility issues with Wayland.

1. Ensure the NVIDIA Driver Supports Wayland
#

First, make sure you are using a version of the NVIDIA driver that supports Wayland. As of the latest updates, the proprietary NVIDIA drivers support Wayland, but you need to ensure KMS is enabled.

2. Enable KMS for NVIDIA
#

To enable KMS for the NVIDIA driver, follow these steps:

Edit the Kernel Command Line
#
  1. Open a terminal.

  2. Edit the GRUB configuration file:

    sudo nano /etc/default/grub
    
  3. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT and add nvidia-drm.modeset=1 to it. It should look something like this:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1"
    
  4. Save the file and update GRUB:

    sudo update-grub
    
Create a Configuration File for NVIDIA DRM
#
  1. Create a new configuration file for the NVIDIA DRM module:

    sudo nano /etc/modprobe.d/nvidia-kms.conf
    
  2. Add the following line:

    options nvidia-drm modeset=1
    
  3. Save the file.

3. Rebuild Initramfs
#

Rebuilding the initramfs ensures that the changes take effect at boot.

sudo update-initramfs -u

4. Reboot Your System
#

Reboot your computer to apply the changes:

sudo reboot

5. Select Wayland Session in GDM
#

After rebooting, you should see the option to select a Wayland session in the GDM login screen:

  1. Click on your user account.
  2. Click the gear icon and select “GNOME on Wayland”.
  3. Enter your password and log in.

Troubleshooting
#

If you still don’t see the Wayland option, or if you encounter issues, check the following:

  • Ensure NVIDIA Drivers Are Loaded Properly: Verify that the NVIDIA drivers are loaded correctly and KMS is enabled.

    sudo dmesg | grep -i nvidia
    sudo dmesg | grep -i drm
    
  • Check GDM Configuration: Ensure that GDM is configured to support Wayland. The GDM configuration file should not have WaylandEnable=false.

    sudo nano /etc/gdm3/custom.conf
    

    Ensure the line WaylandEnable=false is commented out or set to true:

    #WaylandEnable=false
    

Nvidia Services
#

The driver install creates the following services:

nvidia-persistenced.service nvidia-powerd.service nvidia-suspend.service

If you encounter issues with these services:

Check Logs: Use journalctl to view logs for more detailed information.

journalctl -u nvidia-persistenced.service
journalctl -u nvidia-powerd.service
journalctl -u nvidia-suspend.service

My system had one missing. I manually created the unit file, user and run directory. Re-installing the driver should fix it too.

Creating unit file
#

vim /etc/systemd/system/nvidia-persistenced.service
[Unit]
Description=NVIDIA Persistence Daemon
Documentation=man:nvidia-persistenced(1)
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/nvidia-persistenced --user nvidia-persistenced
ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced
PIDFile=/var/run/nvidia-persistenced/nvidia-persistenced.pid

[Install]
WantedBy=multi-user.target

Adding the user
#

sudo useradd -r -d /var/run/nvidia-persistenced -s /sbin/nologin -c "NVIDIA Persistence Daemon" nvidia-persistenced

Run directory
#

sudo mkdir -p /var/run/nvidia-persistenced
sudo chown nvidia-persistenced:nvidia-persistenced /var/run/nvidia-persistenced

Reload unit, enable and start
#

sudo systemctl daemon-reload
sudo systemctl enable nvidia-persistenced.service
sudo systemctl start nvidia-persistenced.service

NVreg not set porperly
#

To check if NVreg_PreserveVideoMemoryAllocations is enabled on your NVIDIA driver, you can use several methods. This parameter is used to ensure that video memory allocations are preserved across suspend and resume cycles, which can be particularly important for systems that frequently enter and exit sleep states.

Method 1: Check the Current Parameter Value
#

You can check the current value of NVreg_PreserveVideoMemoryAllocations by looking at the NVIDIA kernel module parameters:

  1. Using modinfo:

    sudo modinfo -p nvidia
    

    This command lists all parameters for the NVIDIA module. Look for NVreg_PreserveVideoMemoryAllocations in the output.

  2. Using cat:

    cat /proc/driver/nvidia/params/NVreg_PreserveVideoMemoryAllocations
    

    If this file exists, it should contain the current value of the parameter.

Method 2: Check the Module Configuration File
#

Check if the parameter is set in the NVIDIA module configuration file:

  1. Open the configuration file:

    sudo nano /etc/modprobe.d/nvidia.conf
    
  2. Look for a line that sets NVreg_PreserveVideoMemoryAllocations:

    options nvidia NVreg_PreserveVideoMemoryAllocations=1
    

Method 3: Using sysfs Interface
#

  1. Check the value using the sysfs interface:

    cat /sys/module/nvidia/parameters/NVreg_PreserveVideoMemoryAllocations
    

    If the parameter is enabled, the file should contain the value 1. If it is not enabled, it may contain 0 or not exist.

Enabling NVreg_PreserveVideoMemoryAllocations
#

If you need to enable NVreg_PreserveVideoMemoryAllocations, follow these steps:

  1. Edit the module configuration:

    sudo vim /etc/modprobe.d/nvidia.conf
    
  2. Add the following line (or modify it if it exists):

    options nvidia NVreg_PreserveVideoMemoryAllocations=1
    
  3. Update the initramfs to ensure the changes take effect on boot:

    sudo update-initramfs -u
    
  4. Reboot your system to apply the changes:

    sudo reboot
    

Verifying the Change
#

After rebooting, verify that the parameter is enabled using one of the methods above, such as checking the sysfs interface or the module parameters.

By following these steps, you can check and enable the NVreg_PreserveVideoMemoryAllocations parameter on your NVIDIA driver, ensuring that video memory allocations are preserved across suspend and resume cycles.