owned this note
owned this note
Published
Linked with GitHub
# Optimizing battery life and Performance on linux on a Laptop
###### tags: `blog`
https://www.reddit.com/r/Dell/comments/9724vh/xps_9560_fedora_28_guide_for_power_saving_and_no/
## Battery Life Optimization
### TLP
For those who don't know what TLP is:
> TLP brings you the benefits of advanced power management for Linux without the need to understand every technical detail. TLP comes with a default configuration already optimized for battery life, so you may just install and forget it. Nevertheless TLP is highly customizable to fulfil your specific requirements.
All you need to do is install tlp and tlpui. You can tweak some settings in tlpui, but the default settings work nicely for me.
### Powertop
#### Why do I need powertop?
Although TLP is pretty nice, if your laptop has a dedicated GPU, you definitely need powertop, as it has this functionality:
> Runtime PM for PCI Device NVIDIA Corporation Device
This feature alone reduces the power consumption of my laptop from around 20W to less than 10W, bringing the battery life from 5 hours to over 10 hours. **MASSIVE** improvement.
#### How to set it up
First, install powertop
In powertop, you can enable/disable its battery optimization funcionalities, but they don't last thorugh reboots, so you have to turn them on everytime you restart your laptop. Fortunately, you can use systemctl to enable a service to do the trick automatically for you. Here's how you can do it:
As root, create and edit a file like /usr/lib/systemd/user/powertop.service.
The contents should be:
```
[Unit]
Description=Powertop tunings
[Service]
Type=oneshot
ExecStart=/usr/bin/powertop --auto-tune
[Install]
WantedBy=multi-user.target
```
(May be /usr/sbin/powertop in some distros, run which powertop to see which.) Then enable it with
`sudo systemctl enable /usr/lib/systemd/user/powertop.service`
Reboot, and you should see the NVIDIA card optimized in Powertop. (Some optimizations may stay in 'bad' state but that's not really an issue).
## Undervolting CPU
### Why you should unvervolt your CPU
Undervolting both increases battery life and lowers your CPU temperature, reducing CPU throttling and increasing performance. So the real question is, why not?
### Is undervolting dangerous
No. Undervolting will not damage your CPU. You might experience a few blue screens if you go too far on undervolting, but that won't damage your CPU, and once you find the right amount of undervolting your cpu can handle, you computer will run normally.
### How to
1. Install intel-undervolt
2. Edit /etc/intel-undervolt.conf
For example, I unvervolted my CPU and CPU cache by 140mV
```
undervolt 0 'CPU' -140
undervolt 1 'GPU' 0
undervolt 2 'CPU Cache' -140
undervolt 3 'System Agent' 0
undervolt 4 'Analog I/O' 0
```
3. run `intel-undervolt apply`
4. Once you've found the sweetspot(the maximal amount of undervolting your CPU can handle while staying stable), you can enable the undervolting settings so it automatically applies on every startup `systemctl enable --now intel-undervolt.service`