双显卡笔记本linux下关闭其一来省电

昨日果断入手了 lenovo Y470p i5 AMD显卡版,装上了linux deepin

由于有集成显卡和独立显卡,而默认情况下linux根据bios设置来使用其中一块显卡而两块却同时供电,造成极大的耗电,也造成了散热不好,网上早已经有解决方案了。

其中需要注意的是ubuntu下root密码为空,需要执行su命令时请输入sudo su即可进入root用户

新建文件

/etc/initramfs-tools/scripts/local-top/hybrid_boot_options

代码

#
# Standard initramfs preamble
#
prereqs()
{
:
}

case $1 in
prereqs)
        prereqs
        exit 0
        ;;
esac

# source for log_*_msg() functions, see LP: #272301
. /scripts/functions

#
# Helper functions
#
message()
{
        if [ -x /bin/plymouth ] && plymouth --ping; then
                plymouth message --text="$@"
        elif [ -p /dev/.initramfs/usplash_outfifo ] && [ -x /sbin/usplash_write ]; then
                usplash_write "TEXT-URGENT $@"
        else
                echo "$@" >&2
        fi
        return 0
}

run_switcheroo()
{
        local hybridopts
        hybridopts="$1"

        if [ -z "$hybridopts" ]; then
                return 1
        fi

        local IFS=" ,"
        for x in $hybridopts; do
                message "Switching hybrid graphics to $x"
                echo $x > /sys/kernel/debug/vgaswitcheroo/switch
        done
        return 0
}

#
# Begin real processing
#

# Do we have any kernel boot arguments?
for opt in $(cat /proc/cmdline); do
        case $opt in
        hybridopts=*)
                run_switcheroo "${opt#hybridopts=}"
                ;;
        esac
done

exit 0

设置权限,更新

chmod +x /etc/initramfs-tools/scripts/local-top/hybrid_boot_options
initramfs-tools -c -k all

如果系统没有initramfs-tools命令则使用

update-initramfs -c -k all

修改/etc/default/grub,我是查找GRUB_CMDLINE_LINUX_DEFAULT并替换这一行的

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash modeset=1 hybridopts=ON,IGD,OFF"

保存后

update-grub

重启看看有没有问题

参考网址:
http://linuxtoy.org/archives/how-to-use-vga-switcheroo-disable-video-card-linux-kms.html
https://help.ubuntu.com/community/HybridGraphics#Script_for_use_during_bootup

One thought on “双显卡笔记本linux下关闭其一来省电”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.