使用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.


你可能感兴趣的:(使用bbswitch禁用nvidia独显)