使用bbswitch禁用nvidia独显

0.查看显卡状态:

lspci|grep VGA

1.下载bbswitch源代码,编译并安装:

make&&make install

2.加载模块:

modprobe bbswitch

3.(可选)手动设置显卡状态

tee /proc/acpi/bbswitch <<<OFF #关闭独立显卡

tee /proc/acpi/bbswitch <<<ON #开启独立显卡

4. 设置bbswitch模块参数:

echo 'options bbswitch load_state=0'> /etc/modprobe.d/bbswitch.conf

5.开机自加载:

echo 'modprobe bbswitch'>>/etc/rc.local


参考:bbswitch官方文档——

bbswitch is a kernel module which automatically detects the required ACPI callsfor two kinds of Optimus laptops. It has been verified to work with "real"Optimus and "legacy" Optimus laptops (at least, that is how I call them). Themachines on which these tests has performed are:

  • Clevo B7130 - GT 425M ("real" Optimus, Lekensteyns laptop)
  • Dell Vostro 3500 - GT 310M ("legacy" Optimus, Samsagax' laptop)

(note: there is no need to add more supported laptops here as the universalcalls should work for every laptop model supporting either Optimus calls)

It's preferred over manually hacking with the acpi_call module because it candetect the correct handle preceding _DSM and has some built-in safeguards:

  • You're not allowed to disable a card if a driver (nouveau, nvidia) is loaded.
  • Before suspend, the card is automatically enabled. When resuming, it'sdisabled again if that was the case before suspending. Hibernation shouldwork, but it not tested.

Build

Build the module (kernel headers are required):

make

Then load it (requires root privileges, i.e. sudo):

make load

If your card is supported, there should be no error. Otherwise, you get a "Nosuch device" (ENODEV) error. Check your kernel log (dmesg) for moreinformation.

DKMS support

If you have DKMS installed, you can install bbswitch in such a way that itsurvives kernel upgrades. It is recommended to remove older versions of bbswitchby runningdkms remove -m bbswitch -v OLDVERSION --all as root. To installthe new version, simply run:

# make -f Makefile.dkms

To uninstall it, run:

# make -f Makefile.dkms uninstall

Usage

bbswitch has three commands to check the card status and switching (# means "run with root privileges, i.e. run it prefixed withsudo):

Get the status:

# cat /proc/acpi/bbswitch  
0000:01:00.0 ON

Turn the card off, respectively on:

# tee /proc/acpi/bbswitch <<<OFF
# tee /proc/acpi/bbswitch <<<ON

If the card stays on when trying to disable it, you've probably forgotten tounload the driver,

$ dmesg |tail -1
bbswitch: device 0000:01:00.0 is in use by driver 'nouveau', refusing OFF

Do not attempt to load a driver while the card is off or the card won't beusable until the PCI configuration space has been recovered (for example, afterwriting the contents manually or rebooting).

Module options

The module has some options that control the behavior on loading and unloading:load_state andunload_state. Valid values are -1, 0 and 1 meaning "donot change the card state", "turn the card off" and "turn the card on"respectively. For example, if you want to havebbswitch disable the cardimmediately when loading the module while enabling the card on unload, load themodule with:

# modprobe bbswitch load_state=0 unload_state=1

The unload_state value can be changed on runtime, the above command yields thesame behavior as:

# modprobe bbswitch load_state=0
# echo 1 | tee /sys/module/bbswitch/parameters/unload_state

If not explictly set, the default behavior is not to change the power state ofthe discrete video card which equals toload_state=-1 unload_state=-1.

Disable card on boot

These options can be useful to disable the card on boot time. Depending on yourdistribution,/etc/modules, /etc/modules.conf or some other file can be usedto load modules on boot time. Adding the below line to the file makes the cardget disabled on boot:

bbswitch load_state=0

You have to update your initial ramdisk (initrd) for the changes propagate tothe boot process. On Debian and Ubuntu, this can performed by runningupdate-initramfs -u as root.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值