您尚未登录。

#1 2024-05-22 22:20:46

lyao
会员
注册时间: 2024-05-22
帖子: 1

[分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

刚从 win 转 arch,这两天搞 nvidia 的桌面环境给我整麻了,一直黑屏没法操作。其实我装过成功过一次,但网上的各种配置说一道二的,很杂乱,根本记不住哪些设置了,哪些没设置,搞得第二次安装的时候心里也没啥谱。
结果居然是偶然在 bing 上找到的答案,google 上相同的关键字反而没有那文章,还是不能小瞧你啊,bing。

首先安装自己的显卡驱动(这个网上大部分都没啥问题)。

然后根据参考链接中的内容设置自己的配置。

希望能帮助到一部分不知道如何设置的新手朋友。

离线

#2 2024-06-24 11:42:45

barrydc
会员
注册时间: 2024-06-23
帖子: 1

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

感谢楼主的分享,我总结后编写了一键配置脚本,方便以后的朋友使用:

#!/bin/bash

# 定义要写入 /etc/environment 的变量
nvidia_variables=(
    "GBM_BACKEND=nvidia-drm"
    "__GLX_VENDOR_LIBRARY_NAME=nvidia"
    "ENABLE_VKBASALT=1"
    "LIBVA_DRIVER_NAME=nvidia"
)

backup_file() {
    local file=$1
    sudo cp "$file" "$file.bak"
}

update_environment() {
    local env_file="/etc/environment"
    backup_file "$env_file"

    for var in "${nvidia_variables[@]}"; do
        if grep -q "^${var%%=*}" "$env_file"; then
            sudo sed -i "s|^${var%%=*}.*|$var|" "$env_file"
        else
            echo "$var" | sudo tee -a "$env_file" > /dev/null
        fi
    done

    echo "NVIDIA-specific options have been written to $env_file."
}

update_mkinitcpio_conf() {
    local mkinitcpio_conf="/etc/mkinitcpio.conf"
    backup_file "$mkinitcpio_conf"

    sudo sed -i '/^MODULES=/ s/(\(.*\))/(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' "$mkinitcpio_conf"
    sudo sed -i '/^HOOKS=/ s/\(\s*kms\s*\)//g' "$mkinitcpio_conf"

    echo "mkinitcpio.conf has been updated."
}

create_nvidia_conf() {
    local nvidia_conf="/etc/modprobe.d/nvidia.conf"
    sudo bash -c "cat > $nvidia_conf" <<EOL
blacklist nouveau
options nvidia_drm modeset=1 fbdev=1
EOL

    echo "$nvidia_conf has been created."
}

regenerate_initramfs() {
    sudo mkinitcpio -P
    echo "initramfs has been regenerated."
}

create_nvidia_hook() {
    local hook_dir="/etc/pacman.d/hooks"
    local hook_file="$hook_dir/nvidia.hook"

    sudo mkdir -p "$hook_dir"

    sudo bash -c "cat > $hook_file" <<EOL
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Adjust line(6) above to match your driver, e.g. Target=nvidia-470xx-dkms
# Change line(7) above, if you are not using the regular kernel For example, Target=linux-lts

[Action]
Description=Update 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'
EOL

    echo "nvidia.hook has been added to $hook_dir."
}

main() {
    update_environment
    update_mkinitcpio_conf
    create_nvidia_conf
    regenerate_initramfs
    create_nvidia_hook
}

main

如果有兴趣,在我写的Arch 下 Walyland 使用 Nvidia 私有驱动有详细的手动步骤与参考

离线

#3 2024-06-30 18:46:33

yuanj82
会员
注册时间: 2024-02-26
帖子: 21

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

请问Chrome动画什么的有无问题?我之前配置的一直不对,其他环境都很好,唯独plasma,Chrome放大缩小一直要卡死

barrydc 说:

感谢楼主的分享,我总结后编写了一键配置脚本,方便以后的朋友使用:

#!/bin/bash

# 定义要写入 /etc/environment 的变量
nvidia_variables=(
    "GBM_BACKEND=nvidia-drm"
    "__GLX_VENDOR_LIBRARY_NAME=nvidia"
    "ENABLE_VKBASALT=1"
    "LIBVA_DRIVER_NAME=nvidia"
)

backup_file() {
    local file=$1
    sudo cp "$file" "$file.bak"
}

update_environment() {
    local env_file="/etc/environment"
    backup_file "$env_file"

    for var in "${nvidia_variables[@]}"; do
        if grep -q "^${var%%=*}" "$env_file"; then
            sudo sed -i "s|^${var%%=*}.*|$var|" "$env_file"
        else
            echo "$var" | sudo tee -a "$env_file" > /dev/null
        fi
    done

    echo "NVIDIA-specific options have been written to $env_file."
}

update_mkinitcpio_conf() {
    local mkinitcpio_conf="/etc/mkinitcpio.conf"
    backup_file "$mkinitcpio_conf"

    sudo sed -i '/^MODULES=/ s/(\(.*\))/(\1 nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' "$mkinitcpio_conf"
    sudo sed -i '/^HOOKS=/ s/\(\s*kms\s*\)//g' "$mkinitcpio_conf"

    echo "mkinitcpio.conf has been updated."
}

create_nvidia_conf() {
    local nvidia_conf="/etc/modprobe.d/nvidia.conf"
    sudo bash -c "cat > $nvidia_conf" <<EOL
blacklist nouveau
options nvidia_drm modeset=1 fbdev=1
EOL

    echo "$nvidia_conf has been created."
}

regenerate_initramfs() {
    sudo mkinitcpio -P
    echo "initramfs has been regenerated."
}

create_nvidia_hook() {
    local hook_dir="/etc/pacman.d/hooks"
    local hook_file="$hook_dir/nvidia.hook"

    sudo mkdir -p "$hook_dir"

    sudo bash -c "cat > $hook_file" <<EOL
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Adjust line(6) above to match your driver, e.g. Target=nvidia-470xx-dkms
# Change line(7) above, if you are not using the regular kernel For example, Target=linux-lts

[Action]
Description=Update 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'
EOL

    echo "nvidia.hook has been added to $hook_dir."
}

main() {
    update_environment
    update_mkinitcpio_conf
    create_nvidia_conf
    regenerate_initramfs
    create_nvidia_hook
}

main

如果有兴趣,在我写的Arch 下 Walyland 使用 Nvidia 私有驱动有详细的手动步骤与参考


Never stop

离线

#4 2024-07-01 06:35:48

弯弓射小白
会员
注册时间: 2022-10-04
帖子: 122

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

intel+nvidia的混合显卡怎么搞?


风吹又日晒,自由又自在

离线

#5 2024-07-01 12:28:09

anlorsp
会员
注册时间: 2021-11-28
帖子: 46

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

弯弓射小白 说:

intel+nvidia的混合显卡怎么搞?

intel+nvidia混合显卡如果采用nvidia-prime方案(日常使用intel显卡,手动调用nvidia显卡),那么不需要什么额外配置,根据archwiki正常安装驱动即可。因为包括桌面环境在内的大多数渲染工作都由intel显卡负责。

离线

#6 2024-07-11 23:59:27

弯弓射小白
会员
注册时间: 2022-10-04
帖子: 122

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

firefox怎么调用nvidia显卡?


风吹又日晒,自由又自在

离线

#7 2024-07-12 01:19:52

anlorsp
会员
注册时间: 2021-11-28
帖子: 46

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

弯弓射小白 说:

firefox怎么调用nvidia显卡?

理论上可以通过prime-run firefox实现。
然而firefox似乎有bug,我看到不少报告称firefox无法在nvidia-prime下调用nvidia独显。如果prime-run firefox无效,那你可能必须放弃PRIME,将nvidia作为主显卡。

离线

#8 2024-07-13 21:36:20

giteeajake
a noob
所在地: Hebei
注册时间: 2024-06-11
帖子: 62
个人网站

Re: [分享帖]arch linux + kde plasma6 + wayland + sddm 安装 nvidia 内核驱动相关内容

There has a thing.
My friend sees a thing about Hyprland.
at config of Hyprland.
if write env=__GLX_VENDOR_LIBRARY_NAME,nvidia
then you can't load your Hyprland Desktop


i am a noob

离线

页脚