Manjaro/Arch禁用独显

由于本人笔记本是双显卡的,曾几度尝试安装闭源NVIDIA驱动(为了hashcat),然而每次以失败告终,而系统自带的开源nouveau驱动实在太坑了,系统总是会出现一些莫名其妙的bug,忍无可忍之下干脆禁掉独显,只用核显得了。

bbswitch

首先需要安装bbswitch模块,用于切换显卡

1
2
3
4
5
6
pacman bbswitch

# 加载模块
modprobe bbswitch
# 卸载模块
rmmod bbswitch

禁用独显

首先查看当前系统是否已经禁用独显

1
2
cat /proc/acpi/bbswitch
0000:01:00.0 OFF

OFF说明目前已经禁掉独显了,如果不为OFF,那么需要将其关闭

1
2
3
4
# 关闭独显
tee /proc/acpi/bbswitch <<< OFF
# 打开独显
tee /proc/acpi/bbswitch <<< ON

之后还需要告诉系统:modprobe加载bbswitch时关闭独显(load_state=0),卸载bbswitch时打开独显(unload_state=1)

1
2
nano /etc/modprobe.d/bbswitch.conf
options bbswitch load_state=0 unload_state=1

nouveau列入blacklist

执行tee /proc/acpi/bbswitch <<< OFF后还需要将nouveau列入黑名单,防止它后台运行。
blacklist.conf添加blacklist nouveau禁用nouveau

1
2
nano /etc/modprobe.d/blacklist.conf
blacklist nouveau

在下一次重启lspci就可以看到rev ff表示独显已经关闭了,或者dmesg|grep -i nouveau查看是否含有nouveau的内容

1
01:00.0 3D controller: NVIDIA Corporation GP108BM [GeForce MX250] (rev ff)

rc.local

将以上操作设置一个系统启动服务,这样在每次开机时就能够关闭独显了。基于Archlinux systemd写一个服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
nano /etc/systemd/system/rc-local.service
[Unit]
Description="/etc/rc.local Compatibility"

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardInput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

其中/etc/rc.local就是要执行shell的启动脚步,开机时让modprobe加载bbswitch

1
2
#!/bin/sh
modprobe bbswitch

注意一定要赋予rc.local执行权限 chmod +x /etc/rc.local,最后将服务rc-local设置为开机启动 systemctl enable rc-local.service

重启计算机后systemctl status rc-local.service 查看rc-local服务状态。

1
2
3
4
5
6
7
8
9
10
11
● rc-local.service - "/etc/rc.local Compatibility"
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: disabled)
Active: active (exited) since Fri 2020-02-14 09:55:13 CST; 4h 35min ago
Tasks: 0 (limit: 4915)
Memory: 0B
CGroup: /system.slice/rc-local.service

2月 14 09:55:13 system systemd[1]: Starting "/etc/rc.local Compatibility"...
2月 14 09:55:13 system systemd[1]: Started "/etc/rc.local Compatibility".
2月 14 10:07:31 system systemd[1]: /etc/systemd/system/rc-local.service:10: Support for option SysVStartPriority= has bee>
lines 1-10/10 (END)

参考

Arch下使用bbswitch彻底禁用双显卡笔记本的独立显卡
systemd does not run /etc/rc.local?

Give a rose, leave a handful of fragrance; life is not easy, I use the arch
0%