Debian 13 安装Nvidia驱动并启用wayland

1. 添加官方源

编辑源配置文件:

sudo vi /etc/apt/sources.list.d/debian.sources

添加以下内容:

Types: deb

URIs: https://deb.debian.org/debian

Suites: trixie

Components: main contrib non-free non-free-firmware

Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb

URIs: https://security.debian.org/debian-security

Suites: trixie-security

Components: main contrib non-free non-free-firmware

Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb

URIs: https://deb.debian.org/debian

Suites: trixie-updates

Components: main contrib non-free non-free-firmware

Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

更新系统:

sudo apt update -y && sudo apt full-upgrade -y

2. 安装依赖

sudo apt -y install linux-headers-$(uname -r) build-essential libglvnd-dev pkg-config

3. 安装 NVIDIA 驱动

sudo apt install nvidia-kernel-dkms nvidia-driver firmware-misc-nonfree

安装完成后重启系统。

4. 启用 Kernel Modesetting

echo 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX nvidia-drm.modeset=1 nvidia-drm.fbdev=1"' > /etc/default/grub.d/nvidia-modeset.cfg

sudo update-grub

5. 安装 nvidia-suspend-common

sudo apt install nvidia-suspend-common

启用相关服务:

sudo systemctl enable nvidia-suspend.service

sudo systemctl enable nvidia-hibernate.service

sudo systemctl enable nvidia-resume.service

6. 查看 PreserveVideoMemoryAllocations

cat /proc/driver/nvidia/params | grep PreserveVideoMemoryAllocations

# 输出应为:

# PreserveVideoMemoryAllocations: 1

如果值为 0,执行以下命令修改:

echo 'options nvidia NVreg_PreserveVideoMemoryAllocations=1' | sudo tee /etc/modprobe.d/nvidia-power-management.conf

7. 重启并启用 Wayland

重启后,在登录选项中选择 Wayland 会话。