您的位置:首页 > 其它

ubuntu下关闭nvidia显卡及保存屏幕亮度

2013-05-18 21:25 337 查看
由于各种原因(ps:why linux is not for desktop),linux对市场上新出的独显支持不够全面,也不够稳定。最近花了很多时间来减少ubuntu下电池使用功率,因为dell N4110是双显卡,默认全功率运行,独显很少用到,另一方面,屏幕亮度重启后总是最亮,调节很是不便。下面的方法意在用最少的代码量达到节能效果。

Requirements:ubuntu linux;nvidia显卡,;高级电源管理acpi进程开启,有/proc/sys/acpi/call 文件 本人的dell N4110是ASUS A42JV,ubuntu 12.04 内核 3.2.0-10-generic ,下面的代码亲测通过:

一.关闭独显1. git下载acpi_call模块,关闭n卡

sudo aptitude install git
mkdir ~/.optimus
cd ~/.optimus/
git clone http://github.com/mkottman/acpi_call.git
3. 下面,进入acpi_call目录,进行编译

cd acpi_call/  && make
4. 现在,将模块放入内核的acpi文件夹

sudo insmod ./acpi_call.ko
6. 复制模块并运行depmod

sudo cp acpi_call.ko /lib/modules/$(uname -r)*/kernel/drivers/acpi/
sudo depmod
7. 编辑/etc/modules,使模块在内核启动时加载,插入 acpi_call(独立成行)

echo 'acpi_call' >> /etc/modules
***********************************************************************************************ASUS U36Jc的电脑请略去横线中的步骤************************在上文创建的 acpi_call/example 目录下,执行

ubuntu@dell N4110:~/.optimus/acpi_call$ sudo sh test_off.sh
+- +-- 10 lines:#{Trying _SB.PCI0.P0P3.PEGP._OFF: failedTrying _SB.PCI0.P0P2.PEGP._OFF: failedTrying _SB.PCI0.P0P1.PEGP._OFF: failedTrying _SB.PCI0.MXR0.MXM0._OFF: failedTrying _SB.PCI0.PEG1.GFX0._OFF: failedTrying _SB.PCI0.PEG0.GFX0.DOFF: failedTrying _SB.PCI0.PEG1.GFX0.DOFF: failedTrying _SB.PCI0.PEG0.PEGP._OFF: works!#}
机器若跑出以上结果,可以使用‘_SB.PCI0.PEG0.PEGP._OFF’关闭,这一点将在步骤8中使用。请特别注意。其他结果请自行参照。)****************************************************************************8. 新建一个服务,使我们可以开启/关闭n卡

cat /etc/init.d/optimusoff
+- +-- 43 lines:#{#! /bin/sh### BEGIN INIT INFO# Provides:       optimusoff# Required-Start:    $local_fs $syslog# Required-Stop:    $local_fs $syslog# Default-Start:    2 3 4 5# Default-Stop:    0 1 6# Short-Description:    Disables/Enables the NVidia graphics card#         within the NVidia Optimus system#         #         Modified for the U36Jc and Ubuntu 11.04#         using details from#         #         http://robbyx.net/blog/?p=190### END INIT INFO. /lib/lsb/init-functionsset-ecase"$1"in    start)#echo'_SB.PCI0.PEG0.PEGP._OFF'> /proc/acpi/call# -- 上一行要更改为上文中 works的命令,如 非上文举例的命令请自行修改;;    stop)echo'_SB.PCI0.PEG0.PEGP._ON'> /proc/acpi/call# --同上 ;;    *)echo'_SB.PCI0.PEG0.PEGP._OFF'> /proc/acpi/call# --同上 N=/etc/init.d/optimusoffecho"Usage: $N {startstop}nBy default, 'start' is executed.n">&2exit1;;esacexit0#}
9. 激活服务

sudo update-rc.d optimusoff defaults 9802#default runlevel 2sudo chmod a+x /etc/init.d/optimusoff
sudo service optimusoff start
sudo update-initramfs -u
13. 将显卡驱动模块加入黑名单

echo'blacklist nouveau'>>  /etc/modprobe.d/blacklist-nvidia.conf
echo'blacklist nvidia'>>  /etc/modprobe.d/blacklist-nvidia.conf
二,保存屏幕亮度如果你的电脑在终端下可以通过:

echo VALUE > /sys/class/backlight/.../brightness
***其中 VALUE 是屏幕亮度值, ...是文件brightness的相对路径,如本人 的是:***echo 220 > /sys/class/backlight/intel_backlight/brightness***读者可以测试 VALUE值,知道调节到舒适而节能的效果。那么您可以把确认好的上述代码,如:echo 220 > /sys/class/backlight/intel_backlight/brightness 插入 /etc/rc.local中,并且去掉最后一行#exit 0 中的 #

cat /etc/rc.local
+- +-- 16 lines:#{#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.echo 220 > /sys/class/backlight/intel_backlight/brightnessexit0#}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: