Nvidia-ArchLinux-Wayland安装教程
As you know, the transition to Wayland from the traditional Xorg server in the Linux ecosystem has been a hot topic that caused much controversy and, admittedly, a fair share of troubleshooting.
While Wayland promises a more streamlined and secure interface than its predecessor, Xorg, users have often encountered hurdles, particularly regarding compatibility with NVIDIA graphics cards.
In other words, the journey hasn’t always been without bumps, from rendering issues to compatibility quirks. However, it’s becoming increasingly clear that the NVIDIA and Wayland combo, while not yet a perfect match, is evolving into a viable, working solution for many.
Still, with the proper guidance and a bit of patience, using NVIDIA with Wayland on Arch is not just a possibility but a largely workable solution. You can approach this transition with confidence.
This guide is designed to do precisely this: usher you through the setup process and offer solutions to ensure you can take most of your NVIDIA and Wayland experience on Arch Linux. So, let’s get started.
1、Install NVIDIA Driver
1 | sudo pacman -S nvidia nvidia-settings |
2、Set Environment Variables
With NVIDIA’s introduction of GBM (Generic Buffer Management) support, a crucial component of the Linux graphics stack that provides an API for allocating buffers for graphics rendering and display, many compositors have adopted it as their default. So, to force GBM as a backend, we need to set some environment variables.
Open the “/etc/environment” file, paste the following two lines, then save the file and exit.
1 | GBM_BACKEND=nvidia-drm |
3、Loading the NVIDIA Modules at System Boot
To ensure that the NVIDIA modules are loaded at the earliest possible stage, i.e., on the system boot, we need to add the ‘nvidia,’ ‘nvidia_modeset,’ ‘nvidia_uvm,’ and ‘nvidia_drm‘ modules to the initramfs – a temporary root file system loaded into memory as part of the boot process before the real root file system is mounted.
This is possible by entering them in the “MODULES” section of the “/etc/mkinitcpio.conf” file. This is a configuration file for mkinitcpio, a tool Arch uses to generate initial ramdisk images.
So, open the “/etc/mkinitcpio.conf” file. Then, enter the modules mentioned above, as the final version should look like this:
1 | MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) |
Great, but we’re not done with this file yet. Scroll down and remove the “kms” from the “HOOKS” section. This ensures that the initramfs will avoid including the open-source “nouveau” driver to mess with the work of the proprietary NVIDIA one we have installed and rely on.
We’ve finished modifying “/etc/mkinitcpio.conf“. Save your changes and close the file. Next, we’ll proceed to regenerate the initramfs. To do this, execute the following command:
1 | sudo mkinitcpio -P |
In the command’s output, you might notice messages like “WARNING: Possibly missing firmware for module…” These shouldn’t cause concern and are unrelated to the modifications we are currently implementing.
4、Enable DRM
DRM (Direct Rendering Manager) is a subsystem of the Linux kernel responsible for interfacing with GPUs. It provides a framework for graphics drivers to enable direct access to the graphics hardware, which is crucial for performance in rendering tasks, 3D graphics, video playback, and more.
NVIDIA provides proprietary graphics drivers for Linux that use the DRM subsystem to interact with their GPUs. These drivers are essential for getting the best performance and feature support on NVIDIA hardware under Linux.
Enabling the DRM kernel mode setting is required for Wayland compositors to function properly. So, we will pass it as a parameter to the Linux kernel during its initial boot through the GRUB bootloader.
Open its configuration file/etc/default/grub
. Locate the
line that begins with “GRUB_CMDLINE_LINUX_DEFAULT” and append
“nvidia-drm.modeset=1” to its end. The completed line should
resemble the example provided below.
Finally, regenerate the GRUB configuration by running:
1 | sudo grub-mkconfig -o /boot/grub/grub.cfg |
5、Testing Wayland with NVIDIA on Arch Linux
You are all set up. Now, reboot your Arch system. At the login screen of the display manager you’re using, choose the Wayland Session option.
Log in and enjoy a seamless Wayland experience with NVIDIA and your beloved Arch Linux.
In addition, to verify that the NVIDIA DRM settings were correctly applied after a reboot, execute the following command; in response, you should get “Y.”
1 | sudo cat /sys/module/nvidia_drm/parameters/modeset |
6、设置 nvidia 电源管理
Create a file
/etc/modprobe.d/nvidia-power-management.conf
with the following content:1
options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp
sudo update-initramfs -c -k all
to re-generate the kernels. 此处我没有执行成功命令,但是并没有影响,系统正常配置成功。Reboot
Go to suspend mode.
Get an error when trying to load a saved state.
7、配置wayland
经过上述配置后,我发现重启系统将会默认进入到x11
,
它是可以正常工作的,效果良好。但是,既然有强大的独立nvidia
显卡,我们还是需要设置好nvidia
.
下述根据 Wayland
and the proprietary NVIDIA driver主操作,详细信息可以参考。
启用
nvidia
相关服务此项参考:Preserve video memory after suspend1
sudo systemctl enable nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service
强制启用
Wayland
, As of GDM 42 and NVIDIA driver 510, GDM defaults to Wayland. For older NVIDIA drivers (in between version 470 and 510), GDM has chipset-dependent udev rules to use Xorg rather than Wayland. To force-enable Wayland, override these rules by creating the following symlink:1
sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
注意:如果没有第6
到7
步,在GNOME
桌面环境启动后,GDM
不能显示wayland
启动选项,而只是默认启动Xorg
,
设置好6
和7
后,系统正常进入到wayland
。
8、Bottom Line
In the end, it’s essential to clarify a key point. Our guide has confidently demonstrated that Wayland can operate smoothly with NVIDIA on an Arch system. This, however, does not extend to guaranteeing that every application, game, or desktop environment will also function flawlessly.
The compatibility of these components with Wayland varies and is dependent on the extent to which they have integrated support for it.
For example, desktop environments like KDE Plasma and GNOME offer very good support for Wayland, ensuring a seamless experience. On the other hand, environments like Cinnamon, with only basic Wayland support, may not deliver the same smoothness. So, it’s important to consider these differences.
Similarly, using the Hyprland dynamic tiling Wayland compositor would result in a smooth user experience, whereas others that are still dependent on Xorg may not offer the necessary support for Wayland. This variability in compatibility applies to individual applications too, so it’s important to be aware of potential issues when using specific software.
In conclusion, navigating the complexities of setting up Wayland on Arch can seem daunting, especially for those wielding the power of NVIDIA GPUs, who have historically faced hurdles ranging from rendering glitches to compatibility concerns.
Yet, with the proper knowledge, a dash of perseverance, and our guidance, the hurdles that once seemed impossible begin to shrink to the level that, with the correct setup, NVIDIA and Wayland can indeed create a synergy that brings out the best in your Arch setup.
Finally, we recommend referring to the specific Wayland and NVIDIA sections on the official Arch wiki for a more comprehensive understanding. They provide detailed information on setting up and troubleshooting Wayland and NVIDIA on Arch, making them valuable resources for further exploration.
And, of course, we’d love to hear your feedback or thoughts, so please don’t hesitate to share them in the comment box below.