警告:在 Linux OS 中,如果无法设置笔记本电脑的充放电阈值(没有电池充放电阈值管理驱动,或者驱动的这部分功能无效),而且笔记本电池又不可拆卸,那么,在笔记本电脑上安装 Linux OS,可能会损坏电池、或与电池有关的电路。参考:可能并不是什么样的笔记本电脑,都适合安装 Linux OS 操作系统 (*****)https://blog.csdn.net/ken2232/article/details/139660599
密切关联:
Linux OS:Lenovo 笔记本电池,充放电阈值的两种表现 https://mp.csdn.net/mp_blog/creation/success/137823416
特别注意:当笔记本电脑使用 Linux OS 时,首先需要解决电池充放电的阈值设置问题。否则,可能会对电池的寿命,造成很大的损害 。
------
TLP 只适用:Lenovo ThinkPad 吗?
好像?: debian 11 kernel 5.10.x debian 12 kernel 6.10.x
*** 笔记本电脑电池无法充电_我可以控制笔记本电脑的充电周期以延长电池寿命吗? 于 2020-09-08 https://blog.csdn.net/culun797375/article/details/108841028
根据笔记本电脑的品牌,可能会提供不同的工具。 例如,如果您有Lenovo ThinkPad,则可以使用tlp轻松管理此过程。
linux charg修改目录,Thinkpad在linux(ubuntu)下修改电池充电阈值,成功解决Thinkpad在Linux 于 2021-05-04 https://blog.csdn.net/weixin_42611177/article/details/116738212
图形配置界面: TLPUI
sudo apt install tlpui
------
实例 1 :
sudo apt install tlp tlp-rdw
默认安装之后,文件与目录列表,未作任何的修改
安装 app之后,原始默认值,未作任何的修改
- charge_control_end_threshold :100
- charge_control_start_threshold :0
- charge_start_threshold :0
- charge_stop_threshold :100
特别注意:
这意味着 ?: 如果使用默认参数,那么,笔记本的电池寿命,很快就要完蛋了。
经验教训:其中一台笔记本的电池寿命,应该就是这样导致的吧?
自己在没有还解决电池充放电的阈值之前,如果是不可拆卸电池的笔记本,还是不要使用 Linux OS 吧 ?
- 大品牌笔记本电脑,大概率能够设置电池充放电的阈值。
- 国外有专门匹配好 Linux 设备驱动的笔记本电脑销售。
注意:好像,
1. tlp 不是万能的
在 Tlp 不支持的充电阈值电脑, 则不会出现 charge_start_threshold,charge_stop_threshold 等文件。
但这也可能是 Linux 发行版的原因,可能吗?
tlp 的版本太旧 ?
2. 在虚拟机上安装,不会出现 “/sys/class/power_supply/BAT0/” 中的 BAT0 目录。
3. gnome 有一个电池充电扩展 app,可以支持许多品牌的电脑。
4. 在目录 “/sys/class/power_supply/BAT0/” 下,即使是 root 用户,也无法修改、新建文件,或文件夹?
.
修改参数
/etc/tlp.conf
# Set to 0 to disable, 1 to enable TLP.
# Default: 1TLP_ENABLE=1
# BAT0: Primary / Main / Internal battery (values in %)
# Note: also use for batteries BATC, BATT and CMB0
# Default: <none>START_CHARGE_THRESH_BAT0=75
STOP_CHARGE_THRESH_BAT0=80
一种方法:通过系统自带 gui,获得电磁的编号。
启动与测试
c@at5:~$ systemctl enable tlp.service
Synchronizing state of tlp.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable tlp
Created symlink /etc/systemd/system/multi-user.target.wants/tlp.service → /lib/systemd/system/tlp.service.
c@at5:~$ sudo tlp-stat -b
--- TLP 1.5.0 --------------------------------------------+++ Battery Care
Plugin: thinkpad
Supported features: charge thresholds, recalibration
Driver usage:
* natacpi (thinkpad_acpi) = active (charge thresholds, recalibration)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1: 0(off)..96(default)..99
* STOP_CHARGE_THRESH_BAT0/1: 1..100(default)+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer = SANYO
/sys/class/power_supply/BAT0/model_name = 45N1173
/sys/class/power_supply/BAT0/cycle_count = 0 (or not supported)
/sys/class/power_supply/BAT0/energy_full_design = 93960 [mWh]
/sys/class/power_supply/BAT0/energy_full = 22760 [mWh]
/sys/class/power_supply/BAT0/energy_now = 17290 [mWh]
/sys/class/power_supply/BAT0/power_now = 9734 [mW]
/sys/class/power_supply/BAT0/status = Charging.
/sys/class/power_supply/BAT0/charge_control_start_threshold = 75 [%] << systemctl enable tlp.service 启动成功后,才生效。
/sys/class/power_supply/BAT0/charge_control_end_threshold = 80 [%] << systemctl enable tlp.service 启动成功后,才生效。.
/sys/class/power_supply/BAT0/charge_behaviour = [auto] inhibit-charge force-dischargeCharge = 76.0 [%]
Capacity
------
***** Battery Health Charging https://extensions.gnome.org/extension/5724/battery-health-charging/
https://askubuntu.com/questions/34452/how-can-i-limit-battery-charging-to-80-capacity
------
*** How can I limit battery charging to 80% capacity?
https://unix.stackexchange.com/questions/48534/how-to-adjust-charging-thresholds-of-laptop-battery
I have a Asus laptop and the approach which I have found from internet is as follows. This approach may already be a part of some of the apps mentioned above but putting it here for information.
- Create a service file named
battery_charge_threshold.service
like this.[Unit] Description=Set the battery charge threshold After=multi-user.target [Service] Type=oneshot ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold' [Install] WantedBy=multi-user.target
- Move the file to this location
/etc/systemd/system
- Run the following commands.
sudo chmod 644 /etc/systemd/system/battery-charge-threshold.service sudo systemctl daemon-reload sudo systemctl enable battery-charge-threshold.service
After doing this, charge threshold of 80% (as per service file) will persist between reboots. It will also stop charging the battery if the current level is above 80%. Hope this helps. I have been using it for almost 1.5 years without any issue.
Follow
------
Disclaimer
https://github.com/tshakalekholoane/bat/tree/bd7a4d574d94a43e2303a09af1c626f004c5d955
与硬件的关系太密切,难以实现驱动的通用化??
This has been reported to only work with some ASUS and Lenovo ThinkPad laptops only.
For Dell systems, see smbios-utils, particularly the smbios-battery-ctl
command, or install it using your package manager.
For other manufacturers there is also TLP.
There have also been some problems setting the charging threshold inside of a virtual machine.
------
要点:
在 Linux 中,关于电池方面的 app 主要有:两类
- 1. 检测类,只能检测电池的状态。
- 2. 控制类,可以控制电池充放电的阈值。
特别注意:能够延长电池寿命的 app,需要使用 控制类,并设置合理的阈值。
*** TLP电源管理 https://www.deepin.org/zh/tlp-power-management/
获得配置文件的路径,以及有关信息
sudo tlp-stat -b
Status Use the following command to check that TLP is enabled and active:
tlp-stat -s
启动服务
sudo tlp start
查看电量状态
sudo tlp-stat -s -c -b
------
------
Linux下如何设置能让笔记本电脑更省电? https://www.zhihu.com/question/596595897/answer/3030060892
linux电池充电阀值控制
https://blog.csdn.net/weixin_34240657/article/details/91948334
第一:
按照这个链接 http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html#installation
安装tlp:
sudo apt-get install tlp tlp-rdw
sudo apt-get install acpi-call-dkms //这里是dkms,所以需要安装linux-headers
第二:
sudo vi /etc/default/tlp
设置阀值
START_CHARGE_THRESH_BAT0=4 //小于4%开始充电
STOP_CHARGE_THRESH_BAT0=100 //到100%停止充电
第三:
启动服务
sudo tlp start
查看电量状态
sudo tlp-stat -s -c -b
------
Debian中的 backports存储库的作用是什么 https://blog.csdn.net/ken2232/article/details/137778522
https://www.sohu.com/a/313582256_100034897
电池充电阈值 —— 仅限 ThinkPad
重新校准电池 —— 仅限 ThinkPad
注:从官网上看,新版好像并不局限于 ThinkPad https://linrunner.de/tlp/introduction.html
Config Files
https://linrunner.de/tlp/settings/introduction.html
Settings are read from the following files in the specified order:
-
Intrinsic defaults
-
/etc/tlp.d/*.conf: Drop-in customization snippets, read in lexical (alphabetical) order
-
/etc/tlp.conf: User configuration
Hints:
-
In case of identical parameters in several but also within the same file, the last occurence has precedence
-
This also means, parameters in /etc/tlp.conf will override anything else because it is read last
-
All parameters in /etc/tlp.conf are disabled, remove the leading # to activate your change
-
Config files in the /etc/tlp.d/ directory are created by the user:
-
Filenames must end in .conf, otherwise the file will be ignored
-
00-template.conf is provided as an example
-
-
If in doubt, put your configuration changes in /etc/tlp.conf
-
Transfer settings when upgrading describes how to migrate your configuration from versions before 1.3
Note
TLP versions 1.2.2 and older stored all settings in a single config file named /etc/default/tlp.
ThinkPads only: External Kernel Modules
https://linrunner.de/tlp/installation/debian.html
Important
As of version 5.17, the Linux kernel in combination with TLP 1.5 or later offers full battery care support (i.e. charge thresholds and recalibration) for ThinkPads from model year 2011 onwards.
.
Therefore no external kernel modules are required with kernel 5.17 or later and you do not need to proceed any further here.
.
Linux kernels 4.19 through 5.16 provide only charge threshold functionality but no recalibration. If this is sufficient for you, stop reading here. However, if you need the recalibration feature or your model and/or kernel is older, read on. You may find out your current kernel version with the command uname -a or when TLP is already installed with tlp-stat -s.
Depending on your model and kernel version external kernel module(s) are required to provide battery charge thresholds and recalibration.
The output of tlp-stat -b will guide you which package to install:
-
tp-smapi-dkms (main) – optional – External kernel module providing battery charge thresholds and recalibration for ThinkPads before model year 2011 as well as specific tlp-stat -b output until model year 2011
-
acpi-call-dkms (main) – optional (kernel 5.16 and older only) – External kernel module providing battery recalibration for ThinkPads since model year 2011 - e.g. T420/X220 and newer
Install the appropriate package either with your favorite package manager or the command
apt install tp-smapi-dkms
Warning
Bullseye: the acpi-call-dkms package in the official repositories is incompatible with backports kernels ≥ 5.13 and may cause TLP battery care malfunction, system freezes and reboots.
Solution: install acpi-call-dkms version 1.2.2 from Debian backports:
大意是 ?? : acpi-call-dkms 模块,与 内核相关。
使用 backports 仓库中的内核,则也要使用 backports 仓库关联的 acpi-call-dkms。
在默认(如 main) 仓库中的内核,则也要使用 backports 仓库关联的 tp-smapi-dkms。
apt -t bullseye-backports install acpi-call-dkms
Note
-
Which external kernel module do I need for my ThinkPad? explains details
-
Refer to Debian backports for setup instructions
-
You must disable Secure Boot to use the ThinkPad specific packages
Package Installation
https://linrunner.de/tlp/installation/debian.html
Install the following packages
-
tlp (main) – Power saving
-
tlp-rdw (main) – optional (随意的,任选的,可选择的,非强制的;选修的;) – Radio Device Wizard
either with your favorite package manager or the command:
apt install tlp tlp-rdw
For Debian backports use:
apt -t DIST-backports install tlp tlp-rdw
Replace DIST with the codename of your installed Debian version.
The Radio Device Wizard provides the capability to enable or disable builtin bluetooth, Wi-Fi and WWAN devices triggered by certain events. It is implemented in the optional package tlp-rdw.
START/STOP_CHARGE_THRESH_BATx
https://linrunner.de/tlp/settings/battery.html
START_CHARGE_THRESH_BAT0=75 STOP_CHARGE_THRESH_BAT0=80 START_CHARGE_THRESH_BAT1=75 STOP_CHARGE_THRESH_BAT1=80
Set battery charge thresholds for main/internal battery BAT0 and auxiliary/Ultrabay battery BAT1:
-
Start charge threshold (START_CHARGE_THRESH_BATx): battery charge level below which charging will begin when connecting the charger.
-
Stop charge threshold (STOP_CHARGE_TRESH_BATx): battery charge level above which charging will stop while the charger is connected.
Thresholds always go with a lower usable battery capacity, therefore the settings are disabled by default and must be enabled explicitly by removing the leading #.
Important
You must always specify both charge thresholds - start and stop - for a battery, otherwise TLP will ignore the setting completely (and until version 1.3 silently). If you want to apply only one threshold (or your hardware does support only one), then use the dummy value 0 to skip the other one.
See also
RESTORE_THRESHOLDS_ON_BAT
RESTORE_THRESHOLDS_ON_BAT=1
Restore configured charge thresholds when AC is unplugged:
-
0 – disable
-
1 – enable
Default when unconfigured: 0
Hint: after the commands tlp fullcharge/recalibrate the charge thresholds will stay at the vendor specific defaults until the next reboot. Use this feature to restore them prematurely.
NATACPI/TPACPI/TPSMAPI_ENABLE
NATACPI_ENABLE=1 TPACPI_ENABLE=1 TPSMAPI_ENABLE=1
Control battery care drivers:
-
0 – disable
-
1 – enable
Default when unconfigured: 1 (all)
Scope:
NATACPI: all supported laptops
TPACPI_ENABLE, TPSMAPI_ENABLE: ThinkPad specific
------
Battery Care Vendor Specifics
https://linrunner.de/tlp/settings/bc-vendors.html
Lenovo ThinkPads
Hardware | Lenovo ThinkPad series since model year 2011 - e.g. T420(s)/T520/W520/X220 |
Kernel drivers | thinkpad_acpi - required, included in distribution kernels acpi_call - optional, enables recalibration for kernels before 5.17; distribution specific package needed |
TLP version | all |
TLP plugin | thinkpad |
Charge control options | Start and stop charge threshold, recalibration |
Threshold configuration | Main/internal battery BAT0 uses the START/STOP_CHARGE_THRESH_BAT0 parameters Auxiliary/UltraBay battery BAT1 uses the START/STOP_CHARGE_THRESH_BAT1 parameters |
Start threshold values | Range: 0 .. 99 Special: 0 - threshold off 96 - hardware default |
Stop threshold values | Range: 1 .. 100 Special: 100 - hardware default, threshold off |
See also | - Which external kernel module do I need for my ThinkPad? |
Sample configuration
Start charging battery BAT0 when below 75% and stop at 80%:
START_CHARGE_THRESH_BAT0=75 STOP_CHARGE_THRESH_BAT0=80
Sample output of tlp-stat -b
+++ Battery Care Plugin: thinkpad Supported features: charge thresholds, recalibration Driver usage: * natacpi (thinkpad_acpi) = active (charge thresholds, recalibration) Parameter value ranges: * START_CHARGE_THRESH_BAT0/1: 0(off)..96(default)..99 * STOP_CHARGE_THRESH_BAT0/1: 1..100(default) [...] /sys/class/power_supply/BAT0/charge_control_start_threshold = 75 [%] /sys/class/power_supply/BAT0/charge_control_end_threshold = 80 [%] /sys/class/power_supply/BAT0/charge_behaviour = [auto] inhibit-charge force-discharge
Lenovo/IBM legacy ThinkPads
Hardware | Lenovo or IBM ThinkPad series before model year 2011 |
Kernel drivers | thinkpad_acpi - required, included in distribution kernels tp_smapi - required, enables charge thresholds and recalibration; distribution specific package needed |
TLP version | all |
TLP plugin | thinkpad-legacy |
Charge control options | start and stop charge threshold, recalibration |
Threshold configuration | Main/internal battery BAT0 uses the START/STOP_CHARGE_THRESH_BAT0 parameters Auxiliary/UltraBay battery BAT1 uses the START/STOP_CHARGE_THRESH_BAT1 parameters |
Start threshold values | Range: 2 .. 96 Special: 96 - hardware default |
Stop threshold values | Range: 6 .. 100 Special: 100 - hardware default, threshold off |
See also |
Sample configuration
Start charging battery BAT0 when below 75% and stop at 80%:
START_CHARGE_THRESH_BAT0=75 STOP_CHARGE_THRESH_BAT0=80
Sample output of tlp-stat -b
+++ Battery Care Plugin: thinkpad-legacy Supported features: charge thresholds, recalibration Driver usage: * tp-smapi (tp_smapi) = active (status, charge thresholds, recalibration) Parameter value ranges: * START_CHARGE_THRESH_BAT0/1: 2..96(default) * STOP_CHARGE_THRESH_BAT0/1: 6..100(default) [...] /sys/devices/platform/smapi/BAT0/start_charge_thresh = 75 [%] /sys/devices/platform/smapi/BAT0/stop_charge_thresh = 80 [%] /sys/devices/platform/smapi/BAT0/force_discharge = 0
Lenovo non-ThinkPad series
Hardware | Lenovo laptops (all non-ThinkPad series) |
Kernel driver | ideapad_laptop - required, included in distribution kernels (4.14 or newer) |
TLP version | 1.4 and newer |
TLP plugin | lenovo |
Charge control options | Fixed stop charge threshold aka battery conservation mode |
Threshold configuration | All batteries - BAT0, BAT1 - share the START/STOP_CHARGE_THRESH_BAT0 parameter |
Stop threshold values | 1 - batteries charge to the fixed threshold 0 - batteries charge to 100%, conservation mode off |
Specifics | The fixed stop threshold value varies depending on the laptop model, 60% or 80% are common. There is no way to read out the actual threshold in Linux, therefore it cannot be displayed by tlp-stat -b. The figure of 60% shown up to version 1.6 was based on an assumption, but (according to user feedback) does not apply to all models. Some models ignore the setting, conservation mode remains off permanently. |
Sample configuration
Stop charging battery BAT0 and BAT1 at the fixed threshold:
START_CHARGE_THRESH_BAT0=0 # dummy value STOP_CHARGE_THRESH_BAT0=1
Stop charging battery BAT0 and BAT1 at 100%:
START_CHARGE_THRESH_BAT0=0 # dummy value STOP_CHARGE_THRESH_BAT0=0
Sample output of tlp-stat -b
+++ Battery Care Plugin: lenovo Supported features: charge threshold Driver usage: * vendor (ideapad_laptop) = active (charge threshold) Parameter value range: * STOP_CHARGE_THRESH_BAT0: 0(off), 1(on) -- battery conservation mode /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode = 1 (60%)
---------------------------------------------------------------
TLP - Optimize Linux Laptop Battery Life https://linrunner.de/tlp/#installation
https://linrunner.de/tlp/installation/debian.html
Warning
Bullseye: the acpi-call-dkms package in the official repositories is incompatible with backports kernels ≥ 5.13 and may cause TLP battery care malfunction(故障;失灵;功能障碍), system freezes(冻结) and reboots.
Solution: install acpi-call-dkms version 1.2.2 from Debian backports:
apt -t bullseye-backports install acpi-call-dkms
电源管理 电源管理工具
https://www.ucloud.cn/yun/10393.html
桌面环境的电源管理工具
桌面环境一般都有自己的电源管理工具,可设置对各种使用行为响应的电源动作 ,如使用电池时的亮度、灭屏时间、挂起时间、睡眠时间、盖上笔记本盖子的响应动作、按下电源键的响应动作等等。
可参看下文电源相关行为的响应动作进行一些更为详细或者电源管理工具为提供的设置,推荐配合tlp或laptop-mode-tools使用。
=====================================
***** 摘要:如何在Linux上监视和优化电源使用
https://blog.csdn.net/ttszgcs/article/details/108176026
通过命令行监视详细的电源使用情况报告
您可以通过以下几种方式监视电源使用情况,并通过Linux命令行查看电池报告。
1.使用upower实用程序,可以按以下方式监视电源守护程序的活动:
$ upower -monitor-detail
2. acpi实用程序通过从/ proc和/ sys文件中获取电池状态和热量信息。这是在系统上安装它的方法:
$ sudo apt-get install acpi
您可以使用以下选项通过acpi查看与电源有关的信息:
3.如果要监视电池的状态,可以通过运行以下命令来安装Batstat实用程序:
$ git clone https://github.com/Juve45/batstat.git
$ cd batstat/bin/
$ sudo cp batstat /usr/local/bin/
$ sudo chmod +x /usr/local/bin/batstat
然后,运行batstat命令以连续监视电池状态报告:
$ batstat
方法3:启用TLP https://blog.csdn.net/ttszgcs/article/details/108176026
TLP是一种开源且功能丰富的工具,可用于Linux系统上的电源优化。您可以根据其易用性使用其CLI或GUI。在系统上启用TLP时,它会根据您的操作系统和基础计算机来优化功耗。这是通过命令行安装的方法:
$ sudo apt-get install tlp
方法5:使用轻量级软件
使用powertop实用程序,您可以确定哪个软件对您的电源使用造成负担。您可以通过以下命令安装实用程序:
$ sudo apt install powertop
一旦了解了系统上的笨拙大象,如果它们造成的负担比减轻负担更大,您就可以摆脱它们。
这是您有关监视和管理Linux系统上的电源的全部知识。如果您使用电池而不是交流电来运行系统,这将特别有用。